PokeGOAPI-Java icon indicating copy to clipboard operation
PokeGOAPI-Java copied to clipboard

Error NoClassDefFound on Android

Open pompobit opened this issue 10 years ago • 6 comments

I'm trying to use these API on Android, I built the bundle, imported in the project and added compile files('libs/PokeGOAPI-Java_bundle-0.0.1-SNAPSHOT.jar') on gradle.build (I'm on Android studio). I can correctly build my project and run it, but at runtime when I try to log in (both with PTC and Google) the app crashes. Here's the log:

java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:309) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.NoClassDefFoundError: Failed resolution of: LPOGOProtos/Networking/EnvelopesOuterClass$Envelopes$RequestEnvelope$AuthInfo; at com.pokegoapi.auth.GoogleLogin.login(GoogleLogin.java:78) at com.acatch.pompomon.pokemon.MainActivity$Login.doInBackground(MainActivity.java:98) at com.acatch.pompomon.pokemon.MainActivity$Login.doInBackground(MainActivity.java:56) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  at java.lang.Thread.run(Thread.java:818)  Caused by: java.lang.ClassNotFoundException: Didn't find class "POGOProtos.Networking.EnvelopesOuterClass$Envelopes$RequestEnvelope$AuthInfo" on path: DexPathList[[zip file "/data/app/com.acatch.pompomon.pokemon-2/base.apk"],nativeLibraryDirectories=[/data/app/com.acatch.pompomon.pokemon-2/lib/arm, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at com.pokegoapi.auth.GoogleLogin.login(GoogleLogin.java:78)  at com.acatch.pompomon.pokemon.MainActivity$Login.doInBackground(MainActivity.java:98)  at com.acatch.pompomon.pokemon.MainActivity$Login.doInBackground(MainActivity.java:56)  at android.os.AsyncTask$2.call(AsyncTask.java:295)  at java.util.concurrent.FutureTask.run(FutureTask.java:237)  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  at java.lang.Thread.run(Thread.java:818)  Suppressed: java.lang.NoClassDefFoundError: POGOProtos.Networking.EnvelopesOuterClass$Envelopes$RequestEnvelope$AuthInfo at dalvik.system.DexFile.defineClassNative(Native Method) at dalvik.system.DexFile.defineClass(DexFile.java:226) at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219) at dalvik.system.DexPathList.findClass(DexPathList.java:338) at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54) ... 11 more Suppressed: java.lang.ClassNotFoundException: POGOProtos.Networking.EnvelopesOuterClass$Envelopes$RequestEnvelope$AuthInfo at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 10 more Caused by: java.lang.NoClassDefFoundError: > > Class not found using the boot class loader; no stack trace available

So it seems it cannot find anything of POGO library (at runtime, at build time everything is fine). I'm not sure but searching around seems like it could something related to DeX: http://stackoverflow.com/questions/28283688/noclassdeffounderror-for-jar-library-at-runtime-in-android-studio but I don't know which modules are defined as Application (I guess there aren't).

So, any idea? And keep up the good work, if I'll find some time I'll contribute too

pompobit avatar Jul 19 '16 23:07 pompobit

Should be fixed in https://github.com/Grover-c13/PokeGOAPI-Java/pull/46 when the server will be stable for testing and merging.

Or you could just build the lib yourself by replacing compileOnly to compile in the gradle build file for the protobuf dependency.

vmarchaud avatar Jul 19 '16 23:07 vmarchaud

I'm looking into #46 but I don't understand, in what way is related to my issue?

pompobit avatar Jul 20 '16 00:07 pompobit

Check that line of the commit.

vmarchaud avatar Jul 20 '16 08:07 vmarchaud

Is this issue still occurring on latest commit @pompobit

Grover-c13 avatar Jul 20 '16 11:07 Grover-c13

@Grover-c13 I can't check now, I will be able to do it in a few hours

pompobit avatar Jul 20 '16 13:07 pompobit

@Grover-c13 I can confirm that the issue is gone, thanks

pompobit avatar Jul 20 '16 18:07 pompobit