Skip to content

appasaheb4/Tutorial_Create-signed-apk-android-and-Release-build-ios-ReactNative

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create-signed-apk-android-and-Release-build-ios-ReactNative

How to create signed apk android and release build ios in react native ?

android/app

sudo keytool -genkey -v -keystore testing.keystore -alias testing -keyalg RSA -keysize 2048 -validity 10000

android/gradle.properties

MYAPP_RELEASE_STORE_FILE=testing.keystore
MYAPP_RELEASE_KEY_ALIAS=testing
MYAPP_RELEASE_STORE_PASSWORD=developer
MYAPP_RELEASE_KEY_PASSWORD=develoepr

android/app/build.gradle

...
android {
...
defaultConfig { ... }

signingConfigs {
release {
storeFile file("testing.keystore")  
 storePassword "developer"
keyAlias "testing"  
 keyPassword "developer"  
 }  
 }

===========> OR <<===============
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
aaptOptions.cruncherEnabled=false // here
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
}
...

==> mkdir -p android/app/src/main/assets
===> 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/

Custom node_modules/react-native/react.gradle to solve the Duplicate file error perfectly. Add following code into currentBundleTask's creation block (after doFirst block)

         doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
        if (originalDir.exists()) {
            File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4")
            ant.move(file: originalDir, tofile: destDir)
        }
    }
    moveFunc.curry("ldpi").call()
    moveFunc.curry("mdpi").call()
    moveFunc.curry("hdpi").call()
    moveFunc.curry("xhdpi").call()
    moveFunc.curry("xxhdpi").call()
    moveFunc.curry("xxxhdpi").call()
}

cd android
./gradlew assembleRelease

About

How to create signed apk android and release build ios in react native ?

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages