question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build android app error when added productFlavors

See original GitHub issue

Is this a bug report?

Yes,

Have you read the [Contributing Guidelines]

Yes,

Environment

Environment: OS: macOS High Sierra 10.13.2 Node: 6.9.2 Yarn: 1.3.2 npm: 5.5.1 Watchman: 4.5.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed) react: 16.0.0-alpha.12 => 16.0.0-alpha.12 react-native: ^0.48.3 => 0.48.3

Target Platform: iOS (10.3)

Steps to Reproduce

  1. create android with multiple productFlavors (demo, full and etc)
  2. build different flavor app on android device by running this command, react-native run-android --variant=demoDebug or react-native run-android --variant=fullDebug
flavorDimensions  "app"
productFlavors { 
        demo {
            dimension "app"
            applicationId "com.demo"
            resValue "string", "app_name", "demo"
            manifestPlaceholders = [
                    appIcon: "@mipmap/ic_launcher_demo"
            ]
            versionCode 1
            versionName "1.0"
        }
        full {
            dimension "app"
            applicationId "com.full"
            resValue "string", "app_name", "full"
            manifestPlaceholders = [
                    appIcon: "@mipmap/ic_launcher_full"
            ]
            versionCode 1
            versionName "1.0"
        }
}

Expected Behavior

expect different flavors of app will build on android device,

Actual Behavior

the build failed and i, i get this error Error: Activity class {com.todo/com.todo.MainActivity} does not exist,

but I’m able to build the app successfully if i remove the productFlavors {}

any advice will be appreciate.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:6

github_iconTop GitHub Comments

1reaction
samzmanncommented, Oct 7, 2018

I ran into this issue and found some way to make it work: I have two product flavors

  • prod, with applicationId “com.yetno.yetnoapp” (which is the main app id)
  • dev, with applicationId “com.yetno.yetno_app”

When building and running dev (react-native run-android --variant=devDebug) I was getting the error described in this issue. Then I noticed, if I build the prod variant first and have it installed on the device, building and installing the dev variant works fine. So the steps are:

  1. cd android && ./gradlew clean
  2. cd ..
  3. react-native run-android --variant=prodDebug
  4. react-native run-android --variant=devDebug

So this is not really an answer, but it worked for me and maybe it can help some of you guys out 😃

0reactions
johanforssellcommented, Sep 19, 2018

I’m writing new versions of old apps, and thus I have inherited old app id’s.

My code have the package com.common.package (in source files and AndroidManifest.xml).

My build.gradle contains

    buildTypes {
        debug {
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    flavorDimensions "appName"
    productFlavors {
        appAAA {
            dimension "appName"
            applicationId "com.AAA.app"
            versionCode 100
            versionName "3.0.0"
        }
        appBBB {
            dimension "appName"
            applicationId "com.BBB.app"
            versionCode 100
            versionName '3.0.0'
        }
    }

First the app can be installed with gradlew

cd android && ./gradlew installAppBBBDebug

The I can start it manually with

adb -s emulator-5554 shell am start -n com.BBB.app/com.common.package.MainActivity

This is a bloody hassle. I would rather not have to mess with it like this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

adding productFlavors in build.grade(Module:app) giving error
Your build.gradle would end up being something like this: android { compileSdkVersion 25 buildToolsVersion "25.0.3" defaultConfig ...
Read more >
Configure build variants | Android Developers
Each build variant represents a different version of your app that you can ... Add product flavors to the productFlavors block in your...
Read more >
Android Build Types and Product Flavors - DigitalOcean
In this tutorial, we'll be discussing Android Build Types and Product Flavors. We'll see how they make our Android Development easier and ...
Read more >
Build problem with multiple product flavours in new version ...
The specific error we're getting is: Cannot find a variant matching build type 'debug' and product flavors '[gms]' in :app. I've added ......
Read more >
Product Flavors for Android Library | by Sahil Dave - Medium
In this post I would add product flavors to one of the libraries that I am ... To cope with this problem, you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found