AndroidStudio 1.0 中使用AndroidAnnonations




androidannotations-3.2.jar 复制到APP下compile-libs (不存在这个文件,自己创建)
第一步 将androidannotations-api-3.2.jar 复制到APP下的libs


--------------------------------------
第二步 全局build.gradle




// Top-level build file where you can add configuration options common to all sub-projects/modules.

// 设置脚本的运行环境
buildscript {

    /**
     *  支持java 依赖库管理(maven/ivy),用于项目的依赖
     * */
    repositories {
        jcenter()
    }

    /**  依赖包的定义。
     * 支持maven/ivy,远程,本地库,也支持单文件,
     * 如果前面定义了repositories{}maven 库,
     * 使用maven的依赖(我没接触过ivy。。)的时候只需要按照用类似于com.android.tools.build:gradle:0.4,
     * gradle 就会自动的往远程库下载相应的依赖。
     * */
    dependencies {
        classpath "com.android.tools.build:gradle:1.0.0"
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}



---------------------------

第三步   App 下面的  build.gradle

apply plugin: 'android'
apply plugin: 'android-apt'

def AndroidAnnotationVersion = '3.2'
def AppPackageName = "com.xxx.yyy"

def AppVersionCode = 1
def AppVersionName = "1.0.0"

/**
 * 设置编译android项目的参数
 */
android {

    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "com.hequ.merchant"
        minSdkVersion 14
        targetSdkVersion 21
        versionName AppVersionName
        signingConfig signingConfigs.hequ
    }


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

}

configurations {
    apt
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //AndroidAnnotation
    apt files('compile-libs/androidannotations-3.2.jar')
    //apt "org.androidannotations:androidannotations:$AndroidAnnotationVersion"
    //compile "org.androidannotations:androidannotations-api:$AndroidAnnotationVersion"
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:support-v4:21.0.3'
    compile project(':imeth')
}

apt {
    arguments {
        androidManifestFile variant.<span style="background-color: rgb(255, 102, 102);">outputs[0]</span>.processResources.manifestFile
        resourcePackageName AppPackageName
    }
}

注意 红色区 网上很多教程都不是这样的..

----------------------------


第四步,  编译一下就都Ok了





有什么问题可以QQ(765858000)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值