我将一个项目转换为一个库,然后在另一个项目中使用了它,但是问题是当我尝试在gradle中用它来调用它时: 实施项目(':library'),出现此错误:
Android依赖项'android.arch.core:runtime'对于编译(1.1.0)和运行时(1.1.1)类路径具有不同的版本。
您应该通过DependencyResolution 手动设置相同的版本。
我和我都有很多依赖。
我的应用程式gradle:
android {
compileSdkVersion 28
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "com.free.caller"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.android.support:support-v4:27.1.1"
implementation "com.android.support:design:27.1.1"
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-ads:16.0.0'
implementation 'com.github.satyan:sugar:1.5'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.wang.avi:library:2.1.3'
implementation('com.github.alex31n:andutils:1.0.4') {
transitive = false
}
implementation('com.ornach.bitpermission:bit-permission:1.1') {
transitive = false
}
implementation('com.ornach.nobobutton:nobobutton:1.6') {
transitive = false
}
implementation('com.ornach.magicicon:magic-icon:1.6') {
transitive = false
}
implementation('com.ornach.richtext:richtext:1.0') {
transitive = false
}
implementation 'com.github.GrenderG:Toasty:1.3.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'com.github.florent37:expansionpanel:1.1.1'
implementation 'com.github.bumptech.glide:glide:3.7.0'
//// ---- when i call it, the error showed up
implementation project(':library')
}
我的图书馆gradle:
android {
compileSdkVersion 28
buildToolsVersion '28.0.2'
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude module: 'support-annotations'
}
implementation 'com.github.TeamNewPipe:NewPipeExtractor:217d13b1028'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.8.9'
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.android.support:support-v4:27.1.1"
implementation "com.android.support:design:27.1.1"
implementation "com.android.support:recyclerview-v7:27.1.1"
implementation "com.android.support:preference-v14:27.1.1"
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'ch.acra:acra:4.9.2'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.github.nirhart:ParallaxScroll:dd53d1f9d1'
implementation 'com.nononsenseapps:filepicker:4.2.1'
implementation "com.google.android.exoplayer:exoplayer:2.8.2"
implementation "com.google.android.exoplayer:extension-mediasession:2.8.2"
debugImplementation "com.facebook.stetho:stetho:1.5.0"
debugImplementation "com.facebook.stetho:stetho-urlconnection:1.5.0"
debugImplementation 'com.android.support:multidex:1.0.3'
implementation 'io.reactivex.rxjava2:rxjava:2.1.14'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
implementation "android.arch.persistence.room:runtime:1.1.1"
implementation "android.arch.persistence.room:rxjava2:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
implementation "frankiesardo:icepick:3.2.0"
annotationProcessor "frankiesardo:icepick-processor:3.2.0"
debugImplementation "com.squareup.leakcanary:leakcanary-android:1.5.4"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:1.5.4"
implementation "com.squareup.okhttp3:okhttp:3.10.0"
debugImplementation "com.facebook.stetho:stetho-okhttp3:1.5.0"
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
}
我认为导致此问题的所有原因是这些行:
implementation "android.arch.persistence.room:runtime:1.1.1"
implementation "android.arch.persistence.room:rxjava2:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
答案 0 :(得分:0)
我也遇到了同样的问题,所以我解决了Google服务更新
classpath'com.android.tools.build:gradle:3.2.1' classpath'com.google.gms:google-services:4.2.0'
Ps,如果将gradle更新到3.3.0或更高版本,则显示error,这是我的情况,所以我决定像这样设置gradle,然后它可以正常工作!