I'm writing an Android library project in which I have a dependency on Realm. For some reason when I add Realm as a dependency in my Gradle files, I get a build error. Specifically:
Error:cannot access ParametersAreNonnullByDefault
class file for javax.annotation.ParametersAreNonnullByDefault not found
I'm just following the Get Started on the Realm website.
My project level build.gradle looks like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'io.realm:realm-gradle-plugin:1.2.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My application level gradle.build looks like this:
apply plugin: 'com.android.library'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
minSdkVersion 17
targetSdkVersion 24
versionCode 9
versionName "1.2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-annotations:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.google.code.gson:gson:2.4'
//Puree
compile 'com.cookpad.puree:puree:4.1.1'
//Square
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup:tape:1.2.3'
}
I have no idea what is going wrong. At first I thought it might be some conflict between the other dependencies, but I created a new project adding the same dependencies one by one and I had no compilation problems.
You can try adding the following dependency:
// https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305
compile 'com.google.code.findbugs:jsr305:1.3.9' //try also provided
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With