我最近将build.gradle文件更改为使用implementation
而不是compile
。
implementation
关键字强制您确保所有依赖项都使用相同的版本。
谷歌地图依赖关系'com.google.android.gms:play-services-maps:12.0.1'
显然使用旧版本的支持库(26.1.0)
我在运行./gradlew dependencies -b app/build.gradle
这是输出:
+--- com.google.android.gms:play-services-maps:12.0.1
| +--- com.google.android.gms:play-services-base:12.0.1
| | +--- com.google.android.gms:play-services-basement:12.0.1
| | | +--- com.android.support:support-v4:26.1.0
| | | | +--- com.android.support:support-compat:26.1.0 -> 27.1.0 (*)
| | | | +--- com.android.support:support-media-compat:26.1.0
| | | | | +--- com.android.support:support-annotations:26.1.0 -> 27.1.0
| | | | | \--- com.android.support:support-compat:26.1.0 -> 27.1.0 (*)
| | | | +--- com.android.support:support-core-utils:26.1.0 -> 27.1.0 (*)
| | | | +--- com.android.support:support-core-ui:26.1.0 -> 27.1.0 (*)
| | | | \--- com.android.support:support-fragment:26.1.0 -> 27.1.0 (*)
问题是:有这种情况的解决方案吗?我知道使用compile
代替implementation
可以解决问题,但{201}将删除compile
。
以下是build.gradle
文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.test.myapplication"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
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.0'
implementation 'com.google.android.gms:play-services-maps:12.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}