简体   繁体   中英

ActivityNotFoundException using product flavors

I'm playing with product flavors in Android Studio and have hit a bump...!

I have set up two product flavors in the build.gradle file

productFlavors {

    pro {
        packageName "com.foo.bar.pro"
    }

    free {
        packageName "com.foo.bar.free"
    }
}

This builds fine and will install onto a device.

The problem I have is that I added a startActivity call into the MainActivity class which is in the /src/main/java.... folder. The 'free' debug build complains that it cannot find the explicit class com.foo.bar.free.....

I thought that this would be handled.. But do I need to do something specific?

It turns out that the activity was declared in the manifest as .SetupActivity. I changed it to the fully qualified name and it worked!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM