-
Enable debugging over usb --
Settings>About Phone-- TapBuild Numberrow seven times -- Go back one step andDeveloper Optionswill be open [Based on Android variants, it might be on top menu or under additional settings] -- Then fromDeveloper Optionsenable the two items:USB DebuggingInstall apps over USB
-
Install
adbcommand line tools -- For LINUX and MAC -- install it from Android Studio. Go toAndroid SDK Managerfrom settings/preferences. Then open the SDK manager > selectAndroid SDK Platform-toolsandGoogle USB Driverand install them. -- For WINDOWS -- go to here and download the platform tools.- Unzip the downloaded file and select the
adbfile > right click it while clicking on "Shift" button and open with command prompt (or powershell for windows 10) - Or the other way should be install it from Android Studio. Go to
Android SDK Managerfrom settings/preferences. Then open the SDK manager > selectAndroid SDK Platform-toolsandGoogle USB Driverand install them.
- Unzip the downloaded file and select the
-
Plug-in your android device via usb. -- You might need to select
MTPorfile transfer modeon the pop-up that may come [this is dependent on OS version and build] -- Run the commandadb devices. List of device attached will be displayed along with your already used emulators. -
Run the command
react-native run-android -
This will run the debug build to your device
-
In case you have multiple devices connected (or even a device and simulator) you can choose the device to install by the following command
adb -s "deviceID" install path+apkName
- where
deviceIDis the ID you got from theadb devicescommand andpathis<your project folder>/android/app/build/outputs/apk/andapkNameis either ofapp-debug.apkorapp-release.apk
- so example command in this case will be:
adb -s "694d68149804" install /Users/himel/Applications/ReactProjects/carrycut/app/android/app/build/outputs/apk/app-release.apk
- Connect your iOS device via lightning cable to mac
- Go to
<your project folder>/iosand open the.xcodeprojfile in Xcode - From Xcode's
Productmenu chooseDestination. - Your device will be in the list - choose your device and it will be registered for development.
- Register an account in Apple Developer Portal
- Click on the target name (same as project name) on the left column then go to the
Generaltab on the right hand side - Go to the
Signingoption and select your Apple developer account or team under the Team dropdown. - You can now press the
Build and Runbutton(⌘R)or selectRunfrom the Product menu. Your app will launch on your device shortly.
-
React native follows React with respect to information flow - which is one-directional.
-
But when we need to mix react native with native components - we need some special mechanisms.
-
- It's actually exporting something from native code targeting a component in RN. In the component the exported components will be received as
prop. Code Example - Main drawback is this properties does not support callback. So if we need to trigger anything in native from JS codes and handle the results - we can't progress.
- It's actually exporting something from native code targeting a component in RN. In the component the exported components will be received as
- The build we do by running
react-native run-iosorreact-native run-androidwe actually create a debug build by-default. - The debug builds exposes logs, shows system and app warnings and errors
- In the build signature it is marked as debug, so obviously you cannot upload this to stores :-)
-
-
Run the command
keytool -genkey -v -keystore emp-man-release-key.keystore -alias emp-man-key-alias -keyalg RSA -keysize 2048 -validity 10000 -
This command will prompt for passwords for keystore and key. This will also prompt for some fields for your key.
-
The output is a key file named
emp-man-release-key.keystore -
Copy the file to
<your project folder>/android/app -
Edit the file
~/.gradle/gradle.propertiesorandroid/gradle.propertiesand add the following (replace ***** with the correct keystore password, alias and key password)MYAPP_RELEASE_STORE_FILE=emp-man-release-key.keystore MYAPP_RELEASE_KEY_ALIAS=emp-man-key-alias MYAPP_RELEASE_STORE_PASSWORD=***** MYAPP_RELEASE_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_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 from project root in command line - run:
cd android && ./gradlew assembleRelease -
The
app-release.apkwill be generated at<your project folder>/android/app/build/outputs/apk/
-
-
- Create signing certificate requests
- Create provisioning profiles
- Install and link the certificates and profiles
- Select
Generic iOS Devicein the build destination - Go to
Product > Archiveand in the pop-over that came, selectAd-hocorApp-Storefor which option you are archiving. - You also can export the
.ipafile from the dialog box after build is done.