Android Annotations框架配置Android Studio的操作步骤

1.配置gradle(Project):

  classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

allprojects {

 repositories {

    mavenCentral()

        mavenLocal()

        maven {

            url 'https://repo.spring.io/libs-snapshot'

        }

    }

}

2.配置gradle(app):

添加:

apply plugin: 'android-apt'

def AAVersion = '版本号'

apt {

    arguments {

        androidManifestFile variant.outputs[0]?.processResources?.manifestFile(新版本写这一句)

        // if you have multiple outputs (when using splits), you may want to have other index than 0

        // you should set your package name here if you are using different application IDs

        //  resourcePackageName "com.example.hp.myapplication"

        // You can set optional annotation processing options here, like these commented options:

        // logLevel 'INFO'

        // logFile '/var/log/aa.log'

    }

}

dependencies {

 compile 'com.android.support:appcompat-v7:23.3.0'

    apt "org.androidannotations:androidannotations:$AAVersion"

    compile "org.androidannotations:androidannotations-api:$AAVersion"

    }

     到这里位置已经可以正常使用AndroidAnnotations,包括 @EActiivty 等.

     (注意:在使用过注解工具之后点击Build中的Make Project,

     后台会自动生成一个比类名多一个下划线的类,比如:MainActivity生成之后就是MainActivity_,

     这时候去MainFests中把android: name=“  "类名"中的类名后加上"_"点击Make Project就行了)

 要是使用网络Rest注解工具在gradle(app)中添加:

//添加的是为了防止重复引用

  packagingOptions {

        exclude 'META-INF/DEPENDENCIES.txt'

        exclude 'META-INF/LICENSE.txt'

        exclude 'META-INF/NOTICE.txt'

        exclude 'META-INF/NOTICE'

        exclude 'META-INF/LICENSE'

        exclude 'META-INF/DEPENDENCIES'

        exclude 'META-INF/notice.txt'

        exclude 'META-INF/license.txt'

        exclude 'META-INF/dependencies.txt'

        exclude 'META-INF/LGPL2.1'

    }

//添加的是第三方包

dependencies {

apt "org.androidannotations:rest-spring:$AAVersion"

    compile "org.androidannotations:rest-spring-api:$AAVersion"

    compile 'org.springframework.android:spring-android-rest-template:2.0.0.BUILD-SNAPSHOT'

    compile 'org.springframework.android:spring-android-core:2.0.0.BUILD-SNAPSHOT'

    compile files('libs/jackson-annotations-2.8.0-20160517.060412-45.jar')

    compile files('libs/jackson-core-2.8.0-20160515.013135-115.jar')

    compile files('libs/jackson-databind-2.8.0-20160517.061118-256.jar')

}

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

作者:十丶安

来源:CSDN

原文:https://blog.csdn.net/qq_29232955/article/details/85320018

版权声明:本文为博主原创文章,转载请附上博文链接!

你可能感兴趣的:(Android Annotations框架配置Android Studio的操作步骤)