让Android Studio,Gradle和Android Annotations协同工作

前端之家收集整理的这篇文章主要介绍了让Android Studio,Gradle和Android Annotations协同工作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
既然我决定在 Android Studio中使用Android Annotations,我想通过Gradle实现它.经过一些深思熟虑的研究后,我发现有更旧的方法可以通过Gradle实现Android Annotations,具体取决于android studio,gradle或android注释的版本.我来到这个有用的教程 – > http://www.jayway.com/2014/02/21/androidannotations-setup-in-android-studio/,并试图实现这一点,首先,用新的’android-L’作为目标SDK之类的

targetSDKversion “android-L” + compileSdkVersion 20 + buildToolsVersion “20.0.0”

直到我试着用它

targetSDKversion 20 + compileSdkVersion 20 + buildToolsVersion “20.0.0”

并且

targetSDKversion 19 + compileSdkVersion 19 + buildToolsVersion “19.1.0”.

每次我得到2个警告,我的java类似乎没有得到预编译.即使它似乎预先创建了build / generated / source / apt目录.但没有我的MainActivity预处理类 – >主要活动_

我总是得到以下警告:

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]’

我的build.gradle文件如下所示:

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.+'
}

我使用以下版本:

> Android Studio版本0.8.2
> Gradle版本0.12.2
> android-apt版本1.3
> android annotations版本3.0.1(如build.gradle文件中所示)

  • 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.

,但我更喜欢解决我的问题:)

干杯!

解决方法

尝试从项目根目录运行gradlew clean build. 然后在设备上运行之前尝试制作项目(带有绿色箭头0和1的按钮).应该没事.
原文链接:https://www.f2er.com/android/314459.html

猜你在找的Android相关文章