NoClassDefFoundError and ClassNotFoundException
I get these errors:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/stream/JsonReader; Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.gson.stream.JsonReader" on path: DexPathList[[zip file "/data/app/project.1stApp.youtubeplayer-1/ base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
When I try to run my app, this “
com.google.gson” library is a jar file that I did add to my project, which I couldn’t understand when I ran into this issue.
Didn’t add code because I found it not related to the bug….
Copy the jar to your libs folder and add it to your build.gradle dependencies
compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.code.gson:gson:2.3.1'
(Swap 2.3.1 for your JSON version, or use 2.3.*).
Don’t forget to sync