3

Since Gradle 2.1, incremental compilation of Java source is now supported check this

I used below snip of code to enable it

afterEvaluate {

    android.applicationVariants.each { variant ->
        variant.javaCompile.options.incremental = true
    }
}

But I am getting below warning message,

:App:compileDebugJava - is not incremental. Unable to infer the source directories.

Please suggest me what should I do to get rid of it

Amit Yadav
  • 32,664
  • 6
  • 42
  • 57
  • it is possible that you are trying to compile with java 8 and sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8. I had amazing problem with this bug and I figured out that you should rather stick with 1_7 – vanomart Feb 11 '16 at 18:59

2 Answers2

2

Yes, there is an issue for Android Build Plugin, read here:

We use custom sourceset so this is unlikely to be fixed until we can stop using them.

http://code.google.com/p/android/issues/detail?id=82411 and mentioned here

https://discuss.gradle.org/t/faster-incremental-builds/552/10

When it is fixed, use this for Android, add this in allProjects:

allProjects {
    tasks.withType(JavaCompile) {
        configure(options) {
            incremental = true
        }
    }
}

If you see this, you must build your project first:

compileDebugJava - is not incremental (e.g. outputs have changed, no previous execution, etc.).

If you see this, the wrong sourceSets are being used according to the isse(see link):

compileDebugJava - is not incremental. Unable to infer the source directories.

From their example for Java projects:

apply plugin: 'java'
compileJava {
    //enable compilation in a separate daemon process
    options.fork = true

    //enable incremental compilation
    options.incremental = true
}

Source: http://gradle.org/docs/current/dsl/org.gradle.api.tasks.compile.JavaCompile.html

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
  • Using `allProjects` means that you are applying the `incremental` to all of your projects. Currently, `incremental` builds do not seem to be support in `Android`. – Jared Burrows Apr 19 '15 at 15:47
  • @AmitYadav I know. Please read the links I have provided for you. That is the problem with the Android plugin as I have explained above. – Jared Burrows Apr 19 '15 at 15:54
0

I had such issue with react-native addon packages that I have used. I ran react-native link and it seems to have solved the issue.

Omar M.
  • 331
  • 2
  • 6