如何解决Apollo GraphQL 从 v1-2 迁移
我正在尝试从 v1.3.3 -> 2.5.4 更新我的 Apollo 实现。我遵循了非常简单的迁移指南,但每当我这样做时,我都会收到以下错误。
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 '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')
似乎与某些 android/java 文件存在某种冲突。我已经多次阅读简短的设置文档,但没有看到我的实现与示例有什么不同。有人知道这件事吗?
我的应用级依赖如下:
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'
}
项目层面:
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'
}
}
解决方法
我遇到了一个非常相似的问题,但仍在寻找最佳解决方案。
现在对我有用的是降级 类路径 'com.android.tools.build:gradle:4.1.2' 到类路径 'com.android.tools.build:gradle:4.0.2'。一旦我这样做了,项目就开始构建了。
另一种方式是,如果我保留“v4.1.2”原样并在应用程序级别的 gradle 文件中添加:
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"]
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。