Thursday, May 31, 2018

Android Studio 3.1.3: fix warning compile, androidTestCompile and testCompile

Fix Warning:
  1. Configuration 'compile' is obsolete and has been replaced with 'implementation'
  2. Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation'
  3. Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation'
My Android studio:
  • Android Studio 3.1.3
  • buildToolsVersion "28.0.0"
  • Compile Target SDK 28 / min SDK 17
Open Project -> Gradle Scripts -> build-gradle (Module: app)
  1. Change 'compile' to 'implementation'
  2. Change 'androidTestCompile' to 'androidTestImplementation'
  3. Change 'testCompile' to 'testImplementation'
For exmaple my previous
android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 27
...
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'org.jsoup:jsoup:+'
    compile 'com.google.android.gms:play-services-ads:11.2.2'

}
After update
android {
    compileSdkVersion 28
    buildToolsVersion "28.0.0"
    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 28
...
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:appcompat-v7:27.+'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
You may need to change "Gradle Scripts" -> "build.gradle (Project:[your_project_name])"
buildscript {
    repositories {
        jcenter()
        google() 
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

No comments:

Post a Comment