Muhammad Saqib Noor
Muhammad Saqib Noor

Reputation: 358

React Native Android app working fine on debug mode but when we are releasing apk it's generating older version of the app

React Native Android app working fine on debug mode but when we are releasing apk it's generating older version of the app.

android/build.gradle:

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 21
        compileSdkVersion = 32
        targetSdkVersion = 32
        googlePlayServicesAuthVersion = "16.0.1"
         kotlin_version='1.6.0' //add This change version with your installed kotlin version

    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
                  
        classpath("com.android.tools.build:gradle:4.0.2")
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" //add This
        classpath 'com.google.gms:google-services:4.3.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

android/grdle/gradle-wrapper.properties

 distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

Upvotes: 3

Views: 733

Answers (1)

Sharif Noor
Sharif Noor

Reputation: 312

-------------- Apk issues resolve after gradle upgrade -----------------

Step-1:

  • Remove android/.gradle folder
  • Remove android/build folder
  • Remove android/app/build folder
  • Remove .jso folder -- If present, it is used to perform obfuscation
  • Remove android/app/src/main/assets/index.android.bundle file

Step-2:

Then we have to create index.android.bundle again for that run the below command.

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 it will create the following files and folders:

  • android/app/src/main/assets/index.android.bundle.
  • android/app/src/main/res/drawable*

Step-3

  • Remove android/app/src/main/res/drawable* folders

Then generate release APK with this command

  • cd android && gradlew assembleRelease

Upvotes: 4

Related Questions