Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Building new architecture sources on Windows (NDK Bump) #33627

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ android {
ndkVersion System.getenv("LOCAL_ANDROID_NDK_VERSION")
}

if (ndkVersion == null && ndkPath == null && rootProject.ext.ndkVersion != null) {
ndkVersion rootProject.ext.ndkVersion
}

defaultConfig {
minSdkVersion(21)
targetSdkVersion(31)
Expand Down Expand Up @@ -318,6 +322,14 @@ android {
// This flag will suppress "fcntl(): Bad file descriptor" warnings on local builds.
arguments "--output-sync=none"
}

// Note: On Windows there are limits on number of character in file paths and in command lines
// Ref: https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Path-Length-Limits
// NDK r23+ can handle long file paths. But we are still limited by the command line limit on Windows.
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
arguments "NDK_OUT=${rootProject.projectDir}\\.cxx",
"NDK_APP_SHORT_COMMANDS=true"
}
}
}
ndk {
Expand Down
7 changes: 7 additions & 0 deletions template/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: "com.android.application"

import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os

/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
Expand Down Expand Up @@ -157,6 +158,12 @@ android {
// Make sure this target name is the same you specify inside the
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
targets "helloworld_appmodules"

// Fix for windows limit on number of character in file paths and in command lines
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
arguments "NDK_OUT=${rootProject.projectDir}\\.cxx",
"NDK_APP_SHORT_COMMANDS=true"
}
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion template/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
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 {
Expand All @@ -6,7 +8,15 @@ buildscript {
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// Note: On Windows there are limits on number of character in file paths and command lines
// Ref: https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Path-Length-Limits
// NDK r23+ can handle long file paths. But we are still limited by the command line limit on Windows.
ndkVersion = "23.1.7779620"
} else {
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
Expand Down