带有GCM服务的java.lang.ClassNotFoundException

问题描述 投票:0回答:2

我试图让GCM在我的Android-App上运行,我在调用GCMRegistrar.register()后不久收到这个奇怪的错误消息(app-name是我无法透露的app的名称):

 java.lang.ClassNotFoundException: Didn't find class 
 "com.<companyname>.<appname>.GCMIntentService" on path: DexPathList[[zip file 
 "/system/framework/com.google.android.maps.jar", zip file "/data/app/<app-
 name>"],nativeLibraryDirectories=[/data/app-lib/<app.name>, 
 /vendor/lib, /system/lib]]

AndroidManifest的(我认为)相关部分:

 <service android:name=".GCMIntentService" />

GCMIntentService类存在于指定的路径中,我从Google提供的GCM-Client项目中复制了该文件,所以我真的不知道问题所在。

有任何想法吗?

更新:我将类GCMIntentService移动到以下包:

 com.google.android.gcm.demo.app

不,我收到警告:

Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTRATION 
flg=0x10 pkg=com.<company-name>.<app-name> 
cmp=com.xitaso.plugsurfing/.GCMIntentService (has extras) } U=0: not found

那是什么意思?

android noclassdeffounderror google-cloud-messaging
2个回答
0
投票

我弄清楚问题是什么:GCMIntentService必须在包名的根目录中,在我的例子中是com.companyname.appname;我创建了一个单独的包,我放了GCMIntentService类,从那时起它工作正常(至少我认为这是主要问题)。


0
投票

如果您不使用GCM,并且此异常来自其他库,请执行以下操作:

 <service
     android:name="package.GCMIntentService"
     tools:node="remove" />
© www.soinside.com 2019 - 2024. All rights reserved.