3rd-party Gradle plug-ins may be the cause

AndroidAndroid StudioAndroid Studio-3.1

Android Problem Overview


After updating to Android Studio 3.1 I got this error message:

The project works fine and this is mostly just a warning, so my question is what's the meaning of the warning and how can I get rid of it?

The relevant parts from gradle files:

This is my project's build.gradle

buildscript {
    ext {
        kotlin_version = '1.2.31'
        anko_version = '0.10.4'
        room_version = '1.0.0'
        support_version = '27.1.0'
        firebase_version = '12.0.0'
        gms_version = '12.0.0'
    }

    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
        maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
    }
}

And this is my app's build.gradle file:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 27
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

Android Solutions


Solution 1 - Android

To solve the issue, remove Instant App Provision from the "Run Configurations" and leave only the Gradle-Aware Make.

Run -> Edit Configurations..

My Run/Debug configurations after successful build

I have AndroidStudio 3.1, Gradle Plugin 3.1.0 and Kotlin library version 1.2.30.

Solution 2 - Android

I restarted Android Studio and the problem disappeared.

Click File -> Invalidate Caches/Restart

Every time I change the gradle file, I must restart Android Studio to or the problem returns.

You can also try this:

  1. Re-ordered repositories to:

    mavenCentral()
    maven { url 'https://jitpack.io' }
    google()
    jcenter()
    
  2. Clearing this folder: user's ~/.gradle/caches and deleting app build folder manually, then clean and rebuild.

Solution 3 - Android

What fixed the issue for me:

  • Change gradle plugin version to 3.1.0

  • Change Kotlin version to 1.2.30

  • Then Android studio changed gradle wrapper to version 4.4

  • Then Android studio was saying that the build tools version used was 27.0.3 and that I should change it to 27.0.3 so I also changed the target SDK to 27

  • I added this to my gradle.build:

     kapt {
          generateStubs = true
      }
    

I hope it helps

Solution 4 - Android

Here are some steps that I've followed. In my case it's fixed the issue!

Platform modules targeting Android The update of the experimental multiplatform projects feature introduces support for Android platform modules. These modules should apply the corresponding plugin in the Gradle build script and can use the shared code from a common module:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-platform-android'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
// ...
// ...

Kapt diagnostic locations As of now, kapt, the Kotlin annotation processing tool, can offer links to locations in the original Kotlin code rather than generated Java stubs as it reports errors encountered during annotation processing. You can enable this feature by adding these lines to the Gradle build script (build.gradle):

kapt {
    mapDiagnosticLocations = true
}

Add this:

allprojects {
        repositories {
            jcenter()
            google()
        }
    }

Don't forget the next:

// Architecture Component - Room

     implementation "android.arch.persistence.room:runtime:1.1.0-beta1"
        kapt "android.arch.persistence.room:compiler:1.1.0-beta1"
    
      // Lifecyles, LiveData and ViewModel
    kapt 'com.android.databinding:compiler:3.1.0'
    

 // ViewModel and LiveData
    implementation "android.arch.lifecycle:extensions:1.1.1"
   
// alternatively, just ViewModel
    implementation "android.arch.lifecycle:viewmodel:1.1.1"
       
 // alternatively, just LiveData
     implementation "android.arch.lifecycle:livedata:1.1.1"
       kapt "android.arch.lifecycle:compiler:1.1.1"
    
 // Room (use 1.1.0-beta1 for latest beta)
    implementation "android.arch.persistence.room:runtime:1.0.0"
      kapt "android.arch.persistence.room:compiler:1.0.0"
    
   
// Paging
    implementation "android.arch.paging:runtime:1.0.0-alpha7"
    
        // Test helpers for LiveData
    testImplementation "android.arch.core:core-testing:1.1.1"
    
        // Test helpers for Room
 testImplementation "android.arch.persistence.room:testing:1.0.0"
  1. Clean your project

  2. Build and That's it!

Add all of this, Clean your project, build and That's it! :) Let me know if this works! (If it is not working for you, I will help you with another solution)

More Info: Android Site :) Let me know if it works! (If it does not work, I will try to help you finding a better way)

If you give a downVote explain why

Solution 5 - Android

at android studio v3.1.2 , happen Error:

Folder D:\AndroidProjects\app\build\generated\source\kaptKotlin\debug
Folder D:\AndroidProjects\app\build\generated\source\kaptKotlin\release
3rd-party Gradle plug-ins may be the cause

because dataBinding use apply plugin: 'kotlin-kapt' so add

kapt {
    generateStubs = true
}


  1. Change gradle plugin version to 3.1.2
  2. Change Kotlin version to 1.2.30
  3. Then Android studio changed gradle wrapper to version 4.4
  4. Then Android studio was saying that the build tools version used was 27.1.1 and that I should change it to 27.1.1 so I also changed the target SDK to 27

Solution 6 - Android

What actually helped for me is adding this

kapt {
     generateStubs = true
}

into build.gradle

Solution 7 - Android

In my case none of the above solutions solved my problem, I was using 1.2.50 Kotlin version without any mention to Instant Run, and the build wasn't generating the Dagger classes, so I find out this question that solved my issue, apparently, in my situation it's an issue related to the new Kotlin version, so I downgraded to version 1.2.41 and worked fine. By the way, I just tracked to that point because I used the Toggle View on Build screen.

1:Select the Toggle View and build your project

Toggle View

2:You're going to be able to see exactly what happened

Error

Stackoverflow question: https://stackoverflow.com/q/50869056/2200209

Issue tracker: https://issuetracker.google.com/issues/110198434

Solution 8 - Android

Try removing Instant run from settings and gradle will good to go.

It worked for me.

Solution 9 - Android

Here are some steps that i have followed and it's fixed the issue in my case.

  1. First of all install kotlin plugin version to '1.2.31' and update it in build.gradle file like below.

> dependencies { > classpath 'com.android.tools.build:gradle:3.1.0' > classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$1.2.31" > }

  1. Clean Project.

  2. Finally Rebuild the project.

Solution 10 - Android

  1. remove apply plugin: 'kotlin-kapt'

  2. add mavenCentral() in build.gradle like:

    allprojects { repositories { mavenCentral() google() jcenter() } }

  3. Sync and Clean project

Solution 11 - Android

Here is the some approach how I fix this issue for my case:

> First of all update your android gradle plugin version from project build gradle file and then update your gradle version from gradle properties. > > Finally update your kotlin version(Mandatory) to kotlin_version = '1.2.30' or later from project build gradle file.

Now try to clean your project and build. Issue should be resolved. Each time after build if you build again then probably issue will occur again so, just clean your project again and then build.

Solution 12 - Android

This happens because the Kapt annotation processor uses this directory to store Kotlin generated files. Android currently does not recognize the path by default.

See Further Details

Solution 13 - Android

Adding another answer for those who could not remove Instant App Provision, because it keeps reappearing.

Build the project manually: ./gradlew assembleDebug

It is a hotfix, but it will work (because the issue is probably related to Android Studio).

Solution 14 - Android

I had this issue when using Realm with kotlin in android studio.
To solve follow these steps :

  1. After adding Realm to project build.gradle, Make sure your app build.gradle file is like this:

     apply plugin: 'com.android.application'  
     apply plugin: 'kotlin-android'  
     apply plugin: 'kotlin-android-extensions'  
     apply plugin: 'kotlin-kapt'  
     apply plugin: 'realm-android'  
     .  
     .  
     .  
     androidExtensions {  
     experimental = true
     }
    
  2. Use kapt instead of annotationProcessor in your app build.gradle dependencies.

  3. Go to Run -> Edit Configurations.. and remove Instant App Provision option.

  4. Run this command in Android studio's terminal :

     gradlew assembleDebug  
    
  5. It's OK !

Note: If you see "3rd-party Gradle plug-ins may be the cause" message again, Do step 3 & 4 again.

Solution 15 - Android

> Configuration on demand with Gradle 4.6 and above: If you're using > Android Gradle Plugin 3.0.x or 3.1.x with Gradle 4.6 and above, you > should disable configuration on demand to avoid some unpredictable > build errors. (If you are using Android Gradle Plugin 3.2.0 or higher, > you do not need to take any action to disable configuration on > demand.) > > Disable configuration on demand in your gradle.properties file as > shown below: > > org.gradle.configureondemand=false To disable configuration on demand > in the Android Studio settings, choose File > Settings (Android Studio > > Preferences on Mac), select the Compiler category in the left pane, and clear the Configure on demand checkbox. > > In Android Studio 3.2 Beta 1 and higher, the options for enabling > configuration on demand have been removed. Please read known issues section from below link. enter link description here

Solution 16 - Android

Actually,I was also facing the same error. What i did is updating my kotlin version to the latest. This may resolve Your problem.

Solution 17 - Android

Well, I found it is because of apply plugin: 'kotlin-kapt',if you delete this line in build.gradle(app), then you will build successfully...

Have no idea why this plugin results in these warnings.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionhumazedView Question on Stackoverflow
Solution 1 - AndroidAngel KjoseskiView Answer on Stackoverflow
Solution 2 - AndroidSpkingRView Answer on Stackoverflow
Solution 3 - AndroidJúlia GarrigósView Answer on Stackoverflow
Solution 4 - AndroidCristoferView Answer on Stackoverflow
Solution 5 - Android任非凡View Answer on Stackoverflow
Solution 6 - AndroidAndrey AleevView Answer on Stackoverflow
Solution 7 - AndroidPedro OkawaView Answer on Stackoverflow
Solution 8 - AndroidMunish ThakurView Answer on Stackoverflow
Solution 9 - AndroidManish KarenaView Answer on Stackoverflow
Solution 10 - AndroidDan AlboteanuView Answer on Stackoverflow
Solution 11 - Android0xAliHnView Answer on Stackoverflow
Solution 12 - AndroidmvbrenesView Answer on Stackoverflow
Solution 13 - AndroidmrekView Answer on Stackoverflow
Solution 14 - AndroidMehdi I.View Answer on Stackoverflow
Solution 15 - AndroidAndroid DeveloperView Answer on Stackoverflow
Solution 16 - AndroidMaulik TogadiyaView Answer on Stackoverflow
Solution 17 - AndroidNewamberView Answer on Stackoverflow