Android Gradle插件兼容及配置相关问题求助
Hey there, let's work through these build issues step by step. I'll show you exactly what changes to make in your Gradle files to get everything working smoothly.
1. Fix the Kotlin Gradle Plugin Version Error
Your Android Gradle Plugin (AGP) 3.3.1 requires the Kotlin Gradle Plugin to be at least 1.3.0, but you're using 1.0.6. Here's how to update it:
Modify your root build.gradle file:
Change the kotlin_version to a compatible version (1.3.72 works perfectly with AGP 3.3.1):
buildscript { ext.kotlin_version = '1.3.72' // Updated from 1.0.6 repositories { jcenter() maven { url 'https://maven.google.com/' name 'Google' } google() } dependencies { classpath 'com.android.tools.build:gradle:3.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } }
2. Resolve Deprecated Configuration Warnings
The old dependency configurations are no longer supported—replace them with the modern equivalents:
compile→implementation(for dependencies only used internally by your app)testCompile→testImplementationandroidTestCompile→androidTestImplementation
3. Fix Build Tools Version Warning
AGP 3.3.1 requires a minimum Build Tools version of 28.0.3. You have two simple options:
- Either explicitly set
buildToolsVersion "28.0.3" - Or remove the
buildToolsVersionline entirely (AGP will automatically pick the correct version matching yourcompileSdkVersion)
I also recommend updating compileSdkVersion and targetSdkVersion to 28 to align with the Build Tools version—this avoids compatibility gaps.
Modified android-app Module build.gradle
Here's the full updated file with all fixes applied:
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 28 // Updated from 26 // Removed buildToolsVersion - AGP auto-selects the right version defaultConfig { applicationId "fr.curie.jonquille.jonquille_curie" minSdkVersion 18 targetSdkVersion 28 // Updated from 26 versionCode 203000 versionName "2.3.0" multiDexEnabled true testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main.java.srcDirs += 'src/main/kotlin' } dexOptions { javaMaxHeapSize "4g" } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'com.android.support:appcompat-v7:28.0.0' // Updated to match compileSdk 28 implementation 'com.android.support:support-v4:28.0.0' // Updated implementation 'com.android.support.constraint:constraint-layout:1.1.3' // Switched to stable version implementation 'com.android.support:design:28.0.0' // Updated implementation 'com.google.android.gms:play-services-maps:16.1.0' // Compatible with compileSdk 28 implementation 'com.google.android.gms:play-services:16.0.1' // Updated implementation 'uk.co.chrisjenx:calligraphy:2.2.0' implementation 'io.reactivex:rxandroid:1.2.1' implementation 'io.reactivex:rxjava:1.2.4' implementation 'io.reactivex:rxkotlin:0.60.0' implementation 'com.jakewharton.rxbinding:rxbinding-kotlin:1.0.0' implementation 'com.jakewharton.rxbinding:rxbinding-support-v4-kotlin:1.0.0' implementation 'com.jakewharton.rxbinding:rxbinding-appcompat-v7-kotlin:1.0.0' implementation 'com.jakewharton.rxbinding:rxbinding-design-kotlin:1.0.0' implementation 'com.jakewharton.rxbinding:rxbinding-recyclerview-v7-kotlin:1.0.0' implementation 'com.tbruyelle.rxpermissions:rxpermissions:0.9.1@aar' implementation 'pl.charmas.android:android-reactive-location:0.10@aar' implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.sdoward:rxgooglemaps:1.1.1@aar' implementation 'com.github.kittinunf.fuel:fuel:1.3.1' implementation 'com.github.kittinunf.fuel:fuel-android:1.3.1' implementation 'com.github.kittinunf.fuel:fuel-rxjava:1.3.1' implementation 'com.android.support:multidex:1.0.3' // Updated implementation 'com.google.android.gms:play-services-wallet:16.0.1' // Updated implementation 'com.stripe:stripe-android:2.0.2' implementation 'com.facebook.android:facebook-android-sdk:4.+' implementation 'com.twitter.sdk.android:twitter-core:3.1.1' implementation 'com.twitter.sdk.android:tweet-composer:3.1.1' testImplementation 'junit:junit:4.12' } repositories { mavenCentral() maven { url 'https://maven.google.com/' name 'Google' } }
Quick Notes
- I updated support library and Google Play Services versions to match
compileSdkVersion 28—this prevents version mismatch errors. - Switched
constraint-layoutfrom a beta to a stable version for better reliability.
After making these changes, sync your Gradle project and it should build without errors or warnings!
内容的提问来源于stack exchange,提问作者Soukaina Benchekroun




