Search code examples
androidandroid-studioandroid-gradle-pluginandroid-annotations

Configuring Android Annotations v3.0.1 with Android Studio (Beta) 0.8.4


Configuring Android Annotations is quite irksome. But I finally figured out a solution and wish to share with everyone.


Solution

  • Use the below mentioned gradle buildscript.
    Following are some of the references:
    1) https://github.com/excilys/androidannotations/blob/develop/examples/gradle/build.gradle
    2) https://bitbucket.org/hvisser/android-apt
    3) http://www.jayway.com/2014/02/21/androidannotations-setup-in-android-studio/

    build.gradle

     buildscript {
          repositories {
          mavenCentral()
     }
          dependencies {
              classpath 'com.android.tools.build:gradle:0.12.1'
              classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
          }
     }
    
     apply plugin: 'com.android.application'
     apply plugin: 'com.neenbedankt.android-apt'
    
    
     repositories {
         mavenCentral()
     }
    
     ext.androidAnnotationsVersion = '3.0.1';
    
     configurations {
        apt
     }
    
     android {
         compileSdkVersion 19
         buildToolsVersion "19.1.0"
         useOldManifestMerger true
    
         defaultConfig {
             minSdkVersion 14
             targetSdkVersion 19
             versionCode 1
             versionName "1.0"
         }
    
    
    
         buildTypes {
             release {
                runProguard false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
             }
         }
    
         packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/notice.txt'
         }
    }
    
    dependencies {
        compile 'com.android.support:support-v4:20.0.+'
        compile 'com.android.support:appcompat-v7:20.0.+'
        apt "org.androidannotations:androidannotations:${androidAnnotationsVersion}"
        compile "org.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
        compile fileTree(dir: 'libs', include: '*.jar')
    
    } 
    
    
    apt {
        arguments {
            resourcePackageName 'com.yourpackage.name'
            androidManifestFile variant.processResources.manifestFile
        }
    }