3

I'm new to Android Studio and gradle, so I'm not sure on how to configure correctly my project to use android annotatios.

I have followed this tutorial, and ended up with this build.gradle file:

buildscript {
   repositories {
      mavenCentral()
   }
   dependencies {
      classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4+'
   }
}

apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
   compileSdkVersion 20
   buildToolsVersion '20.0.0'

   defaultConfig {
      applicationId "com.example.test"
      minSdkVersion 11
      targetSdkVersion 20
      versionCode 1
      versionName "1.0"
   }
   buildTypes {
      release {
         runProguard false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
   }
}

configurations {
   apt
}

apt {
   arguments {
      androidManifestFile variant.processResources.manifestFile
      resourcePackageName "com.example.test"
   }
}

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   apt "org.androidannotations:androidannotations:3.0+"
   compile "org.androidannotations:androidannotations-api:3.0+"
   compile 'com.android.support:appcompat-v7:20.0.0'
}

Also changed the .idea/compiler.xml to enable annotation processing

<profile default="true" name="Default" enabled="true">

Gradle syncs successfully, however no file is generated. I'm able to build the app, but when I try to add the underscore to my AndroidManifest.xml file, it gives me this error:

Cannot resolve symbol 'MainActivity_'

What am I doing wrong?

Kayan Almeida
  • 611
  • 8
  • 15
  • Did you "Make" the project? – WonderCsabo Oct 17 '14 at 19:09
  • When running make Android Studio should call all annotation processors. Did you check the build log to see actually what was triggered? – WonderCsabo Oct 18 '14 at 07:30
  • Running make project,and checking the console, I could not find anything saying that is calling the processors. So it's not calling? Or am I looking on the wrong place? – Kayan Almeida Oct 19 '14 at 16:55
  • This time, try rebuild instead of make. – WonderCsabo Oct 19 '14 at 20:21
  • Wow, now it's generated a log file with this note: `19:14:18.332 [Daemon Thread 29] INFO o.a.AndroidAnnotationProcessor:85 - Initialize AndroidAnnotations 3.0.1 with options {androidManifestFile=/home/kayan/AndroidRefs/LetsApp/app/build/intermediates/manifests/debug/AndroidManifest.xml, resourcePackageName=com.kayan.letsapp}` But it's not working yet – Kayan Almeida Oct 19 '14 at 21:17
  • Also the directory doesn't exists – Kayan Almeida Oct 19 '14 at 21:23
  • Try importing [this](https://github.com/excilys/androidannotations/tree/develop/examples/gradle) project. Is it working? – WonderCsabo Oct 19 '14 at 21:59
  • I was able to import it, and run clean, build, make... still nothing happens... – Kayan Almeida Oct 20 '14 at 00:04
  • @Hades no, I've found this : http://jakewharton.github.io/butterknife/ But I didn't have time to import it, at least the code gets cleaner. – Kayan Almeida Oct 23 '14 at 15:03
  • Guys, please post your build gradle, or better the project, so we can check your problem. – WonderCsabo Nov 22 '14 at 17:45
  • Look at: http://stackoverflow.com/questions/26705318/android-annotations-with-android-studio/27079797#27079797 – Pierry Nov 22 '14 at 17:50

0 Answers0