免責聲明......我想我已經通過所有相關的帖子了關於這一主題,到目前爲止,他們都沒有固定我的問題。這就是說,如果我錯過了一些東西,請隨時指出我的方向。ADT18,App Engine將連接的Android項目的NoClassDefFoundError
環境:
-newly配置Eclipse的靛藍
-ADT 18
-GWT 2.4
-APP引擎SDK 1.6.4
我試圖創建一個標準的,沒有裝飾樣板的「App Engine連接Android項目」開始學習App Engine和Android之間的事情是如何處理的。
完成File> New> 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)
我一直在這一整天工作,迄今沒有運氣。所以,如果任何人有任何建議,我一定會感謝幫助。
謝謝!
編輯 - 2012年5月2日 - 添加了MyTasksActivity類的setHelloWorldScreenContent。具體而言,失敗:MyRequestFactory requestFactory = Util.getRequestFactory(mContext,MyRequestFactory.class);
同樣,這是一個vanilla嚮導生成的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();
}
});
}
你能顯示MyTasksActivity類的代碼(涉及到你的錯誤的部分)。 – THelper
向OP添加代碼 - 非常感謝 – Kyle