Skip to content

Commit

Permalink
Remove the enableSeparateBuildPerCPUArchitecture from the template en…
Browse files Browse the repository at this point in the history
…tirely (facebook#36341)

Summary:
Pull Request resolved: facebook#36341

See react-native-community/discussions-and-proposals#602 for more context.
TL;DR: this flag is used for an edge case. We should not expose it to every users but move it to a guide.

I'll publish a guide on the website on how to achieve the same feature.

Changelog:
[Android] [Changed] - Remove the enableSeparateBuildPerCPUArchitecture from the template entirely

Reviewed By: cipolleschi

Differential Revision: D43695574

fbshipit-source-id: 0a8bc7a169804de41e0b0cf813d184301635b907
  • Loading branch information
cortinico authored and facebook-github-bot committed Mar 1, 2023
1 parent 32931b7 commit 127dc69
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 54 deletions.
10 changes: 1 addition & 9 deletions packages/rn-tester/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ react {
enableHermesOnlyInVariants = ["hermesDebug", "hermesRelease"]
}

/**
* 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 = true

/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
Expand Down Expand Up @@ -146,7 +138,7 @@ android {
}
splits {
abi {
enable enableSeparateBuildPerCPUArchitecture
enable true
universalApk false
reset()
include (*reactNativeArchitectures())
Expand Down
45 changes: 0 additions & 45 deletions template/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
apply plugin: "com.android.application"
apply plugin: "com.facebook.react"

import com.android.build.OutputFile

/**
* 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.
Expand Down Expand Up @@ -52,14 +50,6 @@ react {
// 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.
*/
Expand All @@ -78,16 +68,6 @@ def enableProguardInReleaseBuilds = false
*/
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 {
ndkVersion rootProject.ext.ndkVersion

Expand All @@ -101,15 +81,6 @@ android {
versionCode 1
versionName "1.0"
}

splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include (*reactNativeArchitectures())
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
Expand All @@ -130,22 +101,6 @@ android {
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}

// 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(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}

}
}
}

dependencies {
Expand Down

0 comments on commit 127dc69

Please sign in to comment.