我正在尝试在Android Studio中使用AndroidAnnotations创建项目.当我构建并运行项目时,一切似乎编译得很好,但我只得到应用程序的空白活动.此外,AndroidAnnotations似乎没有生成任何内容.
我已经添加了androidannotations-api-2.7.1.jar作为我的项目的依赖项,并启用了处理器路径的注释处理路径,该路径androidannotations-2.7.1.jar位于一个单独的文件夹中androidannotations-api-2.7.1.jar.我检查了存储生成的相对于模块内容根的源,并尝试了许多不同的源目录 - 从generated,到gen/aa,到(当前)build/source/aa匹配在Android Studio中创建生成文件的位置.没有任何效果.我已将清单中的活动名称更改为Activity_,并将配置设置为在项目运行时启动它.
我唯一的其他依赖项是android-support-v4和ActionBarSherlock.我试过这两个禁用,没有结果.我最初计划将Roboguice与AndroidAnnotations结合使用,但暂时禁用它以尝试专注于此问题.
我也在使用或试图使用Gradle.这是我目前的build.gradle:
buildscript {
  repositories {
    maven { url 'http://repo1.maven.org/maven2' }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:0.4'
  }
}
apply plugin: 'android'
dependencies {
  compile files('libs/android-support-v4.jar')
  compile files('libs/actionbarsherlock-4.3.1.jar')
  compile files('libs/androidannotations-api-2.7.1.jar')
}
android {
  compileSdkVersion 17
  buildToolsVersion "17.0.0"
  defaultConfig {
    minSdkVersion 7
    targetSdkVersion 17
  }
}
Run Code Online (Sandbox Code Playgroud)
但是,我还没有弄清楚Gradle是如何工作的,所以我大多只是手动添加依赖项,就像普通项目一样,然后将编译行放在Gradle中,这样项目就可以正常编译.我知道这可能不是使用它的正确方法.
我的活动及其布局是相当标准的,我只是从官方指南中复制它们以开始使用AndroidAnnotations.
更新:所以我回到Maven用它来测试构建,我注意到一些奇怪的东西.似乎即使我在Maven中设置了它,也没有生成任何东西.但是,使用Maven构建,我可以在不更改清单中的活动名称的情况下运行项目Activity_,项目将编译并正确运行.这是非常奇怪的,似乎它可以进一步混淆问题,或者如果它也表明了Gradle的某些东西,则可以简化它.
我正在Android Annotations和我合作,今天我做了新的更新Android Studio 1.0.
当我构建项目时它给了我这个错误:
Error:(40, 0) Could not find property 'processResources' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated@54335f5.
Run Code Online (Sandbox Code Playgroud)
这是我的build.gradle文件my project:
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
        // the latest version of the android-apt plugin https://bitbucket.org/hvisser/android-apt
        // http://stackoverflow.com/a/25939518
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
} …Run Code Online (Sandbox Code Playgroud) 我刚刚将我的android gradle插件从0.12更新到0.13.此外,我已经下载了gradle 2.1.然后,我尝试使用android studio 0.8.9测试版但是根据http://tools.android.com/tech-docs/new-build-system/version-compatibility我必须至少使用android studio 0.8.11(金丝雀)渠道).所以我已经更新了我的android工作室,但我仍然有问题.
现在,我必须使用gradle 1.10和android gradle插件0.12.+才能工作
来自AS的错误
Error:No such property: projectDependencies for class: com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated
编辑:
这是我的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        // works with 0.12.+ (not with 0.13.+)
        classpath 'com.android.tools.build:gradle:0.12.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        // The latest version of the android-apt plugin
        classpath …Run Code Online (Sandbox Code Playgroud)