Home Ask Login Register

Developers Planet

Your answer is one click away!

Nestor February 2016

Flavored Activity can't be found on launch

I have created 2 flavors in Android Studio's Gradle, and I put the MainActivity file in their respective folder structures.

This is how the project looks:

enter image description here

This is the Gradle flavor part:

productFlavors {
        free {
            applicationId "com.xxxxx.yyyyy.free"
            versionName "1.0.0"
        full {
            applicationId "com.xxxxx.yyyyy"
            versionName "1.0.0"

Unfortunately, when I use the full flavor, the MainActivity is considered unset.

Free flavor:

enter image description here

Full flavor:

enter image description here

The project can be compiled in both flavors, it just can't be run on full flavor as it can't find the Default Activity. The two files have minimal differences.

What should I check?


keith February 2016

Perhaps not directly addressing your issue, but have you considered making a pure Java helper class that provides different functionality to your MainActivity?

The problem here appears to be your moving MainActivity is not being recognized by the AndroidManifest when in full mode, but if you have 2 versions of your helper class everything should be good

Edit If you want to specify two different activities, use a relative path in your AndroidManifest.

<activity android:name=".MainActivity">

Be cautious to try and reuse as much common code as possible between your two activities to save yourself any headaches down the road though

Post Status

Asked in February 2016
Viewed 1,626 times
Voted 11
Answered 1 times


Leave an answer

Quote of the day: live life