Android Studio 4.2 throws a null pointer exception on incremental builds

835 views Asked by At

UPDATE #4: I have updated to Android Studio 4.2.1 and Realm 10.5.0 and the problem still occurs. Same line numbers on the exception as below.

UPDATE #3: Looking at the full stack trace (which you can see here), it appears this is an issue with Realm. I am using the 10.4.0 annotations processor, perhaps it is not yet fully compatible with AS 4.2?

Caused by: kotlin.KotlinNullPointerException
        at io.realm.processor.ModuleMetaData.getClassListFromModule(ModuleMetaData.kt:337)
        at io.realm.processor.ModuleMetaData.validateNamingPolicies(ModuleMetaData.kt:170)
        at io.realm.processor.ModuleMetaData.preProcess(ModuleMetaData.kt:113)
        at io.realm.processor.RealmProcessor.preProcessModules(RealmProcessor.kt:241)
        at io.realm.processor.RealmProcessor.process(RealmProcessor.kt:178)

The other odd thing - is now I realize that if I run an incremental build that fails, then run it again without making any code changes, it succeeds.

UPDATE #2:

Well that "fix" didn't actually fix anything. Just seemed to make it possible to get through one incremental build without an error, but now back to the same problem.

UPDATE:

I decided to completely remove my AS installation, then downloaded 4.2 and reinstalled. This came with its own set of issues (Sdk wasn't installed initially and when I tried to use the Sdk manager to do so, I got errors about it being corrupted), but I resolved those.

The error below occurred again, maddingly enough, but this time it had an extra line about my Application class using a deprecated API. Running lint showed no issues, but the suggestion was to include a compiler option to include lint while running the build, which I did. This gave me a new error, and when I then removed the -X command, all of a sudden I am not seeing this error anymore...

So I am not sure what "fixed" it, other than jogging the compile step with my argument then removing it.

I just updated to Android Studio 4.2 from 4.1.3, and also updated Gradle (6.7.1), Gradle plug-in(4.2.0), etc. Everything shows up to date.

I can do a full rebuild with no errors. However, if I make a single innocuous change and attempt an incremental build, I always get an error like this:

enter image description here

Doing a full build then works correctly.

I have tried:

  1. Invalidate cache restart
  2. Exit AS, delete the .gradle directory and restart, perform a full rebuild

Nothing seems to help.

Obviously some problem with the upgrade path, but I don't know how to fix! Help!

0

There are 0 answers