facebook / react-native

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

error: cannot find symbol BuildConfig #37474

Closed rdtf1230 closed 1 year ago

rdtf1230 commented 1 year ago

New Version

0.71.8

Old Version

0.69.7

Build Target(s)

android simulator dev build

Output of react-native info

System: OS: macOS 13.3.1 CPU: (10) arm64 Apple M1 Pro Memory: 820.83 MB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.6.0 - /opt/homebrew/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 9.6.6 - /opt/homebrew/bin/npm Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8815526 Xcode: 14.1/14B47b - /usr/bin/xcodebuild Languages: Java: 11.0.16 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.8 => 0.71.8 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Issue and Reproduction Steps

image image

I faithfully implemented the contents of the upgrade helper, but when I build, an error occurs at that part What should I do?

cortinico commented 1 year ago

Can you share the content of your MainApplication.java file?

rdtf1230 commented 1 year ago

Can you share the content of your MainApplication.java file?

import android.app.Application;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.swmansion.gesturehandler.RNGestureHandlerPackage;
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 java.util.List;
import com.microsoft.codepush.react.CodePush;
import com.facebook.react.bridge.JSIModulePackage;
//import com.swmansion.reanimated.ReanimatedJSIModulePackage;
import org.wonday.orientation.OrientationActivityLifecycle;

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.add(new TmpPackage());
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());
          return packages;
        }

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

//        @Override
//        protected JSIModulePackage getJSIModulePackage() {
//            return new ReanimatedJSIModulePackage();
//        }

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

        @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 void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    registerActivityLifecycleCallbacks(OrientationActivityLifecycle.getInstance());
    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());
  }
}

thanks for the answer! here is the content

cortinico commented 1 year ago

thanks for the answer! here is the content

Thanks. I see you use CodePush, I suspect that might be the root cause of your problem. Can you share your android/app/build.gradle and android/build.gradle files?

rdtf1230 commented 1 year ago

thanks for the answer! here is the content

Thanks. I see you use CodePush, I suspect that might be the root cause of your problem. Can you share your android/app/build.gradle and android/build.gradle files?

here is files

  1. app/build.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"] //}

apply plugin: "com.android.application" apply plugin: "com.facebook.react" apply plugin: "com.google.gms.google-services" apply plugin: "com.google.firebase.crashlytics" apply plugin: "com.google.firebase.firebase-perf" apply plugin: "com.google.firebase.appdistribution"

apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" apply from: "../../node_modules/react-native-code-push/android/codepush.gradle" apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

/**

/**

/**

/**

android { ndkVersion rootProject.ext.ndkVersion compileSdkVersion rootProject.ext.compileSdkVersion

namespace project.env.get("APP_ID")
defaultConfig {
    applicationId project.env.get("APP_ID")
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 88
    versionName "2.6.5"
    multiDexEnabled true
    archivesBaseName = "${applicationId}-v${versionCode}(${versionName})-"
    resValue "string", "build_config_package", "tmp.package.name"
}

splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include (*reactNativeArchitectures())
    }
}
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
    }

    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        firebaseCrashlytics {
            nativeSymbolUploadEnabled true
            unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
        }
    }
}

flavorDimensions "mode"
productFlavors {
    dev {
        dimension "mode"
    }
    prod {
        dimension "mode"
    }
    staging {
        dimension "mode"
    }
}

// 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:
        // https://developer.android.com/studio/build/configure-apk-splits.html
        // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        def abi = output.getFilter(com.android.build.OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    defaultConfig.versionCode * 1000 + versionCodes.get(abi)
        }

// def date = new Date(); // def formattedDate = date.format("yyyyMMddHHmmss"); // outputFileName = project.env.get("APPID") + "-v${variant.versionName}" + "" +project.env.get("MODE") + ".apk" } } }

dependencies { implementation 'com.kakao.sdk:usermgmt:1.17.0' implementation platform('com.google.firebase:firebase-bom:32.0.0') implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-inappmessaging-display'

// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

implementation ("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")

implementation 'com.google.android.play:core:1.10.3'

implementation 'com.facebook.fresco:animated-gif:2.6.0'

implementation 'com.facebook.fresco:animated-webp:2.6.0'
implementation 'com.facebook.fresco:webpsupport:2.6.0'

implementation 'com.facebook.android:facebook-android-sdk:12.3.0'

implementation('com.facebook.soloader:soloader:0.10.3') {
    version {
        strictly '0.10.3'
    }
}

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

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
    implementation("com.facebook.react:hermes-android")
} else {
    implementation jscFlavor
}

}

repositories { mavenCentral() }


2.android/build.gradle

import org.apache.tools.ant.taskdefs.condition.Os

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript { ext { buildToolsVersion = "33.0.0" minSdkVersion = 23 compileSdkVersion = 33 targetSdkVersion = 33 kotlinVersion = "1.6.0" // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. ndkVersion = "23.1.7779620" } repositories { google() mavenCentral() } dependencies { classpath("com.android.tools.build:gradle:7.3.1") classpath("com.facebook.react:react-native-gradle-plugin") classpath("com.google.gms:google-services:4.3.14") classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.2") classpath("com.google.firebase:perf-plugin:1.4.2") classpath("com.google.firebase:firebase-appdistribution-gradle:3.1.0") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") }

subprojects {
    repositories {
        mavenCentral()
        maven {
            url 'http://devrepo.kakao.com:8088/nexus/content/groups/public/'
            allowInsecureProtocol true
        }
    }
}

}

cortinico commented 1 year ago

Your file looks correct. Can you share your package.json file as well?

rdtf1230 commented 1 year ago

Your file looks correct. Can you share your package.json file as well?

Thank you for your continued interest. Here it is.

 "dependencies": {
    "@actbase/react-daum-postcode": "^1.0.4",
    "@amplitude/analytics-react-native": "^1.1.1",
    "@babel/eslint-parser": "^7.19.1",
    "@freakycoder/react-native-bounceable": "^1.0.3",
    "@hookform/resolvers": "^2.9.10",
    "@react-native-async-storage/async-storage": "^1.17.11",
    "@react-native-clipboard/clipboard": "^1.11.1",
    "@react-native-community/blur": "^4.3.0",
    "@react-native-community/datetimepicker": "^6.5.3",
    "@react-native-community/netinfo": "^9.3.6",
    "@react-native-community/push-notification-ios": "^1.10.1",
    "@react-native-firebase/analytics": "^17.4.3",
    "@react-native-firebase/app": "^17.4.3",
    "@react-native-firebase/app-distribution": "^17.4.3",
    "@react-native-firebase/auth": "^17.4.3",
    "@react-native-firebase/crashlytics": "^17.4.3",
    "@react-native-firebase/database": "^17.4.3",
    "@react-native-firebase/dynamic-links": "^17.4.3",
    "@react-native-firebase/in-app-messaging": "^17.4.3",
    "@react-native-firebase/messaging": "^17.4.3",
    "@react-native-firebase/perf": "^17.4.3",
    "@react-native-firebase/remote-config": "^17.4.3",
    "@react-native-picker/picker": "^2.4.8",
    "@react-native-seoul/kakao-login": "^4.2.2",
    "@react-navigation/bottom-tabs": "^6.4.0",
    "@react-navigation/drawer": "^6.5.0",
    "@react-navigation/elements": "^1.3.6",
    "@react-navigation/material-bottom-tabs": "^6.2.4",
    "@react-navigation/material-top-tabs": "^6.3.0",
    "@react-navigation/native": "^6.0.13",
    "@react-navigation/native-stack": "^6.9.1",
    "@react-navigation/stack": "^6.3.3",
    "@types/styled-components-react-native": "^5.1.3",
    "@typescript-eslint/eslint-plugin": "^5.7.0",
    "accordion-collapse-react-native": "^1.1.0",
    "appcenter-cli": "^2.11.0",
    "axios": "^0.24.0",
    "deprecated-react-native-prop-types": "^2.3.0",
    "iamport-react-native": "^2.0.2",
    "install": "^0.13.0",
    "jetifier": "^2.0.0",
    "jssoup": "0.0.15",
    "jwt-decode": "^3.1.2",
    "link-preview-js": "^3.0.4",
    "mixpanel-react-native": "^2.1.0",
    "moment-timezone": "^0.5.33",
    "patch-package": "^6.5.0",
    "postinstall-postinstall": "^2.1.0",
    "prop-types": "^15.8.1",
    "react": "18.2.0",
    "react-content-loader": "^6.1.0",
    "react-hook-form": "^7.38.0",
    "react-native": "0.71.8",
    "react-native-animatable": "^1.3.3",
    "react-native-background-color": "^0.0.8",
    "react-native-blob-util": "^0.16.3",
    "react-native-check-version": "^1.0.16",
    "react-native-code-push": "^8.0.1",
    "react-native-collapsible": "^1.6.0",
    "react-native-config": "^1.4.11",
    "react-native-date-picker": "^4.1.3",
    "react-native-device-info": "^10.3.0",
    "react-native-document-picker": "^8.1.2",
    "react-native-eject": "^0.1.2",
    "react-native-fast-image": "^8.5.11",
    "react-native-fbsdk-next": "^6.2.0",
    "react-native-file-viewer": "^2.1.5",
    "react-native-fs": "^2.20.0",
    "react-native-geolocation-service": "^5.3.1",
    "react-native-gesture-handler": "^2.9.0",
    "react-native-image-picker": "^4.10.0",
    "react-native-image-resizer": "^1.4.5",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-kakao-share-link": "^1.0.6",
    "react-native-keyboard-aware-scrollview": "^2.1.0",
    "react-native-maps": "^1.3.2",
    "react-native-masked-text": "^1.13.0",
    "react-native-material-menu": "^2.0.0",
    "react-native-modal": "^13.0.0",
    "react-native-modal-datetime-picker": "^14.0.0",
    "react-native-month-year-picker": "^1.8.2",
    "react-native-orientation-locker": "^1.5.0",
    "react-native-pager-view": "^6.0.2",
    "react-native-paper": "^4.12.5",
    "react-native-pell-rich-editor": "^1.8.8",
    "react-native-picker-select": "^8.0.4",
    "react-native-poll": "0.1.2",
    "react-native-popup-menu": "^0.16.1",
    "react-native-progress": "^5.0.0",
    "react-native-prompt-android": "^1.1.0",
    "react-native-push-notification": "^8.1.1",
    "react-native-ratings": "^8.1.0",
    "react-native-reanimated": "^3.1.0",
    "react-native-render-html": "^6.3.4",
    "react-native-responsive-dimensions": "^3.1.1",
    "react-native-safe-area-context": "^4.4.1",
    "react-native-scoped-storage": "^1.9.3",
    "react-native-screens": "^3.19.0",
    "react-native-slack-webhook": "^0.0.5",
    "react-native-sms-retriever": "^1.1.1",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-splash-screen": "^3.3.0",
    "react-native-star-rating": "^1.1.0",
    "react-native-status-bar-height": "^2.6.0",
    "react-native-svg": "^13.7.0",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-tab-view": "^3.3.0",
    "react-native-toast-message": "^2.1.5",
    "react-native-uuid": "^2.0.1",
    "react-native-vector-icons": "^9.2.0",
    "react-native-version-check": "^3.4.3",
    "react-native-view-shot": "^3.5.0",
    "react-native-web-swiper": "^2.2.4",
    "react-native-webview": "^11.23.1",
    "react-query": "^3.39.1",
    "recoil": "^0.7.6",
    "sp-react-native-in-app-updates": "^1.2.0",
    "styled-components": "^5.3.6"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native-community/eslint-config": "^3.2.0",
    "@tsconfig/react-native": "^2.0.2",
    "@types/jest": "^29.2.1",
    "@types/react": "^18.0.24",
    "@types/react-native": "^0.66.9",
    "@types/react-native-push-notification": "^8.1.1",
    "@types/react-native-vector-icons": "^6.4.7",
    "@types/react-native-version-check": "^3.4.4",
    "@types/react-test-renderer": "^18.0.0",
    "@types/styled-components": "^5.1.18",
    "@typescript-eslint/parser": "^5.7.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "eslint-plugin-flowtype": "^8.0.3",
    "eslint-scope": "^7.1.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.73.9",
    "miragejs": "^0.1.45",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0",
    "typescript": "4.8.4"
  },
  "jest": {
    "preset": "react-native"
  }
cortinico commented 1 year ago

Thanks for your package.json. It looks fine. We would need a reproducer now as I can't say just by looking at those files what's going on.

github-actions[bot] commented 1 year ago
:warning: Missing Reproducible Example
:information_source: It looks like your issue is missing a reproducible example. Please provide either:
rdtf1230 commented 1 year ago

Thanks for your package.json. It looks fine. We would need a reproducer now as I can't say just by looking at those files what's going on.

Ah... I'm sorry. Unfortunately I can't provide that. I do not own the final ownership of this app, so the information I can provide is limited. I can't upload the contents of the currently commercially available app to the repository at will.

rdtf1230 commented 1 year ago

i found it

the namespace project.env.get("APP_ID") is not work.... Must be specified as a static string to work ;)

btw in react-native-config official doc

defaultConfig {
    ...
    resValue "string", "build_config_package", "YOUR_PACKAGE_NAME_IN_ANDROIDMANIFEST_XML"
}

but react-native-upgrade-helper said image

I don't know if it's okay because the two are talking about different things.

cortinico commented 1 year ago

btw in react-native-config official doc

@rdtf1230 Can you link where the docs are? Those are old and needs to be updated

rdtf1230 commented 1 year ago

btw in react-native-config official doc

@rdtf1230 Can you link where the docs are? Those are old and needs to be updated

https://github.com/luggit/react-native-config scroll down and find section [Advanced Android Setup] there is

cortinico commented 1 year ago

I see. You should reach out to them and ask to update the documentation then

rdtf1230 commented 1 year ago

I see. You should reach out to them and ask to update the documentation then

https://github.com/luggit/react-native-config/issues/736 Someone raised an issue about this already in February. I don't know if the author knows, but seeing that the version of the library was updated last week, it doesn't seem to be a dead library.