question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error_prone_core 2.0.6 adds Objects.requireNonNull() to source (which can crash Android)

See original GitHub issue

I’ve been using the error-prone compiler for my Android application. java.util.Objects was only added recently to Android (API 19). The most recent version of error_prone_core (2.0.6) can add Objects.requireNonNull() to the source, which causes the Android app to crash if run on an older device.

I haven’t been able to track down exactly how this happens; I’m not super familiar with error-prone’s internals.

I’ve been using error-prone via the gradle-errorprone-plugin for Android builds. By default it pulls in the latest error_prone_core for use. As a workaround you can force it to use 2.0.5.


As an aside, the stack traces that result are quite mystifying since the source will contain no references to java.util.Objects. For example:

Fatal Exception: java.lang.NoClassDefFoundError: java.util.Objects
       at com.trello.syncadapter.StarredBoardsSync.execute(StarredBoardsSync.java:66)
       at com.trello.syncadapter.StarredBoardsSync.performSync(StarredBoardsSync.java:58)
       at com.trello.syncadapter.TSyncAdapter.onPerformSync(TSyncAdapter.java:49)
       at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:254)

…Where StarredBoardsSync didn’t even import java.util.Objects in the original source.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:17

github_iconTop GitHub Comments

1reaction
kageiitcommented, Feb 3, 2017

This happens even when not using retrolambda. Specifically this line

https://github.com/google/error-prone-javac/blob/a68a002c508b9b862ab4b966c70aad0a1686d328/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java#L126

Will make it so that Objects.requireNonNull() is always used when source and target levels are set to 7. This is not a problem when using oracle’s javac because it does not have this check. This makes it so that when using error prone with any android codeabse, if you do not use retrolambda, the app will always crash on api levels below 19.

cc @cushon Can we get this fixed in error-prone-javac or consider making this an option?

0reactions
cushoncommented, Feb 15, 2017

The fix has been released in 2.0.16.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Objects.requireNonNull error in Android Studio - Stack Overflow
getSupportActionBar() returns null. And since you require it to be non-null, it crashes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found