Getting NoClassDefFoundError with Google Cloud Mes

2019-08-05 08:14发布

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)

2条回答
甜甜的少女心
2楼-- · 2019-08-05 08:36

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.

查看更多
淡お忘
3楼-- · 2019-08-05 08:44

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.

查看更多
登录 后发表回答