我目前正在开发一款使用app引擎后端的应用。以下代码与
崩溃java.lang.NoClassDefFoundError: com.petfinder.backend.model.userApi.UserApi$Builder
我很难过。我试过更新所有的罐子。仍然没有运气。
我可以在我的Nexus 6上运行而不会出现错误,但是当我在其他设备(如Moto E)上运行时,错误会导致应用程序崩溃。
在4.4.4设备上进行测试。
UserApi.Builder builder = new UserApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
// options for running against local devappserver
// - 10.0.2.2 is localhost's IP address in Android emulator
// - turn off compression when running against local devappserver
// .setRootUrl("http://192.168.16.254:8080/_ah/api")
.setRootUrl(URL)
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
例外:
FATAL EXCEPTION: AsyncTask #2
Process: com.petfinder.petfinder, PID: 17401
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)
Caused by: java.lang.NoClassDefFoundError: com.petfinder.backend.model.userApi.UserApi$Builder
at com.petfinder.petfinder.util.PetUtil.getUserApi(PetUtil.java:52)
at com.petfinder.petfinder.ui.LoginActivity$UserLoginTask.doInBackground(LoginActivity.java:330)
at com.petfinder.petfinder.ui.LoginActivity$UserLoginTask.doInBackground(LoginActivity.java:317)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)
01-16 09:06:53.481 17401-17401/com.petfinder.petfinder D/ActivityThread: ACT-AM_ON_PAUSE_CALLED ActivityRecord{41dfff48 token=android.os.BinderProxy@
答案 0 :(得分:0)
发现问题是谷歌播放服务已过时。通过检查Google Play服务并更新过期设备来修复此问题。
public void checkPlayServices() {
int state = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (state == ConnectionResult.SUCCESS) {
Toast.makeText(this, "SUCCESS", Toast.LENGTH_LONG).show();
} else {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(state, this, -1);
dialog.show();
}
}