ADT18,App Engine Connected Android项目和noclassdeffounderror

时间:2012-05-02 02:31:20

标签: android google-app-engine adt

免责声明......我我已经浏览了这个主题的所有相关帖子,到目前为止,他们都没有解决我的问题。话虽这么说,如果我错过了什么,请随意指出我正确的方向。

环境:

- 新配置的Eclipse Indigo

-ADT 18

-GWT 2.4

-App Engine SDK 1.6.4

我正在尝试创建一个标准的,没有多余装饰的样板“App Engine Connected Android Project”,以开始学习如何在App Engine和Android之间处理事情。

完成文件后>新> App Engine Connected Android项目(具有功能性C2DM角色电子邮件和密码)我在Eclipse中获得了MyTasks-Android和MyTasks-AppEngine项目。

了解ADT17 +的整个lib与libs问题,我将MyTasks-Android项目中的lib文件夹更改为libs并更新三个jar的构建路径(c2dm.jar,requestfactory-client.jar和validation-api- 1.0.0.GA.jar)。我还将MyTasks-AppEngine项目添加到构建路径。

一旦完成,我尝试在我的设备上运行App-Android项目。

我可以选择我的Android帐户,“允许”它访问我的帐户,我看到“打个招呼”按钮。单击按钮后,我在Eclipse中收到以下错误:

05-01 22:13:22.965: E/dalvikvm(17457): Could not find class 'com.mytasks.client.MyRequestFactory', referenced from method com.mytasks.MyTasksActivity$2$1.doInBackground
05-01 22:13:22.965: W/dalvikvm(17457): VFY: unable to resolve const-class 315 (Lcom/mytasks/client/MyRequestFactory;) in Lcom/mytasks/MyTasksActivity$2$1;
05-01 22:13:22.965: D/dalvikvm(17457): VFY: replacing opcode 0x1c at 0x000a
05-01 22:13:22.973: W/dalvikvm(17457): threadid=11: thread exiting with uncaught exception (group=0x40a291f8)
05-01 22:13:22.989: E/AndroidRuntime(17457): FATAL EXCEPTION: AsyncTask #1
05-01 22:13:22.989: E/AndroidRuntime(17457): java.lang.RuntimeException: An error occured while executing doInBackground()
05-01 22:13:22.989: E/AndroidRuntime(17457):    at android.os.AsyncTask$3.done(AsyncTask.java:278)
05-01 22:13:22.989: E/AndroidRuntime(17457):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
05-01 22:13:22.989: E/AndroidRuntime(17457):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
05-01 22:13:22.989: E/AndroidRuntime(17457):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
05-01 22:13:22.989: E/AndroidRuntime(17457):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-01 22:13:22.989: E/AndroidRuntime(17457):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
05-01 22:13:22.989: E/AndroidRuntime(17457):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
05-01 22:13:22.989: E/AndroidRuntime(17457):    at java.lang.Thread.run(Thread.java:856)
05-01 22:13:22.989: E/AndroidRuntime(17457): Caused by: java.lang.NoClassDefFoundError: com.mytasks.client.MyRequestFactory
05-01 22:13:22.989: E/AndroidRuntime(17457):    at com.mytasks.MyTasksActivity$2$1.doInBackground(MyTasksActivity.java:145)
05-01 22:13:22.989: E/AndroidRuntime(17457):    at com.mytasks.MyTasksActivity$2$1.doInBackground(MyTasksActivity.java:1)
05-01 22:13:22.989: E/AndroidRuntime(17457):    at android.os.AsyncTask$2.call(AsyncTask.java:264)
05-01 22:13:22.989: E/AndroidRuntime(17457):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)

我一整天都在努力,到目前为止,没有运气。所以,如果有人有任何建议,我一定会感谢你的帮助。

谢谢!

EDIT - 5/2/2012 - 从MyTasksActivity类添加了setHelloWorldScreenContent。具体来说,失败于: MyRequestFactory requestFactory = Util.getRequestFactory(mContext,MyRequestFactory.class);

同样,这是一个由香草向导生成的App Engine Connected Android项目 - 我做的唯一改变是将MyTasks-AppEngine添加到MyTasks-Android构建路径并将lib更改为libs,然后将三个jar读取到构建路径。

private void setHelloWorldScreenContent() {
    setContentView(R.layout.hello_world);

    final TextView helloWorld = (TextView) findViewById(R.id.hello_world);
    final Button sayHelloButton = (Button) findViewById(R.id.say_hello);
    sayHelloButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            sayHelloButton.setEnabled(false);
            helloWorld.setText(R.string.contacting_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 HelloWorldRequest request = requestFactory.helloWorldRequest();
                    Log.i(TAG, "Sending request to server");
                    request.getMessage().fire(new Receiver<String>() {
                        @Override
                        public void onFailure(ServerFailure error) {
                            message = "Failure: " + error.getMessage();
                        }

                        @Override
                        public void onSuccess(String result) {
                            message = result;
                        }
                    });
                    return message;
                }

                @Override
                protected void onPostExecute(String result) {
                    helloWorld.setText(result);
                    sayHelloButton.setEnabled(true);
                }
            }.execute();
        }
    });
}

2 个答案:

答案 0 :(得分:4)

我遇到了同样的问题。我还刚刚将文件夹名称从lib更改为libs,并在andorid项目的构建路径中添加了3个jars并且它有效。

答案 1 :(得分:0)

我只花了4个小时,标准的lib-&gt; libs没有帮助我,最后解决方案是使用jdk 1.6编译而不是1.7,这意味着你必须从appengine编译共享库(逻辑上很好) )用1.6编译