-1

这是我收到的错误;

05-16 04:42:07.579: E/dalvikvm(548): Could not find class 'com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$MyConstraintViolation', referenced from method com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$StandardPayloadDialect.processPayload
05-16 04:42:08.209: E/dalvikvm(548): Could not find class 'javax.validation.ConstraintViolation', referenced from method com.google.web.bindery.requestfactory.shared.Receiver.onConstraintViolation

所以这里是主类的代码。它在我只是为了试验而制作 的Hello Toast消息之后停止工作。

package com.ncwitmobileapp;
import com.ncwitmobileapp.R;
import com.ncwitmobileapp.client.MyRequestFactory;
import com.ncwitmobileapp.client.MyRequestFactory.HelloWorldRequest;
import com.ncwitmobileapp.client.MyRequestFactory.NCWITMOBILEAPPRequest;


import com.google.gwt.core.client.GWT;
import com.google.web.bindery.requestfactory.shared.Receiver;
import com.google.web.bindery.requestfactory.shared.ServerFailure;

import android.R.color;
import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class Login_Screen extends Activity
{
    private static final String TAG = "Techchicks";

    /**
     * The current context.
     */
    private Context mContext = this;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        requestWindowFeature(Window.FEATURE_NO_TITLE); 
        super.onCreate(savedInstanceState);      
        setContentView(R.layout.logins);

        final Button login = (Button)findViewById(R.id.login);
        login.setOnClickListener(new View.OnClickListener() {
            public void onClick(View lb) {
                //communicate with App Engine
                //goes to the Menu Page

                //gets username and password from user(Editables)

                EditText un=(EditText)findViewById(R.id.username);
                EditText ps=(EditText)findViewById(R.id.password);

                final String username = un.getText().toString();
                final String password = ps.getText().toString();
                final Context context = getApplicationContext();
                CharSequence text = "Hello toast!";
                int duration = Toast.LENGTH_SHORT;


                Toast toast = Toast.makeText(context, text, duration);
                toast.show();



                login.setEnabled(false);
                Log.i(TAG, "preparing request to send to server");
                login.setEnabled(false);
                Log.i(TAG, "preparing request to send to server");

                // Use an AsyncTask to avoid blocking the UI thread
                new AsyncTask<Void, Void, String>() {
                    private String message;

                    @Override
                    protected String doInBackground(Void... arg0) {

                        MyRequestFactory requestFactory = Util.getRequestFactory(mContext, MyRequestFactory.class);

                        final NCWITMOBILEAPPRequest request = requestFactory.nCWITMOBILEAPPRequest();
                        Log.i(TAG, "Sending request to server");
                        request.getAuthenticatedTechicksmember(username, password).fire(new Receiver<String>() {
                            @Override
                            public void onFailure(ServerFailure error) {
                                message = "Failure: " + error.getMessage();
                            }

                            @Override
                            public void onSuccess(String result) {
                                message = result;
                                Log.i(TAG,"got back a hello world message");
                            }
                        });
                        CharSequence tet = message;
                        int duration = Toast.LENGTH_SHORT;


                        Toast toast = Toast.makeText(context, tet, duration);
                        toast.show();
                        return message; 
                    }

                }.execute();

            }
        });

        Button register = (Button)findViewById(R.id.register);
        register.setOnClickListener(new View.OnClickListener() {
            public void onClick(View lb) {
                //goes to the Registration Page
            }
        });

        Button forgotpassword = (Button)findViewById(R.id.forgotpassword);
        forgotpassword.setOnClickListener(new View.OnClickListener() {
            public void onClick(View lb) {
                //goes to the Forgot Password Page
            }
        });
    }
}

这是来自服务类的代码:

package com.ncwitmobileapp.server;

import java.util.List;
import java.util.logging.Logger;

import com.ncwitmobileapp.annotation.ServiceMethod;

public class NCWITMOBILEAPPService {

     private static final Logger log = Logger.getLogger(NCWITMOBILEAPPService.class.getName());

      public NCWITMOBILEAPPService() {
      }

    @ServiceMethod
    public Techicksmember createTechicksmember() {
        // TODO Auto-generated method stub
        return null;
    }

    @ServiceMethod
    public static String getAuthenticatedTechicksmember(String userName, String password) {
         log.info("Called authenticateTechicksmember");
         log.info("userName = " + userName + " password = " + password);
        // return ("Success");

        Datastore db = new  Datastore();
        Techicksmember member = db.find(userName);
        if (member==null){
            return "Member not existant";
        }
        if (member.getPassword()==password){
            return "Identity validated!";
        }

        return "Identity Invalidated";

    }

    @ServiceMethod
    public Techicksmember readTechicksmember(Long id) {
        // TODO Auto-generated method stub
        return null;
    }

    @ServiceMethod
    public Techicksmember updateTechicksmember(Techicksmember techicksmember) {
        // TODO Auto-generated method stub
        return null;
    }

    @ServiceMethod
    public void deleteTechicksmember(Techicksmember techicksmember) {
        // TODO Auto-generated method stub

    }

    @ServiceMethod
    public List<Techicksmember> queryTechicksmembers() {
        // TODO Auto-generated method stub
        return null;
    }

}
4

2 回答 2

0

似乎编译器无法找到您要导入的文件的位置。如此处所见,com.google.web它不是 Android 的标准包。如果您在其他地方有这些文件,您可能需要调整构建路径以包含它们的位置。

于 2012-05-16T05:50:21.450 回答
0

是的,如上所述,只需在构建路径中包含所需的 jar 文件。

于 2012-05-16T06:34:05.723 回答