0

I am running gcm web server, but it has over gcm version (previous firebase)

so, referenced older project and use that project's gcm dependency.

I saw this issue: GCM unregister causing the application to crash

but it doesn't work for me.

my gradle setting below:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation project(path: ':permissionchecker')
    implementation project(path: ':datastateview')
    implementation 'com.android.support:appcompat-v7:25.1.0'
    implementation 'com.android.support:support-vector-drawable:25.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.squareup.retrofit2:converter-scalars:+'
    implementation 'com.squareup.retrofit2:converter-gson:+'
    implementation 'me.relex:circleindicator:1.2.2@aar'
    implementation 'com.android.support:design:25+'
    implementation 'com.android.support:support-v4:25+'
    implementation 'com.android.support:recyclerview-v7:25+'
    implementation 'br.com.simplepass:loading-button-android:+'
    implementation 'com.googlecode.android-query:android-query:0.25.9'
    implementation 'org.altbeacon:android-beacon-library:2.+'
    compile 'com.google.android.gms:play-services-gcm:10.0.1'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

and root build.gradle:

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    classpath 'com.google.gms:google-services:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

I tried to many version of, but I met many exception. like

java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.()' is inaccessible to class 'com.google.android.gms.iid.zzd' (declaration of 'com.google.android.gms.iid.zzd' appears in base.apk)

or

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

and any others.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
JYL
  • 193
  • 2
  • 16

1 Answers1

0

This is because there is duplicated dependencies. You must not use inexact version of library by using +. You should not use this:

implementation 'com.android.support:design:25+'

because it means that you want to get the latest version of support library 25. So, it will be the same as:

implementation 'com.android.support:design:25.4.0'

support design is implicity using appcompat-v7 and support-v4. So, the above code is the same as:

implementation 'com.android.support:design:25.4.0'
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support:support-v4:25.4.0'

In the end, your support library dependencies will be:

implementation 'com.android.support:appcompat-v7:25.1.0'
implementation 'com.android.support:support-vector-drawable:25.1.0'
implementation 'com.android.support:design:25.4.0'
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support:support-v4:25.4.0'

which is obviously duplicated.

You need to check if you have another duplicated libraries with:

gradle -q dependencies your-app-project:dependencies

Change your-app-project to your module name, for example, app.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • `design` includes `support-v4` and `appcompat-v7`, so I would suggest removing those two anyway – OneCricketeer Mar 26 '18 at 04:31
  • so... you mean gcm dependency is conflicted with support library? build app without gcm and gms dependency, it works well. – JYL Mar 26 '18 at 05:21