Search code examples
androidandroid-studioandroid-buildinstant-run

Why is Android Instant Run recompiling almost every time?


I'm giving Android Instant Run a test run. For testing, I just added the following line to the onResume() of my Activity:

Toast.makeText(this, "test123", Toast.LENGTH_SHORT).show();

Now, when I change the text of the toast and rebuild, it will tell me

"Instant Run detected that a resource referenced from the AndroidManifest.xml file has changed"

Can anyone explain what's going on here? I didn't change any resource, just the string literal in the Activity java file. ( I'm aware that I should use string resources in Android btw).


Solution

  • Seems like the issue was that my build.gradle modifies the Android Manifest:

    debug {
        ...
        def theVersionNameSuffix = "-debug-" + getCurrentDateTimeString();
        versionNameSuffix theVersionNameSuffix
        ...
    }
    

    Since the suffix is different in every build, that means that the versionName changes between builds which changes the AndroidManifest.

    I have removed the versionNameSuffix entry and now it seems to work.