Jitender Dev
Jitender Dev

Reputation: 6925

Debug and Release apk not working in React Native 0.63.3

enter image description here

I am using below steps to build debug and release apk

  1. cd android && ./gradlew clean && cd ..
  2. cd android && ./gradlew cleanBuildCache && cd ..
  3. npx react-native bundle --platform android --dev true --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res --verbose
  4. cd android && ./gradlew assembleDebug && cd .. or cd android && ./gradlew assembleRelease && cd ..

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

Answers (2)

Mohd Sher Khan
Mohd Sher Khan

Reputation: 1087

there are few steps below:

Goto project directory

//write into terminal

  1. cd android.

//clean by writing this.

2=> ./gradlew clean

//come back to project directory

  1. cd..

//write this complete code to the project directory

  1. 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/

//write into terminal

  1. cd android

// 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

  1. finally find and share from below path.

// 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

Shahanshah Alam
Shahanshah Alam

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

Related Questions