Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError and ClassNotFoundException

Tags:

java

android

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'm trying to run my application, this 'com.google.gson' library is a jar file that I did added to my project and can't understand when I have this problems..

No code added as I find it not relevent to the error...

like image 880
John Doe Avatar asked Mar 17 '23 12:03

John Doe


2 Answers

Copy jar into your libs folder and add this to your build.gradle dependencies

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.3.1'

(Exchange 2.3.1 for your version of json, or use 2.3.*)

Dont forget to sync

like image 130
Eric S. Avatar answered Mar 19 '23 01:03

Eric S.


I use AS.I meet the same problem when I generated signed apk and I do add gson.jar as library.Then i clean the project the problem gone;

like image 37
wanglugao Avatar answered Mar 19 '23 01:03

wanglugao