How can I generate an apk that can run without server with react-native?
Following Aditya Singh's answer the generated (unsigned) apk would not install on my phone. I had to generate a signed apk using the instructions here.
The following worked for me:
$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
Place the my-release-key.keystore
file under the android/app
directory in your project folder. Then edit the file~/.gradle/gradle.properties
and add the following (replace ****
with the correct keystore password, alias and key password)
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=****
MYAPP_RELEASE_KEY_PASSWORD=****
If you're using MacOS, you can store your password in the keychain using the instructions here instead of storing it in plaintext.
Then edit app/build.gradle and ensure the following are there (the sections with signingConfigs signingConfig may need to be added) :
...
android {
...
defaultConfig { ... }
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 {
...
signingConfig signingConfigs.release
}
}
}
...
Then run the command cd android && ./gradlew assembleRelease
,
For Windows 'cd android' and then run gradlew assembleRelease
command , and find your signed apk under android/app/build/outputs/apk/app-release.apk
, or android/app/build/outputs/apk/release/app-release.apk
How to generate an apk that works without dev server in react native
After you go through https://facebook.github.io/react-native/docs/signed-apk-android you can simply run
// for build and run
react-native run-android --variant=release
and take apk in
<rn_project_dir>/android/app/build/outputs/apk/release/app-release.apk
Related Topics
Invert Text Color on Mouse Hover
How to Prevent an Http Request Just for a Favicon
How to Save and Restore a File Object in Local Storage
Convert JavaScript-Generated Svg to a File
Add CSS Styled Marker to Google Maps
Generating CSS Media Queries with JavaScript or Jquery
How to Get CSS3 Multi-Column Count in JavaScript
How to Remove Imported CSS in Reactjs
Accessing JavaScript Variable from Ruby
How to Format a Float in JavaScript
When a 'Blur' Event Occurs, How to Find Out Which Element Focus Went *To*
How to Replace All Dots in a String Using JavaScript
Sending Message from a Background Script to a Content Script, Then to a Injected Script
Importing Lodash into Angular2 + Typescript Application
How to Addeventlistener to Multiple Elements in a Single Line
Meteor.Publish: Publish Collection Which Depends on Other Collection
How to Declare Hash.New(0) with 0 Default Value for Counting Objects in JavaScript