-
-
Notifications
You must be signed in to change notification settings - Fork 124
Android Installation
Sanjeev yadav edited this page Sep 17, 2019
·
3 revisions
- clone repo
git clone https://github.com/alexakasanjeev/magento_react_native.git
- cd into the project and run
npm install
- In terminal run
npm start
- In separate terminal run
react-native run-android
If you get this error
Task :react-native-gesture-handler:compileDebugJavaWithJavac magento_react_native/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.java:3: error: package androidx.core.util does not exist import androidx.core.util.Pools;
do this
2.1 run this command
npm uninstall react-native-gesture-handler
2.2 after that run
npm install [email protected]
then try again
- Open terminal pointing to
magento_react_native
folder - Go into android folder by running
cd android/
in terminal - run
keytool -genkeypair -v -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
remember the keystore and key password
- Place the
my-upload-key.keystore
file under theandroid/app
directory in your project folder. - Edit the file
~/.gradle/gradle.properties
orandroid/gradle.properties
, and add the following (replace*****
with the correct keystore password, alias and key password),
MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=*****
MYAPP_UPLOAD_KEY_PASSWORD=*****
- Edit the file
android/app/build.gradle
in your project folder, and add the signing config
...
android {
...
defaultConfig { ... }
signingConfigs {
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}
}
...
- Move out of the android folder in terminal by running
cd ..
- Run command
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
- Important: Delete these files manually if created after step no. 8
android/app/src/main/res/drawable-hdpi/node_modules_reactnavigationstack_lib_module_views_assets_backicon.png
android/app/src/main/res/drawable-mdpi/node_modules_reactnavigationstack_lib_module_views_assets_backicon.png
android/app/src/main/res/drawable-mdpi/node_modules_reactnavigationstack_lib_module_views_assets_backiconmask.png
android/app/src/main/res/drawable-xhdpi/node_modules_reactnavigationstack_lib_module_views_assets_backicon.png
android/app/src/main/res/drawable-xxhdpi/node_modules_reactnavigationstack_lib_module_views_assets_backicon.png
android/app/src/main/res/drawable-xxxhdpi/node_modules_reactnavigationstack_lib_module_views_assets_backicon.png
- Cd into android folder
cd android/
- Generate the release APK by running command
./gradlew bundleRelease
(make sure you are in android folder in terminal) - To test the release build of your app run
cd .. && react-native run-android --variant=release