React-native: Unoptimized APK

Created on 6 Jun 2019  Â·  19Comments  Â·  Source: facebook/react-native

React Native version: 0.57.1

Steps To Reproduce

  1. gradlew assembleRelease

Describe what you expected to happen:
I had issue with android, they alert: my app is "Unoptimized APK" and not accept for my app although they still accept prev version my app.

Bug Locked

Most helpful comment

You should just build and upload aab (Android App Bundle) file instead of apk .

cd android
./gradlew bundleRelease
cd ..

aab file will be placed in"/android/app/build/outputs/bundle/release/"

All 19 comments

We have the same problem.

Yes, We are on the same boat :1234:

Google Play is generating and optimizing APKs from your Android App Bundle. This may take a few minutes, depending on the size of your app bundle.

did you try to upload .aab file!?

how create .aab react natice v. expo

gradlew bundleRelease

I m also facing same issue..

I have upgraded RN 0.55.4 => 0.59.9

I have also set

def enableSeparateBuildPerCPUArchitecture = true

def enableProguardInReleaseBuilds = true

```
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}


buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
shrinkResources true
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
```

Here are some snips of my configurations of my project. Any help would be greatly appreciated.

2
3
p
1

I am experiencing the same issue, I am using
"expo": "^33.0.0",
"expo-asset": "^5.0.1",
"expo-constants": "^5.0.1",
"expo-file-system": "^5.0.1",
"expo-font": "^5.0.1",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"react-native-elements": "^1.1.0",
"react-navigation": "^3.11.0",

After expo build:android I got a apk of 19MB, But unable to review and publish in google playstore.
531e10d5fe8ca6e7e4c5538912bd90490f3eba9a_2_690x163
17380331cb142d4d0cf0774b865f61870962f29f_2_690x302

Hello there 👋 this issue doesn't have a repro (which means, a react-native init-ed project with the minimal changes that leads to creating the same issue you are reporting). Unfortunately, I have no way of helping you in a meaningful way – there is no easy way for me to recreate the situation and check that the issue reported is still there when changing the code.

Can anyone look a bit deeper in what causes this error? Maybe in the google play store development portal there may be a doc explaining it?

Because of this, we are going to close this issue - but if a repro is shared, we are happy to reopen it 🤗

I found one solution.
Please reply me if someone interested in this.

@ReactAndrey Could you share the solution to this?

@ReactAndrey Please let us know so we can proceed further.

I found one solution.
Please reply me if someone interested in this.
@ReactAndrey
Could you share the solution to this?

You should just build and upload aab (Android App Bundle) file instead of apk .

cd android
./gradlew bundleRelease
cd ..

aab file will be placed in"/android/app/build/outputs/bundle/release/"

As a follow up to @eai301 and @NazarK (thank you BTW), you MUST opt-in to the Google Managed App Signing, or else it will not accept your .aab file. I had opted-out and couldn't find a way to change my mind, had to delete the app from my dashboard and start over, which was fine since I was just starting.

This whole thing started because my .apk was 'too large' (have a lot of images). Ironically, my .aab file was exactly 30 bytes smaller

31391694 Jul 14 21:09 app-release.apk
31319664 Jul 15 06:32 app.aab

I just created the .aab file using below command
cd android then gradlew bundleRelease

You will find you the .aab file inside android/app/build/outputs/bundle/release
and then I uploaded it in my Google Console account and then that warning disappears so my suggestion is to all who are struggling with this error kindly go with this.

I want to reduce my APK Size
I followed these https://facebook.github.io/react-native/docs/signed-apk-android
and run ./gradlew bundleRelease instead of assembleRelease
But I Got Error

Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
Job failed,

So how can I solve it, I'm Google it but the issue is still!
But without Enable Proguard it's work very well and I got (Aab & .Apk ) SO How To Solve it!

I think the issue with this file but I don't know how to configure that!

proguard-rules.pro


# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

@ReactAndrey Could you share the solution to this?

Hi sorry for late reply. I am busy for some projects.
You can simple do such like this.
Open your app in android studio.
Maybe you have to upgrade android studio version.
And then Build/Generated Signed Bundle on Apk and then you can choose Android App Bundle.
After create aab file you can upload this.

@hosseintoussi problem solved?

@ReactDevs007 I have the same problem, what should I do?

Was this page helpful?
0 / 5 - 0 ratings