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)


發佈了25 篇原創文章 · 獲贊 6 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章