I'm having trouble to use errorprone and nullaway in android studio. Looks like nullaway depends on errorprone. These are static analysis tools to avoid NPE. The documentation on how to use nullaway in android on the nullaway github page is very poor and not clear.
I've tried going to plugins area in android studio and i installed the errorprone plugin, then switched the java compiler to javac with error prone like this image:
Then i put the following code in android studio thinking that the compiler would catch the potential null:
private void processLog() {
log(null);
}
static void log(Object x) {
System.out.println(x.toString());
}
static void foo() {
log(null);
}
instead nothing happened. Here is what i put in gradle files;
Bottom level build.gradle:
dependencies {
annotationProcessor "com.uber.nullaway:nullaway:0.1.6"
}
Top level build.gradle file:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.1'
classpath 'io.fabric.tools:gradle:1.24.+'
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.11"
classpath "net.ltgt.gradle:gradle-apt-plugin:0.11"
}
}
plugins {
id "net.ltgt.errorprone" version "0.0.13"
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
maven { url "http://dl.bintray.com/pt-midtrans/maven" }
maven { url "https://jitpack.io" }
maven { url "https://plugins.gradle.org/m2/" }
}
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "$supportlib_version"
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}