[英]android studio java.lang.NoClassDefFoundError Gson
I've made pretty much a fresh project. 我做了一个很新的项目。 I added in the
gson
library by google to my projects /libs
directory and added it as a library. 我通过谷歌将
gson
库添加到我的projects /libs
目录并将其添加为库。 I also added it into my build.gradle
as 我还将它添加到我的
build.gradle
中
compile files('libs/gson-2.2.4.jar')
So now everything looks ok, there aren't any errors given by Android Studio, no red underlines anywhere. 所以现在一切看起来都不错,Android Studio没有任何错误,任何地方都没有红色下划线。 I can build it and give it a shot.
我可以建立它并试一试。
But then I run into this error: 但后来我遇到了这个错误:
java.lang.NoClassDefFoundError: com.google.gson.Gson
Which I can see in the debugger. 我在调试器中可以看到。 The thing is i've added it in and android studio can see that but come build it gives me all these sorts of problems.
事情是我已经添加它并且android studio可以看到但是来构建它给了我所有这些类型的问题。
What am I doing wrong? 我究竟做错了什么?
Had the same issue. 有同样的问题。 What I did was
gradle clean
and then build my project with gradle from console. 我做的是
gradle clean
,然后从控制台用gradle构建我的项目。 In my build.gradle
gson dependency looks like this: 在我的
build.gradle
gson依赖关系如下所示:
dependencies {
compile 'com.google.code.gson:gson:2.2.4'
}
Something went wrong in incremental build system. 增量构建系统出了问题。 One of this should help:
其中一个应该有所帮助:
I'm using Android Studio. 我正在使用Android Studio。 and in my case,
gradle clean
and/or Rebuild project didn't work. 在我的情况下,
gradle clean
和/或Rebuild项目不起作用。 I had to uninstall the current SDK (in my case: 22) that was supposed to be corrupted and then reinstall it. 我不得不卸载当前被破坏然后重新安装的SDK(在我的情况下:22)。 After doing this, the project restarted to compile and run.
执行此操作后,项目重新启动以进行编译和运行。 Hope it can help someone.
希望它可以帮助某人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.