Repository navigation
Cannot pass resourcePackageName to new annotationProcessor #1964
Description
Activity
Hi @AleksanderMielczarek, I have the same problem, did you manage to find a solution to compile your app in debug ?
Hey guys, I'm going to test this with my app if i can reproduce - and hopefully fix this issue.
apt plugin is not compatible with Gradle build tools 2.3.0 so I've switched to annotationProcessor and used approach suggested here.
why do you think that it is not compatible? I just updated build tools to 2.3.0 and gradlew to 3.3 and with android-apt 1.8 i can build my app. even when i add product flavours.
can you supply a sample project where you have this issue so that i can see if i can reproduce it? :)
@dodgex I get message about incompatibility in quite big project which I'm unable to paste here but I'll prepare example project and let you know.
@dodgex : android-apt is now officially deprecated: https://bitbucket.org/hvisser/android-apt/wiki/Migration
So androidannotations should be made compatible with the new annotationProcessor.I've created a sample project showing that
android-aptis now incompatible with google plugins like databinding.If you try to compile it fails.
When you remove the lineapply plugin: 'android-apt'it compiles fine.As you can see, I did not even add androidannotations.
android-aptis deprecated since 2.3 canary came out and since current and future google plugins will rely on the new annotation processor, androidannotations should use it as well.
AATest.zip@couchcrew-thomas I'am using databinding so that would be the reason why build fails for me.
@couchcrew-thomas thank you for that information. I didn't know that.
I'll see what I can do to get the stuff working. I just wonder why my app is building fine with 2.3 and android-apt. Maybe because I'm not using stuff like databinding.
@dodgex Here is sample project with mentioned issue:
https://github.com/AleksanderMielczarek/AndroidAnnotationsAnnotationProcessorIssue@AleksanderMielczarek Thank you for that project. I think I found a solution. 🎉
As we have implemented some code that automatically finds the
AndroidManifest.xmlit is no longer necessary to provide the path in build.gradle (see #1543). That means that the old snipped to add parameters is no longer necessary... we only need theresourcePackageNamefor flavors with differentapplicationIdthan the one indefaultConfigandroid.applicationVariants.all { variant -> variant.variantData.variantConfiguration.javaCompileOptions.annotationProcessorOptions.arguments = ['androidManifestFile': variant.outputs[0]?.processResources?.manifestFile?.absolutePath, 'resourcePackageName': android.defaultConfig.applicationId] }the above snipped can me removed instead one can provide the arguments directly from the defaultConfigblock:
defaultConfig{ // other config javaCompileOptions { annotationProcessorOptions { arguments = ['resourcePackageName': android.defaultConfig.applicationId] } } }with this change the build is working. :)
Reacted by Luong Vo (Lucas), Rahul Kumar and amitbtw and a little bit offtopic:
you do not need to provide full
applicationIdfor your flavors. The below block has the same effekt than yours. :)defaultConfig { applicationId "com.github.aleksandermielczarek.androidannotationsannotationprocessorissue" // other config } productFlavors { dev { applicationIdSuffix ".debug" } prod { // uses applicationId from defaultConfig } }@dodgex Thank you for help. I can confirm that it's working now. I remember that arg
androidManifestFilewas mentioned somewhere in doc and it was part I always paste to every new project.And thank you for trick with applicationIdSuffix, really useful👍
Nice! I'll close the issue then :)
Before 4.0.0
androidManifestFilewas a required argument and it looks no one updated the wiki :DThe wiki has been updated: https://github.com/androidannotations/androidannotations/wiki/Building-Project-Gradle
Reacted by JasonIt still fails for library projects. I've created a new issue since it does not match the OT of this one. #1974
Ola amigos eu tive esse mesmo problema. O problema estava no atributo applicationId dentro do build.gradle do projeto android, eu estava usando o id de outro projeto ao inves de usar o id do projeto que eu havia baixado, nisso nem precisei usar esse Jack bugado que criaram.
Hi,
apt plugin is not compatible with Gradle build tools 2.3.0 so I've switched to annotationProcessor and used approach suggested here.
I have two different applicationId based on flavor. I cannot build flavor dev. AA is looking in wrong package (should use "com.my.app" but instead "com.my.app.debug" is used). Flavor prod, which has default applciationId works. This setup works with apt and 2.2.3 tools.
I think resourcePackageName is not passed properly to AA.
Log:
build.gradle: