【问题标题】:java.lang.ClassNotFoundException with GCM Service带有 GCM 服务的 java.lang.ClassNotFoundException
【发布时间】:2014-03-31 13:22:32
【问题描述】:

我试图让 GCM 在我的 Android 应用程序上运行,在调用 GCMRegistrar.register() 后不久我收到了这个奇怪的错误消息(应用程序名称是我不能透露的应用程序的名称) :

 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 类存在于指定路径,我是从谷歌提供的 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

这是什么意思?

【问题讨论】:

  • 您使用的是哪个 IDE? Eclipse 还是 Android Studio?
  • @Thomas Bouron 我正在使用 Eclipse。
  • 确保包名正确。
  • @deimos1988 转到项目设置 -> Java 构建路径 -> 订购和导出并确保选中 Android private libraries
  • @Thomas Bouron 私有库已检查。

标签: android noclassdeffounderror google-cloud-messaging


【解决方案1】:

我发现问题出在哪里:GCMIntentService 必须位于包名的根目录中,在我的例子中是 com.companyname.appname;我创建了一个单独的包,在其中放置了 GCMIntentService 类,从那时起它运行良好(至少我认为这是主要问题)。

【讨论】:

    【解决方案2】:

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

     <service
         android:name="package.GCMIntentService"
         tools:node="remove" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-24
      • 1970-01-01
      • 2018-01-10
      • 1970-01-01
      相关资源
      最近更新 更多