- Official training: https://developer.android.com/training/basics/firstapp/running-app.html
- Basic tutorial for creating ADV: https://www.sitepoint.com/beginning-andoid-create-an-android-virtual-device/
- Interesting build android first and then link it with RN: http://blog.couchbase.com/2015/november/getting-started-with-react-native-android-and-couchbase-lite
When installing Android Studio the env variable $ANDROID_HOME
was not set up.
This caused react-native run-android
to fail with this error:
java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
In my case the Android SDK was installed in /Users/besartshyti/Library/Android/sdk
.
This means we have to set it manually:
export ANDROID_HOME=/Users/besartshyti/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
You may need to install other Android phone images and virtual machines with specific processors architecture. Open the Android SDK Manager
with:
$ android
After setting up the ANDROID_HOME env variable. Got another error:
failed to find target with hash string 'android-23' in: /Users/besartshyti/Library/Android/sdk
By checking inside the sdk:
$ ls $ANDROID_HOME/platforms
android-24
we can see that only android-24
is installed. Run Android Studio and in Configure
select SDK Manager
and tick the box Android 6 (Marshmallow)
. Press ok, wait to install it, close and run again react-native run-android
.
In order to run react-native android, the
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!
# it means we need to run an emulator
android create avd -t "android-23" -n <your-device-name> -b default/x86_64
emulator -avd <your-device-name>
- what does emulator do?
emulator -help
and check list of AVDsemulator -list-avds
.
Android > emulator -avd foo
WARNING:./android/base/files/IniFile.cpp:155:Failed to process .ini file /Users/izaaksofer/.android/avd/react.avd/config.ini for reading.
Segmentation fault: 11
http://stackoverflow.com/questions/35378889/suddenly-cant-start-the-android-emulator-anymore
This happened to Izaak cause he didn't have memory and so the creation of an AVD failed and was corrupted.
http://blog.tylerbuchea.com/react-native-publishing-an-android-app/
Created and downloaded an account private key
. In the Download
folder.
Google Api Error: apkUpgradeVersionConflict: APK specifies a version code that has already been used.
Change the version number in android/app/build.gradle
, which seems enough.
What's the difference with android/app/src/main/AndroidManifest.xml
?
TODO:
- navigation experimental
- fastlane implement screenshot and asset preparation
- android push notification
The Ads Manager implementation is not generic enough - it's tied with FB infra and pretty specific to Ads Manager itself.
The reason why this is a significantly harder problem on Android than on iOS is because Android gives you much more flexibility in dealing with push notifications. On iOS, when the server sends a push notification, no application code is invoked in the app, instead a notification is shown based on the payload and the app is invoked if/when the user taps on it.
On Android, the push notification actually triggers a BroadcastReceiver that is then responsible for reading the payload and deciding what to do with it. It can show a notification based strictly on the payload content or start a Service to make a network request to pull more info before showing one. Or, it can decide to ignore the push. Basically, you can run any code on a push.
This makes it hard because we want to have the business logic of handling a push in JS. This means running JS in a Service without a UI (so no ReactRootView...), ideally with a minimal / different / smaller bundle than the main app, for performance reasons (this is run while the device is awake just to process push notifs, doing any extra work will result in your app using too much battery power).
In Ads Manager, the business logic is in Java, simply because we know what the payload is, how to create a UI notif from it and what Intent to launch when the user taps on it.
Furthermore, while iOS is (I think) tied to APNS for push delivery [that seems correct from firebase website], on Android there are alternatives, e.g. Amazon Device Messaging. Ideally our APIs would be extensible enough to allow plugging alternative delivery methods.
Form facebook/react-native#3423
Google has moved from GCM to FCM. To implement FCB check the official guide. At the moment there are two libraries: react-native-push-notification which uses GCM and react-native-fcm.
Remember to link dependencies react-native link react-native-fcm
which will produce this master 4586e11.
Send notification directly from Firebase: Docs Send message from Firebase Problems with Firebase
- What is Gradle? stackoverflow
Starting the app on emulator-5554 (/Users/besartshyti/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am start -n com.android/.MainActivity)...
Starting: Intent { cmp=com.android/.MainActivity }
Error type 3
Error: Activity class {com.android/com.android.MainActivity} does not exist.
[Android]$ react-native run-android
JS server already running.
- What is happening there?
- Android Virtual Device (AVD)
- Application Binary Interface (ABI)
- Android Debug Bridge (ADB)
- Android Application Package (APK)
- open menu
cmd+d #ios
andcmd+m #android