Skip to content

Android Installation

Sanjeev yadav edited this page Sep 17, 2019 · 3 revisions

Clone repo

  1. clone repo git clone https://github.com/alexakasanjeev/magento_react_native.git
  2. cd into the project and run npm install

Run debug build

  1. In terminal run npm start
  2. 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

Run release build

  1. Open terminal pointing to magento_react_native folder
  2. Go into android folder by running cd android/ in terminal
  3. 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

  1. Place the my-upload-key.keystore file under the android/app directory in your project folder.
  2. Edit the file ~/.gradle/gradle.properties or android/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=*****
  1. 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
        }
    }
}
...
  1. Move out of the android folder in terminal by running cd ..
  2. 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
  3. 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
  1. Cd into android folder cd android/
  2. Generate the release APK by running command ./gradlew bundleRelease (make sure you are in android folder in terminal)
  3. To test the release build of your app run cd .. && react-native run-android --variant=release
Clone this wiki locally