2
votes

I have built an API with Google Cloud Endpoints and I am trying to connect to it writing an Android application. I followed the following tutorial:

https://developers.google.com/appengine/docs/java/endpoints/consume_android

So, I added the content of the jar on my "src" folder, I copied the listed libraries to lib and I added the code. When I tried to start the application, it crashed with the following error:

        02-26 12:19:52.874: E/dalvikvm(17558): Could not find class 
    'com.google.api.services.utenteendpoint.Utenteendpoint$Builder', referenced from method 
    com.example.androidgcetest.MainActivity.onCreate


 02-26 12:19:53.004: E/AndroidRuntime(17558): FATAL EXCEPTION: main
02-26 12:19:53.004: E/AndroidRuntime(17558): java.lang.NoClassDefFoundError: com.google.api.services.utenteendpoint.Utenteendpoint$Builder
02-26 12:19:53.004: E/AndroidRuntime(17558):    at com.example.androidgcetest.MainActivity.onCreate(MainActivity.java:22)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at android.app.Activity.performCreate(Activity.java:4465)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at android.os.Looper.loop(Looper.java:137)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at android.app.ActivityThread.main(ActivityThread.java:4448)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at java.lang.reflect.Method.invokeNative(Native Method)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at java.lang.reflect.Method.invoke(Method.java:511)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
02-26 12:19:53.004: E/AndroidRuntime(17558):    at dalvik.system.NativeStart.main(Native Method)

Do you know the possible cause of this error?

EDIT: I also found this before the log reported above

02-26 16:51:57.780: W/dalvikvm(1230): Unable to resolve superclass of Lcom/google/api/services/utenteendpoint/Utenteendpoint$Builder; (20)
02-26 16:51:57.780: W/dalvikvm(1230): Link of class 'Lcom/google/api/services/utenteendpoint/Utenteendpoint$Builder;' failed
1
add you .jar file(s) to the lib not srcTheWhiteRabbit
I'm talking about the content of the source.jar file, as stated in the tutorial: "The Endpoints generation results in a sources jar file. Add the contents of this jar file to your Android project.". The jars to be included are added to the lib folder.Raffo
@Raffo I'm also having difficulty understanding where the "contents" of the sources.jar file goes, have you worked this out? It doesn't seem to me that you can just add the sources.jar file to the lib or libs folder because the content is .java files, not .class files.aez
I figured out that part of the tutorial. You don't need to add the content of the jar, but you have to add the content of the *-generated-source folder to your src folder. Then you need to add ONLY the libs that are reported by the tutorial.Raffo
BTW, I'm not able to reproduce this bug anymore, thus I'm waiting to mark anything as solved...Raffo

1 Answers

1
votes

Add the sources.jar file also to libs folder of your android project, just like the other jar files.

Thanks Raffo for finding the typo error in my earlier post