Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native android app working on one mobile but crashing on another mobile (in production through google play store)

I have got android mobile app developed using React Native (not expo). I tested it on emulators (android and IOS) and it is working fine. I then released it to google play. I tested it on 3 devices: 1) One plus one - working fine 2) Samsung S8 - crashes 3) Samsung S7 - crashes

I found the reason why it crashes. Samsung is picking up app-arm64-v8a-release.apk while 1+1 is installing app-armeabi-v7a-release.apk through google play. If i manually download app-armeabi-v7a-release.apk on samsung phone (and not through google play) then the app works fine. Some questions:

1) Is Samsung supposed to download what it is downloading (app-arm64-v8a-release.apk)? 2) If yes (which i think is right) then what could be the issue? How i can debug a production app.

Note: App crashes if i manually install universal apk on 1+1 and Samsung phones.

this is my gradele.build file

def enableSeparateBuildPerCPUArchitecture = true

def enableProguardInReleaseBuilds = true

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

    defaultConfig {
        applicationId "com.bakbakapp.bakbak"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 3
        versionName "3.0"
    }
    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 {
            def isReleaseBuild = false

            gradle.startParameter.taskNames.find {
                if (it ==~ /:app:assemble.*Release/) {
                    isReleaseBuild = true
                    return true // break
                }
                return false // continue
            }
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk true  // If true, also generate a universal APK
            include "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            shrinkResources true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // Map for the version code that gives each ABI a value.
    def abiCodes = ['x86':1, 'x86_64':2, 'armeabi-v7a':3, 'arm64-v8a':4]

    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) { 
                output.versionCodeOverride = abiCodes.get(abi, 0) * 1048576 + defaultConfig.versionCode

            }
        }
    }
}
like image 491
sushil bansal Avatar asked Feb 05 '19 00:02

sushil bansal


People also ask

Can React Native be used for Android app development?

Yes. React Native is a framework for building apps which have Native UI.


1 Answers

As RN as of now only supports 32 bit applications, you will either need to use latest RN version 0.58.3 as

I have successfully used it and test it for 64 bit apps or alternatively you can remove the 64 builds of the app and then playstore will automatically install the 32 bit versions of the app for the users.

For only 32-bit support replace your

include "x86", "x86_64", "armeabi-v7a", "arm64-v8a"

with

include "x86" "armeabi-v7a"

and similarly

def abiCodes = ['x86':1, 'x86_64':2, 'armeabi-v7a':3, 'arm64-v8a':4]

with

def abiCodes = ['x86':1, 'armeabi-v7a':2]

You can track the RN 64 bit issue here

like image 163
warl0ck Avatar answered Oct 14 '22 15:10

warl0ck