所以我想嘗試新的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的提升,我還沒有升級, –