facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.05k stars 24.32k forks source link

Cannot find symbol variable ReactNativeFlipper in MainApplication.java #36154

Closed gabriellend closed 1 year ago

gabriellend commented 1 year ago

Description

I'm not sure this is a bug but I couldn't find any other issue like this on Stack Overflow, in React Native issues, or searching online and thought maybe someone could point me in the right direction. I've tried cleaning, restarting, and triple checking that I did the migration correctly.

I'm running into this error when building a debug apk in Android Studio. The app will run fine on the emulator.

Screenshot 2023-02-14 at 9 48 43 AM Screenshot 2023-02-14 at 9 48 55 AM

Here is my MainApplication.java

package com.mypackage5;

import com.intercom.reactnative.IntercomModule;
import android.app.Application;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;
import com.facebook.react.PackageList;
import com.facebook.react.ReactInstanceManager;
import com.microsoft.codepush.react.CodePush;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;

import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost =
        new DefaultReactNativeHost(this) {
            @Override
            public boolean getUseDeveloperSupport() {
              return BuildConfig.DEBUG;
            }

            @Override
            protected List<ReactPackage> getPackages() {
              @SuppressWarnings("UnnecessaryLocalVariable")
              List<ReactPackage> packages = new PackageList(this).getPackages();
              // Packages that cannot be autolinked yet can be added manually here, for example:
              // packages.add(new MyReactNativePackage());
              packages.add(new CodePush(BuildConfig.CODEPUSH_KEY, getApplicationContext(), BuildConfig.DEBUG));
              return packages;
            }

            @Override
            protected String getJSBundleFile() {
              return CodePush.getJSBundleFile();
            }

            @Override
            protected String getJSMainModuleName() {
              return "index";
            }

            @Override
            protected boolean isNewArchEnabled() {
              return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
            }

            @Override
            protected Boolean isHermesEnabled() {
              return BuildConfig.IS_HERMES_ENABLED;
            }
        };

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
      // If you opted-in for the New Architecture, we load the native entry point for this app.
      DefaultNewArchitectureEntryPoint.load();
    }
    ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
    IntercomModule.initialize(this, "android_sdk-b859cba08266c0c3fed2244509bdd35d96d4e86f", "ouqdzz74");
  }

  public String getJSMainModuleName() {
    return "index";
  }

  public ReactInstanceManager getReactInstanceManager() {
    // CodePush must be told how to find React Native instance
    return getReactNativeHost().getReactInstanceManager();
  }

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }
}

Version

0.71.2

Output of npx react-native info

System: OS: macOS 13.1 CPU: (8) arm64 Apple M1 Memory: 107.13 MB / 8.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node Yarn: 1.22.17 - /opt/homebrew/bin/yarn npm: 6.14.15 - ~/node_modules/.bin/npm Watchman: 2022.06.06.00 - /opt/homebrew/bin/watchman 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: API Levels: 31, 33 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 33.0.0 System Images: android-31 | Google Play ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2022.1 AI-221.6008.13.2211.9477386 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 17.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.2 => 0.71.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

Inside Android Studio: Build -> Generate Signed Bundle / APK and follow the steps to the end. When I click 'Create', I see lines running in Build Output and it gets pretty far but eventually this error pops up.

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

I'm sorry, I hate coming empty handed but my codebase is so huge I'm not sure how I would do this. If you have to close it I understand.

twln1 commented 1 year ago

Do you have android/app/src/debug/java/com/rndiffapp/ReactNativeFlipper.java present? I think I had that same issue when upgrading and I hadn't added this file. Given you are trying to build a debug version it sounds like this might be the culprit

What version did you upgrade from?

gabriellend commented 1 year ago

@twln1 I believe I have that file in that location, as well as having to make a new folder called release and put a ReactNativeFlipper.java in there too. Ill double check when Im home. I’ve been slowly coming up from 0.67.4 but was most recently able to make a debug apk at 0.70. Thank you for your help!

gabriellend commented 1 year ago

Yep! That file is there!

gdpr1504 commented 1 year ago

any update on this?

cortinico commented 1 year ago

I guess the problem is because you're using flavors. Can you share your android/app/build.gradle file? Can you also clarify which flavors and build types are you using?

lovelytingy commented 1 year ago

@gabriellend hi, just curious, how's you system running with 107 mb only?

gabriellend commented 1 year ago

@cortinico Thank you! I'm not actually sure what flavors/build types I'm using. This is the first time I think I've had to talk about them so not totally sure what they are. I do see def jscFlavor = 'org.webkit:android-jsc:+' (in the React Native code as well) though in my app/build.gradle:

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'

import com.android.build.OutputFile

project.ext.react = [
        jsBundleDirDebug: "$buildDir/intermediates/merged_assets/debug/mergeDebugAssets/out",
        jsBundleDirRelease: "$buildDir/intermediates/merged_assets/release/mergeReleaseAssets/out",
]

apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

/**
 * This is the configuration block to customize your React Native Android app.
 * By default you don't need to apply any configuration, just uncomment the lines you need.
 */
react {
    /* Folders */
    //   The root of your project, i.e. where "package.json" lives. Default is '..'
    // root = file("../")
    //   The folder where the react-native NPM package is. Default is ../node_modules/react-native
    // reactNativeDir = file("../node_modules/react-native")
    //   The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
    // codegenDir = file("../node_modules/react-native-codegen")
    //   The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
    // cliFile = file("../node_modules/react-native/cli.js")

    /* Variants */
    //   The list of variants to that are debuggable. For those we're going to
    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    // debuggableVariants = ["liteDebug", "prodDebug"]

    /* Bundling */
    //   A list containing the node command and its flags. Default is just 'node'.
    // nodeExecutableAndArgs = ["node"]
    //
    //   The command to run when bundling. By default is 'bundle'
    // bundleCommand = "ram-bundle"
    //
    //   The path to the CLI configuration file. Default is empty.
    // bundleConfig = file(../rn-cli.config.js)
    //
    //   The name of the generated asset file containing your JS bundle
    // bundleAssetName = "MyApplication.android.bundle"
    //
    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    // entryFile = file("../js/MyApplication.android.js")
    //
    //   A list of extra flags to pass to the 'bundle' commands.
    //   See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
    // extraPackagerArgs = []

    /* Hermes Commands */
    //   The hermes compiler command to run. By default it is 'hermesc'
    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
    //
    //   The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
    // hermesFlags = ["-O", "-output-source-map"]
}

/**
 * Set this to true to create four separate APKs instead of one,
 * one for each native architecture. This is useful if you don't
 * use App Bundles (https://developer.android.com/guide/app-bundle/)
 * and want to have separate APKs to upload to the Play Store.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Set this to true to run Proguard on Release builds to minify the Java bytecode.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore (JSC)
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US. Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Private function to get the list of Native Architectures you want to build.
 * This reads the value from reactNativeArchitectures in your gradle.properties
 * file and works together with the --active-arch-only flag of react-native run-android.
 */
def reactNativeArchitectures() {
    def value = project.getProperties().get("reactNativeArchitectures")
    return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion "30.0.3"
    lintOptions {
        checkReleaseBuilds false
    }
    namespace "com.mypackage5"
    defaultConfig {
        applicationId "com.mypackage5"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
        // missingDimensionStrategy "RNN.reactNativeVersion", "reactNative63" // See note below!
        multiDexEnabled true
        versionCode 20
        versionName "7.0.0"
        //Possibly don't need this?
        // ndk {
        //     abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        // }
    }

    signingConfigs {
        releaseStaging {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include (*reactNativeArchitectures())
        }
    }
    buildTypes {
        debug {
            // Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
            buildConfigField "String", "CODEPUSH_KEY", MYAPP_STAGING_CODE_PUSH_KEY
            manifestPlaceholders = [isDebug:true]
        }
        releaseStaging {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
            buildConfigField "String", "CODEPUSH_KEY", MYAPP_STAGING_CODE_PUSH_KEY
            debuggable false
            matchingFallbacks = ['release', 'debug']
            manifestPlaceholders = [isDebug:false]
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
            buildConfigField "String", "CODEPUSH_KEY", MYAPP_PRODUCTION_CODE_PUSH_KEY
            debuggable false
            manifestPlaceholders = [isDebug:false]
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        defaultConfig.versionCode * 1000 + versionCodes.get(abi)
            }
        }
    }

}

subprojects {
    project.configurations.all {
        afterEvaluate {project ->
            if (project.hasProperty("android")) {
                android {
                    buildToolsVersion rootProject.ext.buildToolsVersion
                    ndkVersion rootProject.ext.ndkVersion
                    compileSdkVersion rootProject.ext.compileSdkVersion
                }
            }
            if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
                android {
                    variantFilter { variant ->
                        def names = variant.flavors*.name
                        if (names.contains("reactNative51") || names.contains("reactNative55") || names.contains("reactNative56") || names.contains("reactNative57WixFork") || names.contains("reactNative57_5")) {
                            setIgnore(true)
                        }
                    }
                }
            }
        }
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

dependencies {
    implementation project(':appcenter-analytics')
    implementation project(':react-native-geolocation-service')
    implementation project(':react-native-push-notification')
    implementation project(':appcenter-crashes')
    implementation project(':appcenter')
    implementation project(':react-native-maps')
    implementation project(':react-native-code-push')
    implementation(project(':stripe_stripe-react-native')) { exclude module: 'appcompat' }
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'com.google.firebase:firebase-bom:28.3.1'
    implementation 'com.google.firebase:firebase-analytics:19.0.0'
    implementation "com.google.android.material:material:1.4.0"
    implementation "com.google.android.gms:play-services-maps:18.0.0"
    implementation "com.google.android.gms:play-services-gcm:17.0.0"
    implementation 'com.google.android.gms:play-services-location:18.0.0'
    implementation 'com.google.android.gms:play-services-places:17.0.0'
    implementation 'io.intercom.android:intercom-sdk:10.6.0'
    implementation 'com.facebook.fresco:fresco:2.5.0'
    implementation 'com.facebook.fresco:animated-gif:2.5.0'
    implementation "androidx.multidex:multidex:2.0.1"
    implementation "androidx.media:media:1.4.1"
    implementation 'androidx.annotation:annotation:1.2.0'
    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
    implementation ("androidx.appcompat:appcompat:1.3.1") { version { strictly '1.3.1' } }
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.squareup.okhttp3', module:'okhttp'
      exclude group:'com.facebook.yoga'
      exclude group:'com.facebook.litho', module: 'litho-annotations'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
      exclude group:'com.squareup.okhttp3', module:'okhttp'
      exclude group:'com.facebook.yoga'
      exclude group:'com.facebook.litho', module: 'litho-annotations'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
      exclude group:'com.squareup.okhttp3', module:'okhttp'
      exclude group:'com.facebook.yoga'
      exclude group:'com.facebook.litho', module: 'litho-annotations'
    }

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

allprojects {
    repositories {
        //start here
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
            }
        }
        //end
        // NOTE: Installation instructions for old intercom package needed this. Not
        // sure if it is needed by anything else so just commented it out.
        //  maven {
        //     url "https://maven.google.com"
        // }
    }
}

googleServices { disableVersionCheck = true }
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
gabriellend commented 1 year ago

@gabriellend hi, just curious, how's you system running with 107 mb only?

@lovelytingy I'm sorry, I have no idea!

cortinico commented 1 year ago

You do have 3 buildTypes, debug and release which are standard and another one called releaseStaging that you added here:

    buildTypes {
        releaseStaging {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
            buildConfigField "String", "CODEPUSH_KEY", MYAPP_STAGING_CODE_PUSH_KEY
            debuggable false
            matchingFallbacks = ['release', 'debug']
            manifestPlaceholders = [isDebug:false]
        }

I'm not sure why you added it, but I would advise against adding custom buildTypes unless you know what you're doing.

Anyway you can solve this build failures by creating a file in android/app/src/releaseStaging/java/com/rndiffapp/ReactNativeFlipper.java by copying the content of the one you have inside android/app/src/release.

gabriellend commented 1 year ago

@cortinico Ah ok, this is legacy code from people who knew what they were doing lol. It's the option I was taught to choose when creating a debug apk. So, maybe I should copy the contents of android/app/src/debug/... instead? I thank you for your eagle eye and I'll go experiment with this newfound knowledge.

gabriellend commented 1 year ago

Aaah, I was wrong, it did not finish building using the same ReactNativeFlipper.java as in the debug folder, but it did build using the one in release. I haven't tested running the apk yet, but this definitely solved my issue. Thank you again!

lovely-indiit commented 7 months ago

@gabriellend hi, just curious, how's you system running with 107 mb only?

hi @gabriellend I know it's late, but actually the 107 mb is leftover memory. All other memory has been utilized already.

Shubham-AppRely commented 5 months ago

@gabriellend sorry this is not the answer but, I'm also facing kinda same issue @cortinico

I'm getting this error:

"Task :app:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5/userguide/command_line_interface.html#sec:command_line_warnings

Execution optimizations have been disabled for 35 invalid unit(s) of work during this build to ensure correctness. Please consult deprecation warnings for more details. 496 actionable tasks: 41 executed, 455 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

Note: F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\node_modules\@react-native-async-storage\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\node_modules\@react-native-async-storage\async-storage\android\src\javaPackage\java\com\reactnativecommunity\asyncstorage\AsyncStoragePackage.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\node_modules\@react-native-async-storage\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\node_modules\@react-native-async-storage\async-storage\android\src\javaPackage\java\com\reactnativecommunity\asyncstorage\AsyncStoragePackage.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\node_modules\@react-native-camera-roll\camera-roll\android\src\main\java\com\reactnativecommunity\cameraroll\CameraRollModule.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\node_modules\@react-native-camera-roll\camera-roll\android\src\main\java\com\reactnativecommunity\cameraroll\CameraRollPackage.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\node_modules\@react-native-async-storage\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\node_modules\@react-native-async-storage\async-storage\android\src\javaPackage\java\com\reactnativecommunity\asyncstorage\AsyncStoragePackage.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\node_modules\@react-native-camera-roll\camera-roll\android\src\main\java\com\reactnativecommunity\cameraroll\CameraRollModule.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\node_modules\@react-native-camera-roll\camera-roll\android\src\main\java\com\reactnativecommunity\cameraroll\CameraRollPackage.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\android\app\src\main\java\com\traffic\user\MainApplication.java:14: error: cannot find symbol import com.facebook.react.ReactNativeFlipper; ^ symbol: class ReactNativeFlipper location: package com.facebook.react F:\Local Disc E data\snup-duplicate-ua-firebase\snup-duplicate-ua\android\app\src\main\java\com\traffic\user\MainApplication.java:51: error: method does not override or implement a method from a supertype @Override ^ 2 errors

FAILURE: Build failed with an exception.

BUILD FAILED in 34s error Failed to install the app. info Run CLI with --verbose flag for more details."

I have 3 paths in android\app\src i.e. debug, main & release & this is my MainApplication.java file from main & in debug & release I have file named ReactNativeFlipper.java:

`package com.somosgtc.userapp;

import android.app.Application; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; import com.facebook.react.defaults.DefaultReactNativeHost; import com.reactnativecommunity.cameraroll.CameraRollPackage; import com.facebook.soloader.SoLoader; import com.rnfs.RNFSPackage; import java.util.List; import com.facebook.react.ReactNativeFlipper; import com.facebook.react.ReactInstanceManager;

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; }

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Manually added packages
      packages.add(new RNFSPackage());
      packages.add(new CameraRollPackage());
      return packages;
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }

    @Override
    protected boolean isNewArchEnabled() {
      return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
    }

    @Override
    protected Boolean isHermesEnabled() {
      return BuildConfig.IS_HERMES_ENABLED;
    }

    @Override
    public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
    }
  };

@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }

@Override public void onCreate() { super.onCreate(); SoLoader.init(this, / native exopackage / false);

if (BuildConfig.DEBUG) {
  ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}

} } `

I've used this same in my release & debug files & this is my android\build.gradle file:

`// Top-level build file where you can add configuration options common to all sub-projects/modules. def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()) buildscript { ext { // buildToolsVersion = '34.0.0' // minSdkVersion = 29 // compileSdkVersion = 34 // targetSdkVersion = 34 // ndkVersion = "23.1.7779620" // googlePlayServicesVersion = "17.0.0" // kotlinVersion = "1.6.21" buildToolsVersion = "33.0.0" minSdkVersion = 21 compileSdkVersion = 33 targetSdkVersion = 33 kotlinVersion = "1.8.0" googlePlayServicesVersion = "17.0.0" ndkVersion = "23.1.7779620" } repositories { google() mavenCentral() } dependencies { classpath("com.android.tools.build:gradle:7.0.4") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") classpath("com.facebook.react:react-native-gradle-plugin") classpath("com.google.gms:google-services:4.3.4") classpath("com.google.firebase:firebase-crashlytics-gradle:2.2.0") classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1" } }

allprojects { repositories { mavenLocal() mavenCentral() google() maven { url 'https://www.jitpack.io' } } }

subprojects { if (project['name'] == 'react-native-reanimated') { project.configurations { compile { } } } project.configurations.all { resolutionStrategy { force 'com.facebook.soloader:soloader:0.10.1' } } }

configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'androidx.core' && details.requested.name == 'core') { details.useVersion '1.13.0' } } } & this is android\app\build.gradle: apply plugin: "com.android.application" apply plugin: 'com.facebook.react' apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics'

react { // Configuration block for React Native, usually no changes needed }

def enableProguardInReleaseBuilds = false def jscFlavor = 'org.webkit:android-jsc:+'

project.ext.react = [ entryFile: "index.js", enableHermes: false, // clean and rebuild if changing ]

project.ext.envConfigFiles = [ debug: ".env", release: ".env.production", ] apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

android { compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } lintOptions { checkReleaseBuilds false abortOnError false warning 'deprecation' warning 'unchecked' } compileSdk 34

namespace "com.somosgtc.userapp"

defaultConfig {
    applicationId "com.somosgtc.userapp"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    // vectorDrawables.useSupportLibrary = truemultidex
    versionCode 42
    versionName "5.1"
    missingDimensionStrategy 'react-native-camera', 'general'
    multiDexEnabled true
}

signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
    release {
        if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
            storeFile file(MYAPP_UPLOAD_STORE_FILE)
            storePassword MYAPP_UPLOAD_STORE_PASSWORD
            keyAlias MYAPP_UPLOAD_KEY_ALIAS
            keyPassword MYAPP_UPLOAD_KEY_PASSWORD
        }
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
        debuggable true
    }
    release {
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        crunchPngs false
    }
}
buildToolsVersion '34.0.0'
ndkVersion '23.1.7779620'

}

dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.core:core-ktx:1.13.0" implementation 'androidx.multidex:multidex:2.0.1' implementation project(':react_native_async_storage') implementation project(':react-native-device-info') implementation project(':react-native-permissions') implementation project(':react-native-camera') implementation project(':react-native-vector-icons') implementation project(':react-native-gesture-handler') implementation project(':react-native-fbsdk') implementation project(':react-native-webview') implementation project(':react-native-fs') implementation project(':react_native_camera_roll') implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02' implementation("com.facebook.react:react-android") implementation project(':react-native-config') implementation 'com.facebook.soloader:soloader:0.10.4' implementation platform('com.google.firebase:firebase-bom:26.1.0') implementation 'com.google.firebase:firebase-analytics' implementation project(':rn-fetch-blob') implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") { because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib") } implementation(project(':react-native-location')) { exclude group: 'androidx.core', module: 'core' }

debugImplementation("com.facebook.flipper:flipper:0.182.0")
debugImplementation("com.facebook.flipper:flipper-network-plugin:0.182.0") {
    exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:0.182.0")
// debugImplementation("com.facebook.flipper:flipper-native-plugin:0.182.0")

if (project.ext.react.get("enableHermes", false)) {
    implementation("com.facebook.react:hermes-android")
} else {
    implementation jscFlavor
}

}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" // apply from: "../../node_modules/react-native-flipper/android/gradle.properties"

afterEvaluate { tasks.matching { it.name == 'packageDebugAssets' }.all { it.dependsOn ":react-native-async-storage:compileDebugShaders" } tasks.matching { it.name == 'compileDebugJavaWithJavac' }.all { dependsOn ':@react-native-async-storage_async-storage:bundleLibCompileToJarDebug' } }

configurations.all { resolutionStrategy { force 'androidx.core:core:1.13.0' // exclude other problematic dependencies if needed } } `,

& this is the npx react-native info :

`System: OS: Windows 11 10.0.22631 CPU: (4) x64 Intel(R) Core(TM) i3-1005G1 CPU @ 1.20GHz Memory: 997.14 MB / 7.79 GB Binaries: Node: version: 16.16.0 path: C:\Program Files\nodejs\node.EXE Yarn: version: 1.22.19 path: C:\Program Files\nodejs\yarn.CMD npm: version: 8.12.1 path: C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: AllowDevelopmentWithoutDevLicense: Enabled Versions:

can someone please help me resolving my issue?