30

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

rnn
  • 2,393
  • 3
  • 21
  • 39
  • 2
    I have the same problem and looking for the answer . Maybe somebody know how to lock all the versions that if there is some update it will be not installed. Come back to the project after 2 weeks and nothing works . – Dzeremix Jun 13 '19 at 11:06
  • It seems there is a new way to upload app on Play store. There is a migration section on official doc https://facebook.github.io/react-native/docs/signed-apk-android.html#migrating-old-android-react-native-apps-to-use-app-signing-by-google-play I have the same issue and will try to migrate soon to check if it works. – elyrico Jun 14 '19 at 12:26
  • Or maybe you should use `./gradlew assembleRelease` – elyrico Jun 15 '19 at 09:52
  • 1
    @hakan Have you able to generate the APK with "./gradlew bundleRelease" command that is there in the React Native document.? I am able to generate .aab file but not the APK file. Can you please tell me how we need to generate the APK file with that command. Note: I was able to generate release APK with "./gradlew assembleRelease" but somehow its not working in android real device or emulator. Please help me on this I stuck over here. – Amar Jul 17 '19 at 15:43
  • Hi @Amar watch this video: [How to generate APK](https://www.youtube.com/watch?v=cws_eQ5LQUk) – rnn Jul 22 '19 at 10:58

9 Answers9

58

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

Enes Öztürk
  • 652
  • 6
  • 9
43

the short answer uses gradlew assembleRelease instead.

not short answer :) The command you are using gradlew bundleRelease builds an android App bundle. read this: Difference between apk (.apk) and app bundle (.aab) and this: https://developer.android.com/guide/app-bundle AAB file is new and not all stores support it.

Navid Farahzadi
  • 681
  • 7
  • 14
Iman Rb
  • 727
  • 5
  • 9
15

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

Chukwuma Nwaugha
  • 575
  • 8
  • 17
6

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

Asad Khan
  • 259
  • 4
  • 7
4

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 ..
Mohammad Goldast
  • 367
  • 2
  • 4
  • 14
1

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

Vaiden
  • 15,728
  • 7
  • 61
  • 91
0

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)

Anton Menshov
  • 2,266
  • 14
  • 34
  • 55
0

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

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 10 '22 at 15:01
0

./gradlew app:bundleRelease Will fix your problem for sure.