0

I have a react-native app that runs with the react-native run-android command, but when I try to build the signed apk for release, the app crashes on some devices. Here is my build gradle:

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
    applicationId "com.mednetinternal"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    ndk {
      abiFilters "armeabi", "armeabi-v7a", "x86", "arm64-v8a"
    }
}

signingConfigs {
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}

splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk true  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
// 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:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a":3]
        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
        }
    }
}

I tried methods that other strings related to the same or similar questions mentioned, but nothing has worked. Upon extracting the universal apk, I found libimagepipeline.so as the only file in /lib/arm64-v8a, but adding an exclude statement for it in packagingOptions did not work either. Is there some way to make an apk that works on all devices?

The errors I have been getting are:

  1. libgnustl_shared.so is 32-bit instead of 64-bit.
  2. Could not find libreactnativejni.so
Jon Goodwin
  • 9,053
  • 5
  • 35
  • 54
  • Is there any change you had to make from the default configuration? – 10101010 Feb 21 '19 at 14:54
  • Have you read [this](https://stackoverflow.com/questions/40694285/react-native-expection-java-lang-unsatisfiedlinkerror-dlopen-failed-data-dat) ? `android{ ... defaultConfig { .... ndk { abiFilters "armeabi-v7a", "x86", 'armeabi', 'arm64-v8a' } packagingOptions { exclude "lib/arm64-v8a/libgnustl_shared.so" exclude '/lib/mips64/**' exclude '/lib/arm64-v8a/**' exclude '/lib/x86_64/**' } ... } }` – Jon Goodwin Feb 21 '19 at 15:02
  • Yes, I added the ndk block containing the abiFilters – Shreyas Nisal Feb 21 '19 at 16:22
  • Yes, I had read the link you shared before I posted the question, but that hasn't worked for me. I tried adding the the line to exclude `libgnustl_shared.so`, but the app still crashes! – Shreyas Nisal Feb 21 '19 at 16:23
  • try remove arm64-v8a it might solve your problem but you will have an issue to update your app with google – JJ Redikes Aug 29 '19 at 16:07

0 Answers0