After updating to Android Studio 3.0 , Let's fix some Gradle issues

Hi guys yesterday I received Android Studio 3.0 update and I immediately decided to update my Android Studio from 2.3.1 to 3.0.

And I faced some issues and than fixed those after going through different stack overflow posts. so I decided to mention all issues which You also can face when You will updated to Android Studio 3.0.

 

 

Android Studio 3.0 Update
Lets update and Restart (Android studio update available)

After this You will be prompted to update Gradle plugin and gradle version for Android. Lets updated Gradle also.

Now Your gradle wrapper file will have this version of gradle.

gradle-4.1-all.zip

Now gradle sync will fail and you will be prompted to remove buildToolsVersion.

You need to use new dependency configurations in Android Studio 3.0.

Change compile configuration to implementation and api. compile configuration is deprected now.

implementation configuration means that the dependency is only available to other modules at run time. this will drastically improve gradle build time.

you also have to exclude application dependencies from test dependecnies, because now test dependencies inherit implementation when gradle resolves application configurations.

Now you can face this issue

Android studio 3.0: Unable to resolve dependency for ‘:app@dexOptions/compileClasspath’: Could not resolve project :projectName

You will face this issue because buildTypes in app build.gradle file should match with module build.gradle file.

Lets resolve this issue.

This was my build types block in app gralde file

buildTypes {
    staging {
        buildConfigField 'String', 'HOST', '"http://compute.amazonaws.com/"'
        buildConfigField 'String', 'REGION_CODE', '"1"'
        debuggable true
        signingConfig signingConfigs.debug
    }
    QA {
        buildConfigField 'String', 'HOST', '"com.amazo/"'
        buildConfigField 'String', 'REGION_CODE', '"92"'
        debuggable true
        signingConfig signingConfigs.debug
    }
    notificationTest {
        buildConfigField 'String', 'HOST', '"http://a6a"'
        buildConfigField 'String', 'REGION_CODE', '"92"'
        debuggable true
        signingConfig signingConfigs.debug
    }
}

and this was my project dependencies

compile project(':slideDateTimePicker')
compile project(':scatter')

I opened scatter build.gradle and slideDateTimePicker build.gradle files and replaced android block with this one.

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    QA {}
    notificationTest{}
    releaseApp {}
    releaseSdk {}
    staging{}
}

Now You can face this issue (most probably) 🙂

Execution failed for task ‘:app:compileRetrolambdaDebug’

Lets resolve this issue now

Add this in app gradle build file before android block (on top)

//noinspection GradleCompatible
    apply plugin: 'com.android.application'
    apply plugin: 'me.tatarka.retrolambda'
 tasks.whenTaskAdded { task ->
 if (task.name.startsWith("lint")) {
    task.enabled = false
  }
 }

retrolambda {
jvmArgs '-noverify'
}

and I also changed my class path version from 3.4.0 to 3.2.5 and my issue resolved.

Also no need to add retroLambdaConfig inside dependencies block.

Now I am running my older project successfully in Android Studio 3.0

Happy Coding 🙂 … share this with other developers. Thank you for reading.

Tags : Android Studio 3.0 Update available, migrating to Android Studio 3.0, Updating 3.0, Errors, Android Studio latest stable version 3.0 update, automatically update Android Studio 3.0, stable release, Configure IDE, Settings, Setup Android Studio 3.0 , resolve dependencies, Update existing project in Android Studio 3.0 , retrolambda, tatarka, config.

Contact Us