Getting NoClassDefFoundError with Google Cloud Messaging (GCM) on Nexus 4

六眼飞鱼酱① 提交于 2019-12-24 08:26:05

问题


I have the gcm.jar in my classpath, so eclipse compiles the project but it fails on my Nexus 4 device with

02-24 11:52:12.645: E/AndroidRuntime(30240): FATAL EXCEPTION: main
02-24 11:52:12.645: E/AndroidRuntime(30240): java.lang.NoClassDefFoundError: com.google.android.gcm.GCMRegistrar
02-24 11:52:12.645: E/AndroidRuntime(30240):    at com.foo.closethedoor.CloseTheDoorActivity.onCreate(CloseTheDoorActivity.java:77)

回答1:


I have the gcm.jar in my classpath

It needs to be in your project's libs/ directory. Do not just manipulate the Eclipse build path manually -- that will allow you compile against the JAR but does not ship the JAR with your APK. Putting the JAR in libs/ does both.




回答2:


NoClassDefFoundError means the Application is unable to find the location of the file inside the Application's folder. It is advised to keep all the library files and jar files in 'libs' folder of the Project.Try doing so.It will resolve the issue. If not, try building the code again before pushing it onto the device.



来源:https://stackoverflow.com/questions/15055351/getting-noclassdeffounderror-with-google-cloud-messaging-gcm-on-nexus-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!