【问题标题】:App crash with this error in some device..java.lang.NoClassDefFoundError: com.google.android.gms.R$string应用程序在某些设备中出现此错误而崩溃..java.lang.NoClassDefFoundError: com.google.android.gms.R$string
【发布时间】:2016-02-04 07:11:41
【问题描述】:

我的应用程序在所有设备上运行,除了一些三星设备.. 这些设备给出异常

java.lang.NoClassDefFoundError: com.google.android.gms.R$string

我正在使用这个依赖 -

compile 'com.google.android.gms:play-services:8.4.0'

【问题讨论】:

  • 在投反对票之前在此处发表评论或发表理由..
  • 请检查您的设备,是否安装了 Google Play 服务。
  • @KundanKumarRoy 您是否在应用程序中使用地图?
  • @Dhruv 是的,我正在使用
  • @KundanKumarRoy 你能分享一些与此相关的代码吗?

标签: android google-maps google-play-services


【解决方案1】:

我得到了解决方案,它与播放服务无关。这是棒棒糖前设备中的 multidex 错误。

在 build.gradle 中添加了 mutidex 依赖项。

【讨论】:

    【解决方案2】:

    根据site, 需要在扩展Application的类中添加如下@Override方法:

    public class FirebaseCntx extends Application {
        ...
        @Override
        protected void attachBaseContext(Context base) {
    
            super.attachBaseContext(base);
            MultiDex.install(this);
        }
        ...
    }
    

    【讨论】:

      【解决方案3】:

      我在 Samsung tab 4.4.2 设备中遇到了同样的问题。问题不是因为谷歌播放服务。这是因为 Gradle 脚本中启用了 multidex 支持,但忘记更新 AndroidManifest.xml。

      <?xml version="1.0" encoding="utf-8"?>
      <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.myapp">
          <application
                  android:name="android.support.multidex.MultiDexApplication" >
              ...
          </application>
      </manifest>
      

      android:name加入manifest文件后解决。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-20
        相关资源
        最近更新 更多