Error: when replacing compilation with implementation in gradle (dependency)

I am upgrading my android studio from 3.0.1 to 3.1.0

But after update, when I build my project, it shows warning 2 :

1. Replace compilation with implementation (and compilation support will end at the end of 2018)

2. Replace testCompile with testImplementaion (and support for testCompile will end at the end of 2018)

So finally make these changes, but after that it shows some error :

error

build.gradle (module: app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "biz.coolpage.aashish.app"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 4
        versionName "1.2.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:design:27.1.0'
    implementation project(':library')
}

      

build.gradle (Project: Abc)

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven {
            url "https://maven.google.com"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

      

+2


source to share


1 answer


Try using gradle api

instead implementation

inside your library. If you have submodules and want to expose libraries in a transitive manner, you should use api

. implementation

will import the library for a specific project. Also you may need to add

implementation (project(":library")) {
    transitive = true
}

      

For example, in your file of build.gradle

your library module use:

api 'com.android.support:appcompat-v7:27.1.0' 

      



instead

implementation 'com.android.support:appcompat-v7:27.1.0'

      

If nothing works you can try invalidating the cache and reloading

+1


source







All Articles