Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find symbol variable ReactNativeFlipper in MainApplication.java #36179

Closed
uloco opened this issue Feb 16, 2023 · 7 comments
Closed

Cannot find symbol variable ReactNativeFlipper in MainApplication.java #36179

uloco opened this issue Feb 16, 2023 · 7 comments
Labels
Resolution: Answered When the issue is resolved with a simple answer

Comments

@uloco
Copy link
Contributor

uloco commented Feb 16, 2023

Description

As many others, I am running in this issue when trying to build a release variant on android:

Cannot find symbol variable ReactNativeFlipper in MainApplication.java

Although I do have the correct file at android/app/src/release/java/world/smokeless/android/ReactNativeFlipper.java

We also only have two build types debug and release, BUT we have three buildFlavors dev, stage and production.

Do I have to adjust anything regarding the flavors maybe?

Version

0.71.3

Output of npx react-native info

info Fetching system and libraries information...
System:
OS: macOS 13.2.1
CPU: (8) arm64 Apple M1
Memory: 51.19 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.14.0 - ~/Library/Caches/fnm_multishells/21608_1676535665395/bin/node
Yarn: Not Found
npm: 9.3.1 - ~/Library/Caches/fnm_multishells/21608_1676535665395/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9514443
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 11.0.14.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.3 => 0.71.3
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Try to build a android app release app with build flavors.

Snack, code example, screenshot, or link to a repository

build.gradle android section

android {
    ndkVersion rootProject.ext.ndkVersion
    compileSdkVersion rootProject.ext.compileSdkVersion
    namespace "world.smokeless.android"

    defaultConfig {
        applicationId "world.smokeless.android"
        versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : 2
        versionName project.hasProperty('versionName') ? project.property('versionName') : getNpmVersion()

        multiDexEnabled true
        flavorDimensions "environment"
        productFlavors {
            dev {
                minSdkVersion rootProject.ext.minSdkVersion
                applicationId 'world.smokeless.android.dev'
                targetSdkVersion rootProject.ext.targetSdkVersion
                resValue "string", "build_config_package", "world.smokeless.android"
                dimension "environment"
            }
            stage {
                minSdkVersion rootProject.ext.minSdkVersion
                applicationId 'world.smokeless.android.stage'
                targetSdkVersion rootProject.ext.targetSdkVersion
                resValue "string", "build_config_package", "world.smokeless.android"
                dimension "environment"
            }
            production {
                minSdkVersion rootProject.ext.minSdkVersion
                applicationId 'world.smokeless.android'
                targetSdkVersion rootProject.ext.targetSdkVersion
                resValue "string", "build_config_package", "world.smokeless.android"
                dimension "environment"
            }
        }
        //detox ui test
        testBuildType System.getProperty('testBuildType', 'debug')  // This will later be used to control the test apk build type
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
        missingDimensionStrategy 'detox', 'full'
        // end detox ui test
    }


    signingConfigs {
        production {
            ...
        }
        stage {
            ...
        } 
        dev {
            ...
        }
    }
    buildTypes {
        release {
            // if the environment Variables are not set, we will not sign the apks
            
            if (STAGE_KEY_PASSWORD != null) {
                productFlavors.stage.signingConfig signingConfigs.stage
            }

            if (RELEASE_KEY_PASSWORD != null) {
                productFlavors.production.signingConfig signingConfigs.production
            }
                 productFlavors.dev.signingConfig signingConfigs.dev
            


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

@cortinico
Copy link
Contributor

Do I have to adjust anything regarding the flavors maybe?

I've checked your build.gradle file you attached (thanks for doing it), and it looks correct to me. If you have 2 ReactNativeFlipper.java file (one inside /debug and one inside /release) you should be fine.

Could you try to replicate this in a reproducer from npx react-native init, by adding the 3 product flavours your also have and see if the crash replicates also there?

@uloco
Copy link
Contributor Author

uloco commented Feb 16, 2023

Ok so apparently I did have a wrong package name in the ReactNativeFlipper.java in the release folder, so it did not get imported correctly.

This happened because the upgrade helper prefixes the app name with com. and since we don't have a com domain our app name is different. Would be nice if there was a way to specify app name differently for ios and android and explicitly in upgrade helper with no magic prefixing stuff. I ran into this issue a few times already.

Thanks for your hint and pair of eyes :)

@uloco uloco closed this as completed Feb 16, 2023
@cortinico
Copy link
Contributor

Would be nice if there was a way to specify app name differently for ios and android and explicitly in upgrade helper with no magic prefixing stuff

That's a great suggestion actually 🤔 don't you mind opening a feature request here:
https://github.com/react-native-community/upgrade-helper/issues/new/choose

@cortinico cortinico added Resolution: Answered When the issue is resolved with a simple answer and removed Needs: Triage 🔍 labels Feb 16, 2023
@uloco
Copy link
Contributor Author

uloco commented Feb 22, 2023

@cortinico
Copy link
Contributor

Closing as we don't have code inside RN that controls this logic 👍 It's up to the upgrade-helper

@cortinico cortinico reopened this Feb 22, 2023
@victoriaSh
Copy link

Maybe it could be useful for someone. I also had this error and wrong directory structure for release build after using react-native-rename on the fresh new project (directory for "middle string" in bundle id was missing)

@Fb9027
Copy link

Fb9027 commented Mar 4, 2023

Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Answered When the issue is resolved with a simple answer
Projects
None yet
Development

No branches or pull requests

4 participants