我尝试在Android项目中使用AndroidAnnotation。 事实上,我有一个包含所有业务逻辑的库项目,我想在这个项目中使用AndroidAnnotations,它的build.gradle:
apply plugin: 'com.android.library'
apply plugin: 'android-apt'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':android-sliding-layer-lib')
compile 'net.simonvt.menudrawer:menudrawer:3.0.6@aar'
compile project(':pull-to-refresh')
compile project(':view-pager-indicator')
compile project(':month-year-date-picker')
compile project(':pull-to-refresh-gallery')
compile project(':facebook-sdk')
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.androidmapsextensions:android-maps-extensions:2.1.+'
compile 'com.android.support:support-v4:20.0.+'
apt "org.androidannotations:androidannotations:3.1"
compile "org.androidannotations:androidannotations-api:3.1"
}
android {
compileSdkVersion 19
buildToolsVersion '20'
lintOptions {
abortOnError false
}
defaultConfig {
versionCode 1
versionName "1.0"
minSdkVersion 10
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
代的工作,例如,我的类“ReadMoreFindContactsFragment_”是正确的generatad,我可以在Android工作室看到它。
我在根路径中也有一个build.gradle文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4+'
}
}
allprojects {
repositories {
jcenter()
}
}
我可以在我的手机上启动应用程序并且AndroidAnnotations片段可以正常工作但是当我在AndroidStudio上使用“重建项目”时,我有这样的消息:
“错误:/home/rpotier/devhome/workspace/mobile-android/shared-project/src/com/shared/ui/phone/ReadMoreFindContactsActivity.java:6:导入com.shared.ui.fragment.ReadMoreFindContactsFragment_无法解决“
你能帮帮我吗?
谢谢!