Home » Android » android – 3rd-party Gradle plug-ins may be the cause

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

Posted by: admin March 11, 2020 Leave a comment

Questions:

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'
        }
    }
}
How to&Answers:

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.

Answer:

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.

Answer:

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

Answer:

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

Answer:

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

Answer:

What actually helped for me is adding this

kapt {
     generateStubs = true
 }

into build.gradle

Answer:

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:
Kotlin 1.2.50 asks for baseFeatureInfoDir

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

Answer:

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

It worked for me.

Answer:

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.

Answer:

  1. remove apply plugin: 'kotlin-kapt'
  2. add mavenCentral() in build.gradle like:

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

  3. Sync and Clean project

Answer:

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.

Answer:

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

Answer:

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).

Answer:

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.

Answer:

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

Answer:

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

Answer:

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.