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

后端 未结 8 1325
借酒劲吻你
借酒劲吻你 2021-01-18 08:00

I am having a little trouble with the complier, Same code I use on Nexus 5, no error. as Soon as I use it in Tablet, it crash right away and the error said

java.la

相关标签:
8条回答
  • 2021-01-18 08:30

    Got the same problem.. just clean the project, then make it and finally run it

    0 讨论(0)
  • 2021-01-18 08:32

    I believe you should try turning multiDexEnabled false and get rid of the compile 'com.google.android.gms:play-services-gcm:8.4.0' . You have two play-services which forces you to turn multiDexEnabled to true

    0 讨论(0)
  • 2021-01-18 08:35

    Change this line

    <uses-permission
    android:name="com.google.android.c2dm.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
    

    with this

    <permission android:name="<your-package-name>.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="<your-package-name>.permission.C2D_MESSAGE" />
    

    Also i see a lot of anomaly in your manifest with respect to how you have declared GCM . Have a look at the technical docs.

    0 讨论(0)
  • 2021-01-18 08:45

    I look into my code many time, and I look at each library I am using and I was able to fix it.

    First, like @BrainMiz said mutiDexEnabled should set it off. I just comment it instead of set it as false.

    defaultConfig {
         applicationId "com.package.name"
         minSdkVersion 16
         targetSdkVersion 23
         versionCode 1
         versionName "1.0"
         //multiDexEnabled true
    }
    

    Second, it is the dependencies. Since I don't have any jar in my libs folder I remove

      compile fileTree(dir: 'libs', include: ['*.jar'])
    

    also remove all not being used gms library, only add the one that being used. I have to give some credits to @Radix because I did found some error in my code regarding to the code that where I check if the device has google play store.

    dependencies {
        //compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
    
        compile 'org.twitter4j:twitter4j-core:4.0.2'
        compile 'com.android.support:multidex:1.0.1'
        compile 'com.android.support:appcompat-v7:23.1.1'
        //compile 'com.google.android.gms:play-services:8.4.0'
        compile 'com.android.support:design:23.1.1'
        compile 'com.squareup.okhttp:okhttp:2.5.0'
        //compile 'com.android.support:support-v4:23.1.1'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.isseiaoki:simplecropview:1.0.8'
        compile 'com.qozix:tileview:2.0.7'
        compile 'com.android.support:cardview-v7:23.1.1'
        compile 'com.google.android.gms:play-services-gcm:8.4.0'
    }
    
    0 讨论(0)
  • 2021-01-18 08:48

    I had the same issue

    Had in gradle.build dependencies :

    compile 'com.android.support:multidex:1.0.0'
    

    And in AndroidManifest.xml :

    <application
            ...
            android:name="android.support.multidex.MultiDexApplication">
    
    0 讨论(0)
  • 2021-01-18 08:48

    Having same issue and was stuck for a whole day. Finally got solution.

    Add in your app level gradle.build:

    repositories {
      jcenter()
    }
    
    dependencies {
      compile 'com.google.android:multidex:0.1'
    }
    

    Then override attachBaseContext in your Application class like below:

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
    

    And don't forgot to enable mutlidex support as below:

    android {
        ...
        defaultConfig {
            ...
            multiDexEnabled true
        }
    }
    
    0 讨论(0)
提交回复
热议问题