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:
libgnustl_shared.so is 32-bit instead of 64-bit.
Could not find libreactnativejni.so
Related
I have built a release android apk file, conceived for a size of 7.9 MB.
I manage to install it on my android device, but not to open it because it crashes.
When i use flutter run --release it still does not open and detects no errors.
How can I solve that problem?
Thank you for your help.
Note: I have found several questions close to mine, but they have an error or are not entirely similar to mine. As a consequence the solution given do not work on my case.
Here is some of my build.gradle
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.misteref.mykamus"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
in app level build.gradle
set minifyEnabled and shrinkResources to false
or use progaurd if you need this two be true
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
To expand on #Joachim Haglund's comment
update your gradle file with the following. All the builds will then be included in the aab file. (It's also worth checking what SDKs you have installed/require updating with Android Studio)
android {
defaultConfig {
//add the following
ndk {
abiFilters "x86", "x86_64", "armeabi", "armeabi-v7a", "arm64-v8a"
}
}
}
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
}
}
}
}
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
I am working on google-sign-in but getting an error CANCELED and error code is 16.
Steps to Reproduce
I can able to check status for GoogleSignin.hasPlayServices(); and popup open to select account. When choose account it show the error CANCELED code 16.
Expected Behavior
It should return user info.
Actual Behavior
it give error CANCELED code 16.
Environment:
1. android/build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.1.0'
}
2. android/app/build.gradle:
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.pacelogin"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
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]
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
}
}
}
}
dependencies {
implementation (project(':react-native-google-signin')){
exclude group: "com.google.android.gms"
}
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.1.1"
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.google.android.gms:play-services-basement:15.0.1"
}
Update : I have refereed this link
Hey Namrata you first check whether you are generating correct keystore file for your project.
1 . Make sure you give correct password and alias name which you passed to create keystore file.
2. store the keystore file in your(/android/app/) path or you can create folder named keystore and then pase it there.(/android/app/keystore/)
make sure you are specify in which mode you are working. If it is debug mode then use debug section or else use release mode.
signingConfigs {
debug {
storeFile file("../app/YOUR_FILE_NAME.keystore")
storePassword "YOUR_STORE_PASSWORD"
keyAlias "YOUR_ALIAS_NAME"
keyPassword "YOUR_PASSWORD"
}
/* release {
storeFile file("../app/debug.keystore")
storePassword "YOUR_STORE_PASSWORD"
keyAlias "YOUR_ALIAS_NAME"
keyPassword "YOUR_PASSWORD"
}*/
}
Verify the dependencies you are using are correct.
I have developed my application in react native. I want to minify and shrink my code. In order to achieve this I have enabled proguard and added proguard based lines in build.gradle
Here's my code
build.gradle
android {
compileSdkVersion 23
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.mobile"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
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
}
}
}
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
signingConfig signingConfigs.release
// minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
// buildTypes {
// release {
// minifyEnabled enableProguardInReleaseBuilds
// proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
// }
// }
// 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]
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
}
}
}
}
Im getting this error.
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'
Im not sure where its going wrong. Please guide me so that I can resolve this issue.
You probably get some warnings from ProGuard.
Try to enable setting -i when running your gradle build to see the warnings.
You can also test this hypothesis by adding -ignorewarnings to your ProGuard configuration. If the build succeeds afterwards if was due to the mentioned warnings.
Note: you should investigate these warnings and fix them if possible (some are harmless), otherwise your application might contain errors and will not function properly at runtime.
I Want generated build apk but after cd android && ./gradlew assembleRelease build failed.
there my info:
* What went wrong:
Could not list contents of '/Users/sweet/Desktop/phase/ka-
mobile/node_modules/react-native/third-party/glog-0.3.4/test-driver'.
Couldn't follow symbolic link.
i already put my-release-key.keystore under android/app
and change android/app/build.gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.kickavenue"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
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 false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
and change android/gradle.properties or change on ~/.gradle/gradle.properties
android.useDeprecatedNdk=true //only on android/gradle.properties i write
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=sample
MYAPP_RELEASE_KEY_PASSWORD=sample
there is wrong my step to build genereated APK
What version of RN are you using? This issue appears on RN 0.46.3 as stated on React Native's github: https://github.com/facebook/react-native/issues/14464
You could upgrade to React Native 0.47.0 to fix the issue.
Try deleting the .bin folder inside your node_modules