Gradlew bundleRelease doesnt generate release apk in react-native

Viewed 42208

I try to get apk of app. I did it before well. However, I tried to use get apk of other app today but it doesnt give me release apk. why ?

I followed these steps : enter link description here

Normally, it takes 2-3 minutes but now it lasts just 3 sec and doesnt generate apk

it says this :

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

8 Answers

I had the same problem. Following command worked for me:

After the ./gradlew bundleRelease command we get a .aab version of our app. To get APK, you should run the app with release version on any device with the below command.

  • Make sure you have connected an android device
  • For the production ready app, firstly you have to remove the previous app from the device

Run this command in your-project/:

react-native run-android --variant=release

Then APK can be found in android/app/build/outputs/apk/release

Hope this helps

Use gradlew bundleRelease to generate an app bundle (.aab file) and gradlew assembleRelease to generate an apk (.apk file). To install a release on your emulator, use react-native run-android --variant=release. I hope this helps

I made a file that called build.sh. When i want to release a new version of android in ReactNative, just type and press sh ./build.sh in terminal.

My shell script in build.sh file:

npx jetify && cd android && ./gradlew clean && ./gradlew assembleRelease && ./gradlew bundleRelease && cd ..

Cutting the long story short the command gradlew bundleRelease is used to generate an .aab file where as the command gradlew assembleRelease is used to generate .apk file so use the command accordingly

You can simply open the Build Variants window on the bottom left hand corner of Android Studio and choose release as the current variant:

enter image description here

The following should solve your issue:

Open Android Studio and select "build bundle(s)" from Build/Build Bundle(s)/Apk(s)

Refer this image

Then, open your console and run

cd android &&  ./gradlew bundleRelease 

from your project's root. You may encounter an error such as

Cannot add task 'wrapper' as a task with that name already exists., because overriding built-in tasks are deprecated in 4.8 and produces an error.

To prevent it, please update your android/build.gradle, as follows:

FROM:

task wrapper(type: Wrapper) {
    gradleVersion = '4.4'    
    distributionUrl = distributionUrl.replace("bin", "all")
}

TO:

wrapper {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

Lastly, don't forget to convert your .aab file to .apk through bundletool in order to test locally your app (exactly as an APK file)

step - 1) ./gradlew bundleRelease

step - 2) react-native run-android --variant=release

Make sure you have connected an android device For the production-ready app, firstly you have to remove the previous app from the device

Related