搞安卓开发以来,一直使用的Eclipse,Google出了AndroidStudio(简称AS)以后,一直忙于项目没有时间试试,今天装了一个适应一下,然后想在里面用上AndroidAnnotions(简称AA)(一个挺不错的开源框架,用起来特别方便,如果你现在在用Spring的注解,就会想在android中也来这么一个)。配置的时候遇到点问题!!!!!


1.首先,你可以上AndroidAnnotations的官网:http://androidannotations.org/,学习一下如何使用标签;

2.在Eclipse中的配置参考:https://github.com/excilys/androidannotations/wiki/Eclipse-Project-Configuration

下面讲讲如何在AS中配置AA:

1.安装AS,有钱的,没钱的百度下载AS;

2.建立AS的新项目,在左侧切换至Project的Porject模式,方便我们查看项目的目录

------>

注意右图里的有2个build.gradle文件,一个局部有效,一个全局有效,在局部build.gradle中(加入红色字体

apply plugin: 'com.android.application'apply plugin: 'android-apt'def AAVersion='3.3.2'android {    compileSdkVersion 23    buildToolsVersion "23.0.2"    defaultConfig {        applicationId "com.bq.facecode"        minSdkVersion 14        targetSdkVersion 23        versionCode 1        versionName "1.0"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }}dependencies {    compile fileTree(dir: 'libs', include: ['*.jar'])    testCompile 'junit:junit:4.12'    compile 'com.android.support:appcompat-v7:23.1.1'    compile 'com.android.support:design:23.1.1'    apt "org.androidannotations:androidannotations:$AAVersion"    compile "org.androidannotations:androidannotations-api:$AAVersion"}apt {    arguments {        //老版本的写法2.2.1以前        //androidManifestFile variant.processResources.manifestFile        //2.2.1以后        androidManifestFile variant.outputs[0].processResources.manifestFile        resourcePackageName 'com.bq.facecode'//项目包名    }}

然后在全局build.gradle中加入

// 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.5.0'        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'    }}allprojects {    repositories {        jcenter()    }}task clean(type: Delete) {    delete rootProject.buildDir}

需要注意的地方是,gradle的版本会造成一个错误

No such property 'processResources' on  com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated

遇到这个问题请不要慌张,查看一下全局文件中的红色字体部分,是不是使用的

com.neenbedankt.gradle.plugins:android-apt:1.3,如果是可以改成1.4试试


再查看一下你的gradle的版本,如果版本低于2.2.1,可能你得在局部文件中使用

androidManifestFile variant.processResources.manifestFile //(低版本的写法)

androidManifestFile variant.outputs[0].processResources.manifestFile //(高版本的写法)


关于查看项目Gradle的版本:

在项目左侧文件夹中找到gradle->wrapper->gradle-wrapper.properties,打开后即可看到

#Wed Oct 21 11:34:03 PDT 2015distributionBase=GRADLE_USER_HOMEdistributionPath=wrapper/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/distsdistributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
红字那里就是你当前使用的版本

更多相关文章

  1. 安卓ADT项目及升级AS(Android(安卓)Studio)全攻略
  2. Android新手入门2016(2)--Mac下的Android开发环境
  3. Eclipse 无法查看 Android(安卓)源代码
  4. 在Android中利用iText生成PDF
  5. fir.im Weekly - 600个 Android(安卓)开源项目汇总
  6. android悬浮窗及权限
  7. [置顶] 关于Android(安卓)NDK如何成功调用stl的使用分析
  8. 【Android】程序设计 ——记账App项目android移动端的实现
  9. Android手写开源项目和资料搜集

随机推荐

  1. PHP第二课:变量,常量,魔术常量
  2. php写一个计算器
  3. Laravel框架入门和基本使用(二)
  4. 【PHP连接MySQL】我来手把手教你PHP怎么
  5. laravel框架入门和基本使用(一)
  6. 【php基础入门】运算符、流程控制语句及
  7. Alibaba-技术专区-开源项目之Nacos功能特
  8. 如何解决跨域问题?
  9. 异常 - 虚拟机初始化错误 - Error occurr
  10. 锤炼你的核心竞争力