From 23f2c88837cd290cdaaaf37f06bd89cc13ee7710 Mon Sep 17 00:00:00 2001 From: creature-water-valley <83949308+creature-water-valley@users.noreply.github.com> Date: Fri, 21 Apr 2023 10:46:32 +0900 Subject: [PATCH] npm run prebuild:prod --- .../SantokuApp/prebuild/prod/android/app/BUCK | 55 ---- .../prebuild/prod/android/app/build.gradle | 309 ++++++------------ .../prebuild/prod/android/app/build_defs.bzl | 19 -- .../mobile/SantokuApp/ReactNativeFlipper.java | 16 +- .../android/app/src/main/AndroidManifest.xml | 2 +- .../fintan/mobile/SantokuApp/AppActivity.java | 41 +-- .../mobile/SantokuApp/MainApplication.java | 100 ++---- .../MainApplicationReactNativeHost.java | 117 ------- .../components/MainComponentsRegistry.java | 36 -- ...ApplicationTurboModuleManagerDelegate.java | 48 --- .../android/app/src/main/jni/CMakeLists.txt | 7 - .../jni/MainApplicationModuleProvider.cpp | 32 -- .../main/jni/MainApplicationModuleProvider.h | 16 - ...nApplicationTurboModuleManagerDelegate.cpp | 45 --- ...ainApplicationTurboModuleManagerDelegate.h | 38 --- .../src/main/jni/MainComponentsRegistry.cpp | 65 ---- .../app/src/main/jni/MainComponentsRegistry.h | 32 -- .../prod/android/app/src/main/jni/OnLoad.cpp | 11 - .../mobile/SantokuApp/ReactNativeFlipper.java | 20 ++ .../prebuild/prod/android/build.gradle | 37 +-- .../prebuild/prod/android/gradle.properties | 2 +- .../prebuild/prod/android/settings.gradle | 7 - .../SantokuApp/prebuild/prod/ios/Podfile | 39 ++- .../prebuild/prod/ios/Podfile.properties.json | 2 +- .../ios/SantokuApp.xcodeproj/project.pbxproj | 58 ++-- .../prod/ios/SantokuApp/AppDelegate.h | 6 +- .../prod/ios/SantokuApp/AppDelegate.mm | 127 +------ .../prod/ios/SantokuApp/Supporting/Expo.plist | 2 +- 28 files changed, 262 insertions(+), 1027 deletions(-) delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/BUCK delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/build_defs.bzl delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/java/jp/fintan/mobile/SantokuApp/newarchitecture/MainApplicationReactNativeHost.java delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/java/jp/fintan/mobile/SantokuApp/newarchitecture/components/MainComponentsRegistry.java delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/java/jp/fintan/mobile/SantokuApp/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/jni/CMakeLists.txt delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/jni/MainApplicationModuleProvider.cpp delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/jni/MainApplicationModuleProvider.h delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/jni/MainComponentsRegistry.cpp delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/jni/MainComponentsRegistry.h delete mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/main/jni/OnLoad.cpp create mode 100644 example-app/SantokuApp/prebuild/prod/android/app/src/release/java/jp/fintan/mobile/SantokuApp/ReactNativeFlipper.java diff --git a/example-app/SantokuApp/prebuild/prod/android/app/BUCK b/example-app/SantokuApp/prebuild/prod/android/app/BUCK deleted file mode 100644 index 42c6527ea1..0000000000 --- a/example-app/SantokuApp/prebuild/prod/android/app/BUCK +++ /dev/null @@ -1,55 +0,0 @@ -# To learn about Buck see [Docs](https://buckbuild.com/). -# To run your application with Buck: -# - install Buck -# - `npm start` - to start the packager -# - `cd android` -# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` -# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck -# - `buck install -r android/app` - compile, install and run application -# - -load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") - -lib_deps = [] - -create_aar_targets(glob(["libs/*.aar"])) - -create_jar_targets(glob(["libs/*.jar"])) - -android_library( - name = "all-libs", - exported_deps = lib_deps, -) - -android_library( - name = "app-code", - srcs = glob([ - "src/main/java/**/*.java", - ]), - deps = [ - ":all-libs", - ":build_config", - ":res", - ], -) - -android_build_config( - name = "build_config", - package = "jp.fintan.mobile.SantokuApp", -) - -android_resource( - name = "res", - package = "jp.fintan.mobile.SantokuApp", - res = "src/main/res", -) - -android_binary( - name = "app", - keystore = "//android/keystores:debug", - manifest = "src/main/AndroidManifest.xml", - package_type = "debug", - deps = [ - ":app-code", - ], -) diff --git a/example-app/SantokuApp/prebuild/prod/android/app/build.gradle b/example-app/SantokuApp/prebuild/prod/android/app/build.gradle index cb9ada6694..97d851017d 100644 --- a/example-app/SantokuApp/prebuild/prod/android/app/build.gradle +++ b/example-app/SantokuApp/prebuild/prod/android/app/build.gradle @@ -4,137 +4,109 @@ plugins { apply plugin: "com.android.application" apply plugin: "com.google.gms.google-services" apply plugin: "com.google.firebase.crashlytics" +apply plugin: "com.facebook.react" import com.android.build.OutputFile -/** - * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets - * and bundleReleaseJsAndAssets). - * These basically call `react-native bundle` with the correct arguments during the Android build - * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the - * bundle directly from the development server. Below you can see all the possible configurations - * and their defaults. If you decide to add a configuration block, make sure to add it before the - * `apply from: "../../node_modules/react-native/react.gradle"` line. - * - * project.ext.react = [ - * // the name of the generated asset file containing your JS bundle - * bundleAssetName: "index.android.bundle", - * - * // the entry file for bundle generation. If none specified and - * // "index.android.js" exists, it will be used. Otherwise "index.js" is - * // default. Can be overridden with ENTRY_FILE environment variable. - * entryFile: "index.android.js", - * - * // https://reactnative.dev/docs/performance#enable-the-ram-format - * bundleCommand: "ram-bundle", - * - * // whether to bundle JS and assets in debug mode - * bundleInDebug: false, - * - * // whether to bundle JS and assets in release mode - * bundleInRelease: true, - * - * // whether to bundle JS and assets in another build variant (if configured). - * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants - * // The configuration property can be in the following formats - * // 'bundleIn${productFlavor}${buildType}' - * // 'bundleIn${buildType}' - * // bundleInFreeDebug: true, - * // bundleInPaidRelease: true, - * // bundleInBeta: true, - * - * // whether to disable dev mode in custom build variants (by default only disabled in release) - * // for example: to disable dev mode in the staging build type (if configured) - * devDisabledInStaging: true, - * // The configuration property can be in the following formats - * // 'devDisabledIn${productFlavor}${buildType}' - * // 'devDisabledIn${buildType}' - * - * // the root of your project, i.e. where "package.json" lives - * root: "../../", - * - * // where to put the JS bundle asset in debug mode - * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", - * - * // where to put the JS bundle asset in release mode - * jsBundleDirRelease: "$buildDir/intermediates/assets/release", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in debug mode - * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in release mode - * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", - * - * // by default the gradle tasks are skipped if none of the JS files or assets change; this means - * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to - * // date; if you have any other folders that you want to ignore for performance reasons (gradle - * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ - * // for example, you might want to remove it from here. - * inputExcludes: ["android/**", "ios/**"], - * - * // override which node gets called and with what additional arguments - * nodeExecutableAndArgs: ["node"], - * - * // supply additional arguments to the packager - * extraPackagerArgs: [] - * ] - */ - def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath() +def expoDebuggableVariants = ['debug'] +// Override `debuggableVariants` for expo-updates debugging +if (System.getenv('EX_UPDATES_NATIVE_DEBUG') == "1") { + react { + expoDebuggableVariants = [] + } +} -def reactNativeRoot = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() -project.ext.react = [ - entryFile: ["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android"].execute(null, rootDir).text.trim(), - enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes", - hermesCommand: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc", - cliPath: "${reactNativeRoot}/cli.js", - composeSourceMapsPath: "${reactNativeRoot}/scripts/compose-source-maps.js", -] +/** + * 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 { + entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim()) + reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile() + hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc" + debuggableVariants = expoDebuggableVariants + + /* 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 from: new File(reactNativeRoot, "react.gradle") +// Override `hermesEnabled` by `expo.jsEngine` +ext { + hermesEnabled = (findProperty('expo.jsEngine') ?: "hermes") == "hermes" +} /** - * Set this to true to create two separate APKs instead of one: - * - An APK that only works on ARM devices - * - An APK that only works on x86 devices - * The advantage is the size of the APK is reduced by about 4MB. - * Upload all the APKs to the Play Store and people will download - * the correct one based on the CPU architecture of their device. + * 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 /** - * Run Proguard to shrink the Java bytecode in release builds. + * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInReleaseBuilds') ?: false).toBoolean() /** - * The preferred build flavor of JavaScriptCore. + * 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 + * 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:+' /** - * Whether to enable the Hermes VM. - * - * This should be set on project.ext.react and that value will be read here. If it is not set - * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode - * and the benefits of using Hermes will therefore be sharply reduced. - */ -def enableHermes = project.ext.react.get("enableHermes", false); - -/** - * Architectures to build native code for. + * 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") @@ -146,72 +118,13 @@ android { compileSdkVersion rootProject.ext.compileSdkVersion + namespace 'jp.fintan.mobile.SantokuApp' defaultConfig { applicationId 'jp.fintan.mobile.SantokuApp' minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 4 versionName "0.1.0" - buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() - - if (isNewArchitectureEnabled()) { - // We configure the CMake build only if you decide to opt-in for the New Architecture. - externalNativeBuild { - cmake { - arguments "-DPROJECT_BUILD_DIR=$buildDir", - "-DREACT_ANDROID_DIR=${reactNativeRoot}/ReactAndroid", - "-DREACT_ANDROID_BUILD_DIR=${reactNativeRoot}/ReactAndroid/build", - "-DNODE_MODULES_DIR=$rootDir/../node_modules", - "-DANDROID_STL=c++_shared" - } - } - if (!enableSeparateBuildPerCPUArchitecture) { - ndk { - abiFilters (*reactNativeArchitectures()) - } - } - } - } - - if (isNewArchitectureEnabled()) { - // We configure the CMake build only if you decide to opt-in for the New Architecture. - externalNativeBuild { - cmake { - path "$projectDir/src/main/jni/CMakeLists.txt" - } - } - def reactAndroidProjectDir = project(':ReactAndroid').projectDir - def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) { - dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck") - from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") - into("$buildDir/react-ndk/exported") - } - def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) { - dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck") - from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") - into("$buildDir/react-ndk/exported") - } - afterEvaluate { - // If you wish to add a custom TurboModule or component locally, - // you should uncomment this line. - // preBuild.dependsOn("generateCodegenArtifactsFromSchema") - preDebugBuild.dependsOn(packageReactNdkDebugLibs) - preReleaseBuild.dependsOn(packageReactNdkReleaseLibs) - - // Due to a bug inside AGP, we have to explicitly set a dependency - // between configureCMakeDebug* tasks and the preBuild tasks. - // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732 - configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild) - configureCMakeDebug.dependsOn(preDebugBuild) - reactNativeArchitectures().each { architecture -> - tasks.findByName("configureCMakeDebug[${architecture}]")?.configure { - dependsOn("preDebugBuild") - } - tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure { - dependsOn("preReleaseBuild") - } - } - } } splits { @@ -253,6 +166,7 @@ android { nativeSymbolUploadEnabled true unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib' } + shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false) minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } @@ -263,11 +177,12 @@ android { 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(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = - versionCodes.get(abi) * 1048576 + defaultConfig.versionCode + defaultConfig.versionCode * 1000 + versionCodes.get(abi) } } @@ -295,10 +210,8 @@ android { } dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) - - //noinspection GradleDynamicVersion - implementation "com.facebook.react:react-native:+" // From node_modules + // The version of react-native is set by the React Native Gradle Plugin + implementation("com.facebook.react:react-android") def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true"; def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true"; @@ -307,80 +220,42 @@ dependencies { // If your app supports Android versions before Ice Cream Sandwich (API level 14) if (isGifEnabled || isWebpEnabled) { - implementation "com.facebook.fresco:fresco:${frescoVersion}" - implementation "com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}" + implementation("com.facebook.fresco:fresco:${frescoVersion}") + implementation("com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}") } if (isGifEnabled) { // For animated gif support - implementation "com.facebook.fresco:animated-gif:${frescoVersion}" + implementation("com.facebook.fresco:animated-gif:${frescoVersion}") } if (isWebpEnabled) { // For webp support - implementation "com.facebook.fresco:webpsupport:${frescoVersion}" + implementation("com.facebook.fresco:webpsupport:${frescoVersion}") if (isWebpAnimatedEnabled) { // Animated webp support - implementation "com.facebook.fresco:animated-webp:${frescoVersion}" + implementation("com.facebook.fresco:animated-webp:${frescoVersion}") } } - implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" - debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { - exclude group:'com.facebook.fbjni' - } + implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0") + + debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { - exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } - debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { - exclude group:'com.facebook.flipper' - } + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") - if (enableHermes) { - //noinspection GradleDynamicVersion - implementation("com.facebook.react:hermes-engine:+") { // From node_modules - exclude group:'com.facebook.fbjni' - } + if (hermesEnabled.toBoolean()) { + implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } } -if (isNewArchitectureEnabled()) { - // If new architecture is enabled, we let you build RN from source - // Otherwise we fallback to a prebuilt .aar bundled in the NPM package. - // This will be applied to all the imported transtitive dependency. - configurations.all { - resolutionStrategy.dependencySubstitution { - substitute(module("com.facebook.react:react-native")) - .using(project(":ReactAndroid")) - .because("On New Architecture we're building React Native from source") - substitute(module("com.facebook.react:hermes-engine")) - .using(project(":ReactAndroid:hermes-engine")) - .because("On New Architecture we're building Hermes from source") - } - } -} - -// Run this once to be able to run the application with BUCK -// puts all compile dependencies into folder libs for BUCK to use -task copyDownloadableDepsToLibs(type: Copy) { - from configurations.implementation - into 'libs' -} - apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle"); applyNativeModulesAppBuildGradle(project) -def isNewArchitectureEnabled() { - // To opt-in for the New Architecture, you can either: - // - Set `newArchEnabled` to true inside the `gradle.properties` file - // - Invoke gradle with `-newArchEnabled=true` - // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` - return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" -} - licenseReport { generateCsvReport = false diff --git a/example-app/SantokuApp/prebuild/prod/android/app/build_defs.bzl b/example-app/SantokuApp/prebuild/prod/android/app/build_defs.bzl deleted file mode 100644 index fff270f8d1..0000000000 --- a/example-app/SantokuApp/prebuild/prod/android/app/build_defs.bzl +++ /dev/null @@ -1,19 +0,0 @@ -"""Helper definitions to glob .aar and .jar targets""" - -def create_aar_targets(aarfiles): - for aarfile in aarfiles: - name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] - lib_deps.append(":" + name) - android_prebuilt_aar( - name = name, - aar = aarfile, - ) - -def create_jar_targets(jarfiles): - for jarfile in jarfiles: - name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] - lib_deps.append(":" + name) - prebuilt_jar( - name = name, - binary_jar = jarfile, - ) diff --git a/example-app/SantokuApp/prebuild/prod/android/app/src/debug/java/jp/fintan/mobile/SantokuApp/ReactNativeFlipper.java b/example-app/SantokuApp/prebuild/prod/android/app/src/debug/java/jp/fintan/mobile/SantokuApp/ReactNativeFlipper.java index d339333ded..97199d729d 100644 --- a/example-app/SantokuApp/prebuild/prod/android/app/src/debug/java/jp/fintan/mobile/SantokuApp/ReactNativeFlipper.java +++ b/example-app/SantokuApp/prebuild/prod/android/app/src/debug/java/jp/fintan/mobile/SantokuApp/ReactNativeFlipper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * *
This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
@@ -17,22 +17,27 @@
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
-import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
+import com.facebook.react.ReactInstanceEventListener;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.network.NetworkingModule;
import okhttp3.OkHttpClient;
+/**
+ * Class responsible of loading Flipper inside your React Native application. This is the debug
+ * flavor of it. Here you can add your own plugins and customize the Flipper setup.
+ */
public class ReactNativeFlipper {
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (FlipperUtils.shouldEnableFlipper(context)) {
final FlipperClient client = AndroidFlipperClient.getInstance(context);
+
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
- client.addPlugin(new ReactFlipperPlugin());
client.addPlugin(new DatabasesFlipperPlugin(context));
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
client.addPlugin(CrashReporterPlugin.getInstance());
+
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
NetworkingModule.setCustomClientBuilder(
new NetworkingModule.CustomClientBuilder() {
@@ -43,12 +48,13 @@ public void apply(OkHttpClient.Builder builder) {
});
client.addPlugin(networkFlipperPlugin);
client.start();
+
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
// Hence we run if after all native modules have been initialized
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext == null) {
reactInstanceManager.addReactInstanceEventListener(
- new ReactInstanceManager.ReactInstanceEventListener() {
+ new ReactInstanceEventListener() {
@Override
public void onReactContextInitialized(ReactContext reactContext) {
reactInstanceManager.removeReactInstanceEventListener(this);
@@ -66,4 +72,4 @@ public void run() {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/example-app/SantokuApp/prebuild/prod/android/app/src/main/AndroidManifest.xml b/example-app/SantokuApp/prebuild/prod/android/app/src/main/AndroidManifest.xml
index a7918b74f9..29a4e5628b 100644
--- a/example-app/SantokuApp/prebuild/prod/android/app/src/main/AndroidManifest.xml
+++ b/example-app/SantokuApp/prebuild/prod/android/app/src/main/AndroidManifest.xml
@@ -15,7 +15,7 @@
Please note that this class is used ONLY if you opt-in for the New Architecture (see the
- * `newArchEnabled` property). Is ignored otherwise.
- */
-public class MainApplicationReactNativeHost extends ReactNativeHost {
- public MainApplicationReactNativeHost(Application application) {
- super(application);
- }
-
- @Override
- public boolean getUseDeveloperSupport() {
- return BuildConfig.DEBUG;
- }
-
- @Override
- protected List Please note that this class is used ONLY if you opt-in for the New Architecture (see the
- * `newArchEnabled` property). Is ignored otherwise.
- */
-@DoNotStrip
-public class MainComponentsRegistry {
- static {
- SoLoader.loadLibrary("fabricjni");
- }
-
- @DoNotStrip private final HybridData mHybridData;
-
- @DoNotStrip
- private native HybridData initHybrid(ComponentFactory componentFactory);
-
- @DoNotStrip
- private MainComponentsRegistry(ComponentFactory componentFactory) {
- mHybridData = initHybrid(componentFactory);
- }
-
- @DoNotStrip
- public static MainComponentsRegistry register(ComponentFactory componentFactory) {
- return new MainComponentsRegistry(componentFactory);
- }
-}
diff --git a/example-app/SantokuApp/prebuild/prod/android/app/src/main/java/jp/fintan/mobile/SantokuApp/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java b/example-app/SantokuApp/prebuild/prod/android/app/src/main/java/jp/fintan/mobile/SantokuApp/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java
deleted file mode 100644
index 7a63b241ea..0000000000
--- a/example-app/SantokuApp/prebuild/prod/android/app/src/main/java/jp/fintan/mobile/SantokuApp/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package jp.fintan.mobile.SantokuApp.newarchitecture.modules;
-
-import com.facebook.jni.HybridData;
-import com.facebook.react.ReactPackage;
-import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.soloader.SoLoader;
-import java.util.List;
-
-/**
- * Class responsible to load the TurboModules. This class has native methods and needs a
- * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
- * folder for you).
- *
- * Please note that this class is used ONLY if you opt-in for the New Architecture (see the
- * `newArchEnabled` property). Is ignored otherwise.
- */
-public class MainApplicationTurboModuleManagerDelegate
- extends ReactPackageTurboModuleManagerDelegate {
-
- private static volatile boolean sIsSoLibraryLoaded;
-
- protected MainApplicationTurboModuleManagerDelegate(
- ReactApplicationContext reactApplicationContext, List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
+ */
+package jp.fintan.mobile.SantokuApp;
+
+import android.content.Context;
+import com.facebook.react.ReactInstanceManager;
+
+/**
+ * Class responsible of loading Flipper inside your React Native application. This is the release
+ * flavor of it so it's empty as we don't want to load Flipper.
+ */
+public class ReactNativeFlipper {
+ public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
+ // Do nothing as we don't want to initialize Flipper on Release.
+ }
+}
diff --git a/example-app/SantokuApp/prebuild/prod/android/build.gradle b/example-app/SantokuApp/prebuild/prod/android/build.gradle
index 8f7700e222..ab877c110a 100644
--- a/example-app/SantokuApp/prebuild/prod/android/build.gradle
+++ b/example-app/SantokuApp/prebuild/prod/android/build.gradle
@@ -2,22 +2,17 @@
buildscript {
ext {
- buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
+ buildToolsVersion = findProperty('android.buildToolsVersion') ?: '33.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
- compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
- targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')
+ compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '33')
+ targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '33')
if (findProperty('android.kotlinVersion')) {
kotlinVersion = findProperty('android.kotlinVersion')
}
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
- if (System.properties['os.arch'] == 'aarch64') {
- // For M1 Users we need to use the NDK 24 which added support for aarch64
- ndkVersion = '24.0.8215888'
- } else {
- // Otherwise we default to the side-by-side NDK version from AGP.
- ndkVersion = '21.4.7075529'
- }
+ // 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()
@@ -26,25 +21,13 @@ buildscript {
dependencies {
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
classpath 'com.google.gms:google-services:4.3.3'
- classpath('com.android.tools.build:gradle:7.2.1')
+ classpath('com.android.tools.build:gradle:7.4.1')
classpath('com.facebook.react:react-native-gradle-plugin')
- classpath('de.undercouch:gradle-download-task:5.0.1')
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
}
}
-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())
-
allprojects {
- configurations.all {
- resolutionStrategy {
- force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
- }
- }
-
repositories {
- mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
@@ -55,13 +38,7 @@ allprojects {
}
google()
- mavenCentral {
- // We don't want to fetch react-native from Maven Central as there are
- // older versions over there.
- content {
- excludeGroup 'com.facebook.react'
- }
- }
+ mavenCentral()
maven { url 'https://www.jitpack.io' }
}
}
diff --git a/example-app/SantokuApp/prebuild/prod/android/gradle.properties b/example-app/SantokuApp/prebuild/prod/android/gradle.properties
index 68475ab50c..22babe01b8 100644
--- a/example-app/SantokuApp/prebuild/prod/android/gradle.properties
+++ b/example-app/SantokuApp/prebuild/prod/android/gradle.properties
@@ -42,7 +42,7 @@ newArchEnabled=false
# The hosted JavaScript engine
# Supported values: expo.jsEngine = "hermes" | "jsc"
-expo.jsEngine=jsc
+expo.jsEngine=hermes
# Enable GIF support in React Native images (~200 B increase)
expo.gif.enabled=true
diff --git a/example-app/SantokuApp/prebuild/prod/android/settings.gradle b/example-app/SantokuApp/prebuild/prod/android/settings.gradle
index 6333efb0ab..7ce23ca052 100644
--- a/example-app/SantokuApp/prebuild/prod/android/settings.gradle
+++ b/example-app/SantokuApp/prebuild/prod/android/settings.gradle
@@ -8,10 +8,3 @@ applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild(new File(["node", "--print", "require.resolve('react-native-gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile())
-
-if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") {
- include(":ReactAndroid")
- project(":ReactAndroid").projectDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../ReactAndroid");
- include(":ReactAndroid:hermes-engine")
- project(":ReactAndroid:hermes-engine").projectDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../ReactAndroid/hermes-engine");
-}
diff --git a/example-app/SantokuApp/prebuild/prod/ios/Podfile b/example-app/SantokuApp/prebuild/prod/ios/Podfile
index 26b440688c..c353449106 100644
--- a/example-app/SantokuApp/prebuild/prod/ios/Podfile
+++ b/example-app/SantokuApp/prebuild/prod/ios/Podfile
@@ -5,34 +5,63 @@ require File.join(File.dirname(`node --print "require.resolve('@react-native-com
require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}
+ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
+ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = '1' if podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR'] == 'true'
+
platform :ios, podfile_properties['ios.deploymentTarget'] || '13.0'
install! 'cocoapods',
:deterministic_uuids => false
+prepare_react_native_project!
+
+# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
+# because `react-native-flipper` depends on (FlipperKit,...), which will be excluded. To fix this,
+# you can also exclude `react-native-flipper` in `react-native.config.js`
+#
+# ```js
+# module.exports = {
+# dependencies: {
+# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
+# }
+# }
+# ```
+flipper_config = FlipperConfiguration.disabled
+if ENV['NO_FLIPPER'] == '1' then
+ # Explicitly disabled through environment variables
+ flipper_config = FlipperConfiguration.disabled
+elsif podfile_properties.key?('ios.flipper') then
+ # Configure Flipper in Podfile.properties.json
+ if podfile_properties['ios.flipper'] == 'true' then
+ flipper_config = FlipperConfiguration.enabled(["Debug", "Release"])
+ elsif podfile_properties['ios.flipper'] != 'false' then
+ flipper_config = FlipperConfiguration.enabled(["Debug", "Release"], { 'Flipper' => podfile_properties['ios.flipper'] })
+ end
+end
+
target 'SantokuApp' do
use_expo_modules!
config = use_native_modules!
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
+ use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
- :hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes',
+ :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
:fabric_enabled => flags[:fabric_enabled],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/..",
- #
- # Uncomment to opt-in to using Flipper
- # Note that if you have use_frameworks! enabled, Flipper will not work
- # :flipper_configuration => !ENV['CI'] ? FlipperConfiguration.enabled : FlipperConfiguration.disabled,
+ # Note that if you have use_frameworks! enabled, Flipper will not work if enabled
+ :flipper_configuration => flipper_config
)
post_install do |installer|
react_native_post_install(
installer,
+ config[:reactNativePath],
# Set `mac_catalyst_enabled` to `true` in order to apply patches
# necessary for Mac Catalyst builds
:mac_catalyst_enabled => false
diff --git a/example-app/SantokuApp/prebuild/prod/ios/Podfile.properties.json b/example-app/SantokuApp/prebuild/prod/ios/Podfile.properties.json
index 5a6e743184..22161f0eb8 100644
--- a/example-app/SantokuApp/prebuild/prod/ios/Podfile.properties.json
+++ b/example-app/SantokuApp/prebuild/prod/ios/Podfile.properties.json
@@ -1,4 +1,4 @@
{
- "expo.jsEngine": "jsc",
+ "expo.jsEngine": "hermes",
"ios.useFrameworks": "static"
}
diff --git a/example-app/SantokuApp/prebuild/prod/ios/SantokuApp.xcodeproj/project.pbxproj b/example-app/SantokuApp/prebuild/prod/ios/SantokuApp.xcodeproj/project.pbxproj
index d5b0ddcf14..d5171ec5cf 100644
--- a/example-app/SantokuApp/prebuild/prod/ios/SantokuApp.xcodeproj/project.pbxproj
+++ b/example-app/SantokuApp/prebuild/prod/ios/SantokuApp.xcodeproj/project.pbxproj
@@ -14,12 +14,12 @@
96905EF65AED1B983A6B3ABC /* libPods-SantokuApp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58EEBF8E8E6FB1BC6CAF49B5 /* libPods-SantokuApp.a */; };
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */; };
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; };
- F0EB33D5CEB642529CA1A6FB /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F7FAD74748A545DDB629076B /* InfoPlist.strings */; };
- F4763079800D4BE89FE96102 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1822A7FB00D14535AA83E68E /* InfoPlist.strings */; };
- 04856851765747B88885795D /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4FE6816F2685497FB59F127A /* GoogleService-Info.plist */; };
- 8820544EC5044C6EA6136E95 /* noop-file.swift in Sources */ = {isa = PBXBuildFile; fileRef = 690B859CC28B45CA9C7A1321 /* noop-file.swift */; };
- B05AF8C69D9B489BBD406D1B /* RCTThrowErrorModule.h in Resources */ = {isa = PBXBuildFile; fileRef = 9C30268C8FEC40BC8B9B86CF /* RCTThrowErrorModule.h */; };
- 102D990D053C401BA0F8CCF8 /* RCTThrowErrorModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C4C38D42D0348C9BF3A9B3A /* RCTThrowErrorModule.m */; };
+ 96E376B2A92041219ED60834 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = AFFB5479F617407D8B970884 /* InfoPlist.strings */; };
+ 2D0C57E7AFFB431EB2E41F51 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 02987C8EC66849C3A922F99A /* InfoPlist.strings */; };
+ 206D839DE8BC413B8138A052 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5FE293C2047B49A29EEADFD2 /* GoogleService-Info.plist */; };
+ EE70C03FF67F4A5EB5FCB370 /* noop-file.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37955FB710434818A7428481 /* noop-file.swift */; };
+ AF21B20C03294D058329AA55 /* RCTThrowErrorModule.h in Resources */ = {isa = PBXBuildFile; fileRef = 398D0B58CB4A4F088C0597CA /* RCTThrowErrorModule.h */; };
+ 27BCD27079664DD59DB29965 /* RCTThrowErrorModule.m in Sources */ = {isa = PBXBuildFile; fileRef = A463EDB4B7854DA5962CB4FA /* RCTThrowErrorModule.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -37,12 +37,12 @@
BB2F792C24A3F905000567C9 /* Expo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Expo.plist; sourceTree = "