当我将realm.io库添加到我的Android应用程序并尝试运行应用程序时,我在编译期间收到此错误:
错误:任务':compileDebugJava'执行失败。 > java.lang.ClassCastException:com.sun.tools.javac.code.Symbol $ ClassSymbol无法强制转换为javax.lang.model.element.PackageElement
这是我的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
}
}
当我删除领域依赖项和代码时,应用程序编译正常。我正在运行Android Studio 0.8.14
答案 0 :(得分:3)
问题原来是我的领域模型是嵌套类,而不是顶级类。改变这个解决了这个问题。
答案 1 :(得分:2)
您的模型中的字段没有正确的getter和setter。