Android annotations and applicationIdSuffix
Asked Answered
C

2

8

I'd been trying out Android annotations recently and everything had been working well until I decided to add applicationIdSuffix in buildTypes in my build.gradle file. Currently it looks like this:

buildTypes {
    debug {
        applicationIdSuffix '.debug'
    }

    ...
}

And upon compiling I get the following log in gradle console:

:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:pre_testBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72220Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42220Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
No matching client found for package name 'org.me.myapp.debug'
:app:generateDebugResources
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
Note: Resolve log file to /dir/myapp/app/build/generated/source/apt/androidannotations.log
Note: Initialize AndroidAnnotations 3.3.1 with options {androidManifestFile=/dir/myapp/app/build/intermediates/manifests/full/debug/AndroidManifest.xml}
Note: Start processing for 4 annotations on 18 elements
Note: AndroidManifest.xml file found with specified path: /dir/myapp/app/build/intermediates/manifests/full/debug/AndroidManifest.xml Note: AndroidManifest.xml found: AndroidManifest [applicationPackage=org.me.myapp.debug, componentQualifiedNames=[org.me.myapp.ui.MainActivity_, net.hockeyapp.android.UpdateActivity], permissionQualifiedNames=[android.permission.ACCESS_WIFI_STATE, android.permission.ACCESS_NETWORK_STATE], applicationClassName=null, libraryProject=false, debugabble=false, minSdkVersion=15, maxSdkVersion=-1, targetSdkVersion=22]
error: The generated org.me.myapp.debug.R class cannot be found
Note: Found Android class: android.R
Note: Time measurements: [Whole Processing = 15 ms], [Extract Manifest = 4 ms], [Extract Annotations = 3 ms],
Note: Finish processing
Note: Start processing for 0 annotations on 0 elements
Note: Time measurements: [Whole Processing = 0 ms],
Note: Finish processing
1 error
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.

I've tried cleaning and rebuilding again, removing generated directory from the project, but nothing helps. If I remove applicationIdsuffix from build.gradle file, everything works fine. How can I fix this problem?

Chemisorb answered 29/6, 2015 at 13:11 Comment(0)
S
9

Remove this line from your build.gradle file:

resourcePackageName android.variant.applicationId

Edit: try to add this line to your apt block:

resourcePackageName "org.me.myapp"
Sidnee answered 29/6, 2015 at 14:0 Comment(6)
I don't have anywhere this line.Chemisorb
or "resourcePackageName android.defaultConfig.applicationId" to avoid using hardcoded valuesNato
But my problem was solved by giving correct value for applicationId in defaultConfig of app level build.gradleTriggerhappy
Yes, you need the default app id, it does not matter how you pass it. The original problem here was the per variant app id was used. Actually AA needs the manifest package, not the app id, but most of the time the manifest package is the same as the default app id.Sidnee
@Sidnee do you know how configurate this but fopr the new annotationProcessor. I'm not using aptChader
@Chader please read this thread.Sidnee
H
22

For me this was happening because google-services.json was referring to my production package name. The best solution at the time of this writing seems to be to either write your own gradle tasks to switch between release and debug versions of the file, or to include both package names in the file:

google-services.json for different productFlavors

Hay answered 21/12, 2015 at 22:57 Comment(0)
S
9

Remove this line from your build.gradle file:

resourcePackageName android.variant.applicationId

Edit: try to add this line to your apt block:

resourcePackageName "org.me.myapp"
Sidnee answered 29/6, 2015 at 14:0 Comment(6)
I don't have anywhere this line.Chemisorb
or "resourcePackageName android.defaultConfig.applicationId" to avoid using hardcoded valuesNato
But my problem was solved by giving correct value for applicationId in defaultConfig of app level build.gradleTriggerhappy
Yes, you need the default app id, it does not matter how you pass it. The original problem here was the per variant app id was used. Actually AA needs the manifest package, not the app id, but most of the time the manifest package is the same as the default app id.Sidnee
@Sidnee do you know how configurate this but fopr the new annotationProcessor. I'm not using aptChader
@Chader please read this thread.Sidnee

© 2022 - 2024 — McMap. All rights reserved.