gpt4 book ai didi

android - 让 Android Studio、Gradle 和 Android Annotations 协同工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:17:39 28 4
gpt4 key购买 nike

既然我已经决定在 Android Studio 中使用 Android Annotations,我想通过 Gradle 来实现它。经过深思熟虑的研究后,我发现根据 android studio、gradle 或 android 注释的版本,有通过 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 -> 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 注释版本 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 的绿色箭头的按钮)。应该没问题。

关于android - 让 Android Studio、Gradle 和 Android Annotations 协同工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25290256/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com