Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
34 changes: 10 additions & 24 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -247,25 +247,11 @@ def getNdkBuildName() {
}

def findNdkBuildFullPath() {
// we allow to provide full path to ndk-build tool
if (hasProperty("ndk.command")) {
return property("ndk.command")
}
// or just a path to the containing directory
if (hasProperty("ndk.path")) {
def ndkDir = property("ndk.path")
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}

if (System.getenv("ANDROID_NDK") != null) {
def ndkDir = System.getenv("ANDROID_NDK")
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}

def ndkDir = android.ndkDirectory ? android.ndkDirectory.absolutePath : null

if (ndkDir) {
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
if (System.getenv("ANDROID_HOME") != null) {
def sdkDir = System.getenv("ANDROID_HOME")
def ndkDir = new File(sdkDir, "ndk").getAbsolutePath()
def ndkVersionedDir = new File(ndkDir, project.android.ndkVersion).getAbsolutePath()
return new File(ndkVersionedDir, getNdkBuildName()).getAbsolutePath()
}
return null
}
Expand All @@ -285,15 +271,14 @@ def getNdkBuildFullPath() {
if (ndkBuildFullPath == null) {
throw new GradleScriptException(
"ndk-build binary cannot be found, check if you've set " +
"\$ANDROID_NDK environment variable correctly or if ndk.dir is " +
"setup in local.properties",
"\$ANDROID_HOME environment variable correctly and you have installed the correct NDK version (" +
project.android.ndkVersion + ")",
null)
}
if (!new File(ndkBuildFullPath).canExecute()) {
throw new GradleScriptException(
"ndk-build binary " + ndkBuildFullPath + " doesn't exist or isn't executable.\n" +
"Check that the \$ANDROID_NDK environment variable, or ndk.dir in local.properties, is set correctly.\n" +
"(On Windows, make sure you escape backslashes in local.properties or use forward slashes, e.g. C:\\\\ndk or C:/ndk rather than C:\\ndk)",
"Check that you have installed the correct NDK version (" + project.android.ndkVersion + ")",
null)
}
return ndkBuildFullPath
Expand Down Expand Up @@ -380,7 +365,7 @@ task extractJNIFiles {

android {
compileSdkVersion 29

ndkVersion ndkVersion
compileOptions {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
Expand All @@ -391,6 +376,7 @@ android {
targetSdkVersion(28)
versionCode(1)
versionName("1.0")
ndkVersion "20.1.5948944"

consumerProguardFiles("proguard-rules.pro")

Expand Down
3 changes: 2 additions & 1 deletion packages/rn-tester/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def useIntlJsc = false

android {
compileSdkVersion 29

ndkVersion ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -142,6 +142,7 @@ android {
defaultConfig {
applicationId "com.facebook.react.uiapp"
minSdkVersion 19
ndkVersion "20.1.5948944"
targetSdkVersion 29
versionCode 1
versionName "1.0"
Expand Down