Apollo GraphQL migration from v1 - 2

427 Views Asked by At

I am trying to update my Apollo implementation from v1.3.3 -> 2.5.4. I've followed the migration guide which is super simple but whenever I do it I get the following error.

Execution failed for task ':app:dataBindingMergeDependencyArtifactsOuterspatialDebug'.
> Could not resolve all files for configuration ':app:outerspatialDebugCompileClasspath'.
   > Could not resolve com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4.
     Required by:
         project :app
      > The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'default' with value 'outerspatial'. However we cannot choose between the following variants of com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4:
          - android-debugApiElements
          - android-debugRuntimeElements
          - jvm-api
          - jvm-runtime
        All of them match the consumer attributes:
          - Variant 'android-debugApiElements' capability com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4 declares an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
              - Unmatched attributes:
                  - Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
                  - Provides attribute 'com.android.build.gradle.internal.dependency.AndroidTypeAttr' with value 'Aar' but the consumer didn't ask for it
                  - Doesn't say anything about default (required 'outerspatial')
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
          - Variant 'android-debugRuntimeElements' capability com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4 declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
              - Unmatched attributes:
                  - Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
                  - Provides attribute 'com.android.build.gradle.internal.dependency.AndroidTypeAttr' with value 'Aar' but the consumer didn't ask for it
                  - Doesn't say anything about default (required 'outerspatial')
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
          - Variant 'jvm-api' capability com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4 declares an API of a component:
              - Unmatched attributes:
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Doesn't say anything about default (required 'outerspatial')
                  - Provides its elements packaged as a jar but the consumer didn't ask for it
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but the consumer didn't ask for it
          - Variant 'jvm-runtime' capability com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4 declares a runtime of a component:
              - Unmatched attributes:
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Doesn't say anything about default (required 'outerspatial')
                  - Provides its elements packaged as a jar but the consumer didn't ask for it
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but the consumer didn't ask for it
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'android-releaseApiElements' capability com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4 declares an API of a component:
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'
              - Other compatible attribute:
                  - Doesn't say anything about default (required 'outerspatial')
          - Variant 'android-releaseRuntimeElements' capability com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4 declares a runtime of a component:
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'
              - Other compatible attribute:
                  - Doesn't say anything about default (required 'outerspatial')
          - Variant 'ios-api' capability com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4:
              - Incompatible because this component declares a usage of 'kotlin-api' of a component and the consumer needed an API of a component
              - Other compatible attributes:
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Doesn't say anything about default (required 'outerspatial')
          - Variant 'iosSim-api' capability com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4:
              - Incompatible because this component declares a usage of 'kotlin-api' of a component and the consumer needed an API of a component
              - Other compatible attributes:
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Doesn't say anything about default (required 'outerspatial')
          - Variant 'metadata-api' capability com.apollographql.apollo:apollo-normalized-cache-sqlite:2.5.4:
              - Incompatible because this component declares a usage of 'kotlin-api' of a component and the consumer needed an API of a component
              - Other compatible attributes:
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Doesn't say anything about default (required 'outerspatial')

There seems to be some sort of conflict with some android/java files. I've read the short set-up documentation several times and don't see where my implementation is any different than the example. Anybody know anything about this?

my app level dependecies are as follows:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.2.0'
//    implementation 'com.android.support:support-compat:28.0.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'com.squareup.okhttp3:okhttp:4.6.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
    implementation 'com.squareup.retrofit2:retrofit:2.6.2'
    implementation 'com.github.bumptech.glide:glide:4.10.0'
    implementation 'androidx.work:work-runtime:2.5.0'

    // apollo
    implementation 'com.apollographql.apollo:apollo-android-support:2.5.4'
    implementation 'com.apollographql.apollo:apollo-gradle-plugin:2.5.4'
    implementation 'com.apollographql.apollo:apollo-http-cache:2.5.4'
    implementation 'com.apollographql.apollo:apollo-runtime:2.5.4'

    implementation 'ca.mimic:oauth2library:2.4.2'
    implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0') {
        exclude group: 'group_name', module: 'module_name'
    }

    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    implementation platform('com.google.firebase:firebase-bom:26.1.0')
    releaseImplementation 'com.google.firebase:firebase-analytics'
    releaseImplementation 'com.google.firebase:firebase-crashlytics'
    releaseImplementation 'com.google.firebase:firebase-appindexing'
    releaseImplementation 'com.google.firebase:firebase-perf'

    implementation 'io.branch.sdk.android:library:5.0.1'
    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
    implementation 'androidx.preference:preference:1.1.1'
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    implementation 'com.segment.analytics.android:analytics:4.9.0'

    implementation 'com.google.android.play:core:1.9.1'
    implementation 'com.github.chrisbanes:PhotoView:2.3.0'

    implementation "androidx.room:room-runtime:2.2.6"
    annotationProcessor  'android.arch.persistence.room:compiler:1.1.1'
    implementation "com.leinardi.android:speed-dial:3.1.1"

    implementation 'com.google.android.gms:play-services-location:18.0.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    compileOnly 'org.jetbrains:annotations:13.0'
    testCompileOnly 'org.jetbrains:annotations:13.0'

//    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.5'
}

The project level:

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
        classpath 'com.apollographql.apollo:apollo-gradle-plugin:2.5.4'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
        classpath 'com.google.firebase:perf-plugin:1.3.4'
    }
}
1

There are 1 best solutions below

0
On

I've been having a very similar issue and still looking for the best solution.

For now what worked for me is to downgrade classpath 'com.android.tools.build:gradle:4.1.2' to classpath 'com.android.tools.build:gradle:4.0.2'. Once i did that the project started building.

The other way was if I left 'v4.1.2' as is and in the application level gradle file I added:

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        matchingFallbacks = ["release"]
    }
    debug {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        matchingFallbacks = ["release"]
    }
}