133

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'
        }
    }
}
xarlymg89
  • 2,552
  • 2
  • 27
  • 41
humazed
  • 74,687
  • 32
  • 99
  • 138

17 Answers17

143

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.

Ege Kuzubasioglu
  • 5,991
  • 12
  • 49
  • 85
Angel Kjos
  • 1,951
  • 1
  • 12
  • 12
  • 5
    this actually works but any idea why it was happening and how you arrived at this solution. – humazed Mar 29 '18 at 16:55
  • 59
    and for some reason after deleting `Instant App Provisions` it always returning to its place. – humazed Mar 29 '18 at 16:59
  • Worked for me, but I'd also like to know what the issue is. Has anyone filed an issue with Google to complain about the obscure warning message? – AutonomousApps Apr 01 '18 at 22:33
  • 1
    I created an issue on the bug tracker to improve the warning message: https://issuetracker.google.com/issues/77356844 – AutonomousApps Apr 01 '18 at 22:39
  • 2
    @PeterSamokhin can you confirm that the change is applied? I too had this issue, and `Instant App Provisions` keeps on popping up whenever a new AS window is created, despite applying the change and updating all default run configs – Allan W Apr 09 '18 at 06:11
  • @AllanW cleaned local gradle caches (`~/.gradle`), all caches of project, all IDE files (`/.idea/`, `*.iml`), deleted `Instant App Provisions`, changed `kotlin-stdlib-jre7` to `kotlin-stdlib`, tried to `Invalidate & restart`. And still no sense – Peter Samokhin Apr 09 '18 at 06:42
  • @PeterSamokhin try invalidating cache and restarting (under files), and if that doesn't work, try reimporting the project again rather than opening the recent project. – Allan W Apr 09 '18 at 06:44
  • Another test I did was to run a build on a ci like Travis. You can also try running the gradle command via command line to ensure that the issue is related to Android studio – Allan W Apr 09 '18 at 06:45
  • @AllanW tried to build & run with gradle, and all were ok. Tried to reimport (cloned from git), this also doesn't help. – Peter Samokhin Apr 09 '18 at 06:58
  • 3
    Does this disable instant run? – Caleb_Allen May 10 '18 at 17:25
  • 7
    @Caleb_Allen no, but nobody uses instant run anyway. This is for 'instant apps', not instant run – Tim Jun 06 '18 at 08:01
  • 4
    For anyone where this keeps on coming back (like @humazed), I found a fix: First go to `Run > Edit Configurations` again. Then go to `Edit Defaults` by clicking the button with the wrench icon at the top. Select `Android App` and leave only `Gradle-aware Make` like before. Hit apply. – b_yng Jul 04 '18 at 01:04
  • 2
    If you're still getting this issue, it seems to have been fixed starting from AS 3.2 beta1: https://androidstudio.googleblog.com/2018/06/android-studio-32-beta-1-available.html (see "Android Studio gave superfluous warnings about folders generated by kapt.") – spuente Jul 25 '18 at 00:51
  • Android programming is becoming more and more ludicrous by the day. – Iman Akbari Aug 28 '18 at 13:45
17

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.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
SpkingR
  • 965
  • 7
  • 14
7

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

5

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

Cristofer
  • 1,046
  • 13
  • 21
5

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
任非凡
  • 61
  • 2
5

What actually helped for me is adding this

kapt {
     generateStubs = true
}

into build.gradle

Andrey Aleev
  • 192
  • 1
  • 1
  • 13
2

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

It worked for me.

Munish Thakur
  • 926
  • 1
  • 8
  • 25
2

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.

Manish Karena
  • 724
  • 6
  • 29
2

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

Pedro Okawa
  • 589
  • 1
  • 6
  • 10
1
  1. remove apply plugin: 'kotlin-kapt'
  2. add mavenCentral() in build.gradle like:

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

  3. Sync and Clean project
Dan Alboteanu
  • 9,404
  • 1
  • 52
  • 40
0

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.

Community
  • 1
  • 1
0xAliHn
  • 18,390
  • 23
  • 91
  • 111
0

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

mvbrenes
  • 517
  • 5
  • 9
0

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

mrek
  • 1,655
  • 1
  • 21
  • 34
0

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.

Mehdi I.
  • 11
  • 3
0

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

Android Developer
  • 559
  • 1
  • 5
  • 17
0

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

Maulik Togadiya
  • 594
  • 5
  • 10
-4

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.

Newamber
  • 1
  • 2