Android-apt + android annotations + multiple flavors

Issue #34 invalid
vsimion created an issue

I'm trying to add multiple flavors to my app, but my manifest file cannot locate the generated activity (MainActivity_) for any of the build variants. Are flavors supported with apt and AA? This is in my app build.gradle

apt {
    arguments {
        androidManifestFile variant.output[0].processResources.manifestFile
        resourcePackageName android.defaultConfig.applicationId
    }
}

  productFlavors {
        flavor1{
            applicationId 'com.test.example.flavor1'
        }
        flavor2{
             applicationId 'com.test.example.flavor2'
        }
    }

Comments (10)

  1. Hugo Visser repo owner

    There's no explicit flavor support in android-apt. I think that variant.outputs[] is an array per flavor, but I'm unsure. You can verify from the command line by using --debug on gradlew to see what is set as the path to the compile.

    To clarify: android-apt will run on all flavors, the only thing that is not supported is separate configuration per flavor (e.g. aptFlavor)

  2. Hugo Visser repo owner

    Since I'm not a user of Android Annotations I'd definitely need some feedback from you to be able to investigate and maybe fix this. Otherwise, I'll have to close this issue as wont fix for now.

  3. Csaba Kozák

    @hvisser i think this problem is general and does not related to AndroidAnnotations. If i understand correctly, @vsimion wants the annotation processor to be invoked for each flavor, so the processors can generate source to each flavor's directory.

  4. Hugo Visser repo owner

    @WonderCsabo I'm pretty sure this is already the case, because it uses the variant which is a combination of flavor and build type. So android-apt will run for all flavors, the only thing that is not supported is separate configuration per flavor, which is usually not a big issue. I'm not sure what variant.output[0] points to in the case of AA.

  5. Csaba Kozák

    @hvisser, I see. I do not understand what is the problem, then. Maybe @vsimion can create a reduced test case project?

  6. vsimion reporter

    I've managed to get it working, My problem was on the apt configuration in the app build.gradle. This is my working configuration

    apt {
        arguments {
            androidManifestFile variant.outputs[0].processResources.manifestFile
            resourcePackageName android.defaultConfig.applicationId
        }
    }
    

    Also you always need to Build -> Make Project(Ctrl-F9 on Windows) after changing the build variant for the flavor.

    Thank you for your support.

  7. Log in to comment