Getting Android Studio, Gradle and Android Annotations working together

耗尽温柔 提交于 2019-12-12 08:44:05

问题


now that i've decided to use Android Annotations with Android Studio i wanted to implement it through Gradle. After some thoughtful research i've found out that there are older and newer ways of implementing Android Annotations through Gradle depending on which version android studio, gradle or android annotations have. i came to this useful tutorial -> http://www.jayway.com/2014/02/21/androidannotations-setup-in-android-studio/ , and tried to implement this , at first, with the new 'android-L' as target SDK like

targetSDKversion "android-L" + compileSdkVersion 20 + buildToolsVersion "20.0.0"

until i tried it with

targetSDKversion 20 + compileSdkVersion 20 + buildToolsVersion "20.0.0"

and also

targetSDKversion 19 + compileSdkVersion 19 + buildToolsVersion "19.1.0".

Everytime i was getting 2 warnings that my java classes dont seem to get precompiled. even though it seems that it pre-creates the build/generated/source/apt directory. but without my pre-processed class from my MainActivity -> MainActivity_

I always do get following Warnings:

Note: Resolve log file to D:\AndroidProjects\GradleTest\app\build\generated\source\apt\androidannotations.log Note: Initialize AndroidAnnotations 3.0.1 with options >{androidManifestFile=D:\AndroidProjects\GradleTest\app\build\intermediates\manifests\debug\AndroidManifest.xml, resourcePackageName=at.gradle.defuex.gradletest}

warning: Unclosed files for the types '[dummy1407928544078]'; these types will not undergo annotation processing

warning: The following options were not recognized by any processor: '[androidManifestFile, resourcePackageName]'

My build.gradle file looks like this:

buildscript{
repositories{
    mavenCentral()
}

dependencies{
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3'
    }
}


repositories{
    mavenCentral()
}

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

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "at.gradle.defuex.gradletest"
        minSdkVersion 10
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }

    signingConfigs{
        releaseConfig{
            storeFile file("gradlekeystore.jks");
            storePassword ("*************");
            keyAlias "keyAlias";
            keyPassword "*************";
        }
    }


    buildTypes {
        release {
            runProguard false
            debuggable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            signingConfig signingConfigs.releaseConfig
        }

        debug {
            debuggable true
            applicationIdSuffix ".debug"
        }
    }
}

apt {
    arguments {
        androidManifestFile variant.processResources.manifestFile
        resourcePackageName "at.gradle.defuex.gradletest"
    }
}

dependencies {
    apt "org.androidannotations:androidannotations:3.0+"
    compile "org.androidannotations:androidannotations-api:3.0+"
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.+'
}

Im using following Versions:

  • Android Studio version 0.8.2
  • Gradle version 0.12.2
  • android-apt version 1.3
  • android annotations version 3.0.1 (as seen in the build.gradle file)
  • If there should be a solution to this problem please tell me, because im confused now.
  • If there should be a better annotations framework or a way of using cool annotations, please tell me that too.
  • And if it should not be a common way anymore to use annotations for android projects anyway, please pleeeeease tell me that too.

,but i would prefer a solution to my problem :)

Cheers!


回答1:


Try to run gradlew clean build from project root. Then try to make project (button with a green arrow with 0 and 1) before running on a device. Should be fine.



来源:https://stackoverflow.com/questions/25290256/getting-android-studio-gradle-and-android-annotations-working-together

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!