所以我想尝试新的Android Studio和进口我的Eclipse项目(我产生了构建gradle这个文件)。工作很好。Android的工作室:使用AndroidAnnotations
这似乎并没有工作,唯一的图书馆是AndroidAnnotations。 我选择了文件>设置>编译器>注解处理下的androidannotations-2.7.jar文件。
作为生产源目录我选择了“gen”。 但是生成的文件如MainActivity_不会生成。我错了什么?
所以我想尝试新的Android Studio和进口我的Eclipse项目(我产生了构建gradle这个文件)。工作很好。Android的工作室:使用AndroidAnnotations
这似乎并没有工作,唯一的图书馆是AndroidAnnotations。 我选择了文件>设置>编译器>注解处理下的androidannotations-2.7.jar文件。
作为生产源目录我选择了“gen”。 但是生成的文件如MainActivity_不会生成。我错了什么?
我有同样的问题,然后用配置的IntelliJ AA的指示,现在它就像一个魅力一样。
AA的IntelliJ配置页面将指向你这个帖子...
...上面的帖子详细地向您的IntelliJ建立各种库,滚动向底部为AA。
我不得不这样做,我没有在Eclipse做的是去首选项>编译器>注释处理器和我的处理器路径设置为像主要的事情...
[PATH TO AA JARS] /androidannotations-2.7.jar:[PATH TO AA JARS] /androidannotations-api-2.7.jar:[PATH TO AA JARS] /codemodel-2.4.1.jar
随着Android的Studio是基于的IntelliJ你试图遵循AndroidAnnotation的维基configuration guideline?
如果您使用gradle这个你应该检查this page这也解释了如何配置AndroidAnnotation的插件:
buildscript {
repositories {
mavenCentral()
}
def gradleAndroidAnnotationsPluginVersion = '0.3.0'
dependencies {
classpath "net.ealden.gradle.plugins:gradle-androidannotations-plugin:$gradleAndroidAnnotationsPluginVersion"
}
}
apply plugin: 'androidannotations'
apply plugin: 'idea'
androidAnnotationsVersion = '2.2'
我没有尝试这种新的IDE呢。我会尽快检查。
我做了他们提供的教程但我无法让事情奏效。我将尝试稍后链接的插件。 –
首先,这个插件是一个https://github.com/jvoegele/gradle-android-plugin封装,与Android Studio无关。 – robotoaster
如果没有问题,编译,只是在IDE中看到生成的类后做,那么你需要检查,如果目标/生成来源/注释被选中作为源文件夹。
这将是文件>项目结构>模块>来源选项卡,然后查找该文件夹并将其标记为来源。该文件夹将变成蓝色,并将在“源文件夹”列表中列出。
似乎有一种使Android Studio与AndroidAnnotations合作的方法
如果您尝试使用Android Studio的一个项目,运行Android注释,你可能会遇到一个神秘的编译器的问题:
类型不正确的发现注释元素的公共抽象INT com.googlecode.androidannotations数据。 annotations.EActivity.value()(实测值int类型的数据)
问题是R类中找不到。Android Studio不会将R.java默认放置在gen目录中,如eclipse。解决方案是进入项目设置 - > Facets - >选择你的项目的Android方面 - >编译器选项卡,并从“在make之前运行process-resources Maven任务”中将“R.java和Manifest.java文件”更改为“由IDE生成”。
这对我来说是什么在起作用:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
configurations {
apt
}
repositories {
mavenRepo url: 'https://oss.sonatype.org/content/repositories/snapshots/'
}
ext.androidAnnotationsVersion = '3.0-SNAPSHOT';
dependencies {
compile 'com.android.support:support-v4:18.0.+'
apt "org.androidannotations:androidannotations:$ext.androidAnnotationsVersion"
compile "org.androidannotations:androidannotations-api:$ext.androidAnnotationsVersion"
}
android {
compileSdkVersion 18
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 18
}
}
android.applicationVariants.all { variant ->
ext.aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}")
ext.aptOutput.mkdirs()
variant.javaCompile.options.compilerArgs += [
'-processorpath', configurations.apt.asPath,
'-AandroidManifestFile=' + variant.processResources.manifestFile,
'-s', ext.aptOutput
]
}
之后,我需要标注build/sources/apt-generated/debug
由右Android Studio中源单击它并选择Mark Directory as
>Source Root
Mark目录已被删除(在任何情况下它都不存在于0.3.4中)。 – 2013-11-12 01:46:16
此选项似乎已在Android Studio 1.2中删除。 –
感谢Ben的提升,我还没有升级, –