Reputation: 6925
I am using below steps to build debug and release apk
The apks are generated successfully. But when i run them i always got this.
However, If i start the metro-server the app works fine but not the debug-apk.
Any help will be appreciated.
Andoid config:
buildToolsVersion = "29.0.2"
minSdkVersion = 23
compileSdkVersion = 29
targetSdkVersion = 29
classpath 'com.google.gms:google-services:4.1.0'
Manifest
<application
android:name=".MainApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
>
app's build.gradle
project.ext.react = [
entryFile: "index.js",
bundleAssetName: "index.android.bundle",
enableHermes: false, // clean and rebuild if changing
devDisabledInDev: true, // Disable dev server in dev release
bundleInDev: true, // add
bundleInDebug: true
]
Thanks
Upvotes: 1
Views: 7868
Reputation: 1087
there are few steps below:
Goto project directory
//write into terminal
//clean by writing this.
2=> ./gradlew clean
//come back to project directory
//write this complete code to the project directory
//write into terminal
// if you want debug(.apk)
6=> ./gradlew assembleDebug
// if you want in release mode(.apk)
6=> ./gradlew assembleRelease
// if you want in Bundle release(.abb)
6=> ./gradle bundleRelease
// for debug
android/app/build/outputs/apk/debug/app-debug.apk
// for release
android/app/build/outputs/apk/release/app-release.apk
// for production
android/app/release/app-release.abb
Upvotes: 0
Reputation: 605
In terminal of your project directory:-
cd android
then ./gradlew clean
then cd ..
then
//to create bundle
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
then
//to create debug build
npx react-native run-android variant=debug
and
//to create release build
npx react-native run-android variant=release
Note :- Make sure you have run npm start
in project root directory before all.
Upvotes: 3