When I add the realm.io library to my Android app and try to run the app, I get this error during compilation:
Error:Execution failed for task ':compileDebugJava'. > java.lang.ClassCastException: com.sun.tools.javac.code.Symbol$ClassSymbol cannot be cast to javax.lang.model.element.PackageElement
This is my build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
classpath 'com.jakewharton.hugo:hugo-plugin:1.1.0'
}
}
apply plugin: 'android'
apply plugin: 'crashlytics'
apply plugin: 'com.android.application'
apply plugin: 'hugo'
repositories {
mavenCentral()
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion '19.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
dexOptions {
jumboMode = true
}
/*sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'src-gen/main/java']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}*/
}
dependencies
{
compile project(':libraries:AndroidBootstrap')
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.crashlytics.android:crashlytics:1.+'
compile files('libs/naga-3_0.jar')
compile files('libs/branch-1.1.1.jar')
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile 'com.google.android.gms:play-services:5.0.89'
compile 'de.greenrobot:eventbus:2.2.1'
compile 'com.github.kevinsawicki:http-request:5.6'
compile 'com.maxmind.geoip2:geoip2:0.9.0'
compile 'com.squareup.retrofit:retrofit:1.4.1'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'de.hdodenhof:circleimageview:1.2.0'
compile 'com.helpshift:android-aar:3.6.0'
compile 'io.realm:realm-android:0.73.1'
compile project(':facebook')
repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } }
compile('com.segment.analytics.android:core:2.4.1@aar')
{
transitive = true
}
}
When I remove the realm dependency and code, the app compiles fine. I'm running Android Studio 0.8.14
The problem turned out to be that my realm models were nested classes, instead of top-level classes. Changing that fixed this problem.
You don't have the proper getters and setters for the fields in your model.
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