Skip to content

Commit

Permalink
fixandroid build failing on app center
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Sep 20, 2021
1 parent 7c2d63e commit 118095f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
39 changes: 17 additions & 22 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ android {
defaultConfig {
minSdkVersion getExtOrDefault('minSdkVersion', 16)
targetSdkVersion getExtOrDefault('targetSdkVersion', 28)
ndkVersion "21.1.6352462"

externalNativeBuild {
cmake {
Expand All @@ -38,22 +39,28 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions{
abortOnError false
disable 'GradleCompatible'
}

externalNativeBuild {
cmake {
path "./src/main/rnmmkv/CMakeLists.txt"
version "3.10.2"
}
}

packagingOptions {
excludes = ["**/libc++_shared.so","**/libreactnativeutilsjni.so"]
excludes = ["**/libc++_shared.so"]
}

configurations {
extractHeaders
extractJNI
}
}
Expand All @@ -77,27 +84,11 @@ dependencies {

def rnAAR = fileTree("${rootDir}/../node_modules/react-native/android").matching({ it.include "**/**/*.aar" }).singleFile

def inputFile = new File(rootDir, '../node_modules/react-native/package.json')
def json = new JsonSlurper().parseText(inputFile.text)
def reactNativeVersion = json.version as String
def (major, minor, patch) = reactNativeVersion.tokenize('.')
extractJNI(files(rnAAR))
}

task extractAARHeaders {
doLast {
configurations.extractHeaders.files.each {
def file = it.absoluteFile
copy {
from zipTree(file)
into "$buildDir/$file.name"
include "**/*.h"
}
}
}
}

task extractJNIFiles {

doLast {
configurations.extractJNI.files.each {
def file = it.absoluteFile
Expand All @@ -111,10 +102,14 @@ task extractJNIFiles {
}
}

def hasExtractedJNIFiles = false;

tasks.whenTaskAdded { task ->
if (task.name.contains('externalNativeBuild')) {
task.dependsOn(extractAARHeaders)
task.dependsOn(extractJNIFiles)
if (task.name.contains('generateJsonModel') || task.name.contains('externalNativeBuild')) {
if (!hasExtractedJNIFiles) {
hasExtractedJNIFiles = true;
task.dependsOn(extractJNIFiles)
}
}
}

2 changes: 1 addition & 1 deletion android/src/main/rnmmkv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.9.0)

set (PACKAGE_NAME "rnmmkv")
set (BUILD_DIR ${CMAKE_SOURCE_DIR}/../../../build)
set (BUILD_DIR ../../../build)

add_subdirectory(../../../../MMKV/Core core)

Expand Down

1 comment on commit 118095f

@vercel
Copy link

@vercel vercel bot commented on 118095f Sep 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.