Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android annotations and applicationIdSuffix

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?

like image 492
Mikhail Avatar asked Jun 29 '15 13:06

Mikhail


2 Answers

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

like image 143
yuval Avatar answered Sep 30 '22 18:09

yuval


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"
like image 26
WonderCsabo Avatar answered Sep 30 '22 17:09

WonderCsabo