简体   繁体   English

让Android Studio + Gradle + Annotations协同工作

[英]Getting Android Studio + Gradle + Annotations to work together

I've been trying to get annotations to work in my gradle file so that I can use it with dagger, thus far with little success. 我一直试图在我的gradle文件中使用注释,以便我可以使用它与匕首,迄今为止收效甚微。 Here is my gradle file (using android studio 1.0 and gradle 1.0.0-rc4), to which I receive the following error when I try to sync: 这是我的gradle文件(使用android studio 1.0和gradle 1.0.0-rc4),当我尝试同步时,我收到以下错误:

Error:No such property: projectDependencies for class: com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated

Gradle file: Gradle文件:

buildscript {
repositories {

    mavenCentral()
}

dependencies {

    classpath 'com.android.tools.build:gradle:1.0.0-rc4'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4+'
}
}

apply plugin: 'com.android.application'
apply plugin: 'android-apt'


repositories {

mavenCentral()
}

android {
compileSdkVersion 21
buildToolsVersion '21.1.1'

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 21
}
lintOptions {
    checkReleaseBuilds false
    abortOnError false
    disable 'InvalidPackage'
}

buildTypes {
    release {
        minifyEnabled true
        proguardFile 'proguard-android.txt'
    }

    debug {
        minifyEnabled true
        proguardFile 'proguard-android.txt'
    }

}

dexOptions {
    preDexLibraries = false
}
}


apt {
arguments {
    androidManifestFile variant.processResources.manifestFile
    resourcePackageName 'my_package_name'
}
}

dependencies {
...

// Dependency Injection
compile 'com.squareup.dagger:dagger:1.2.2'
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
...

apt 'org.androidannotations:androidannotations:3.0.1'          
compile 'org.androidannotations:androidannotations-api:3.0.1'  
compile fileTree(dir: 'libs', include: ['*.jar'])

}

I'm not sure if this would be an answer to the entirety of your question but that error can be fixed by: 我不确定这是否可以解答您的整个问题,但错误可以通过以下方式解决:

replacing this line: androidManifestFile variant.processResources.manifestFile 替换此行: androidManifestFile variant.processResources.manifestFile

to: androidManifestFile variant.outputs[0].processResources.manifestFile to: androidManifestFile variant.outputs[0].processResources.manifestFile

according to this reference 根据这个参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM