Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Android Cheat Sheet

Steve Podell edited this page Nov 11, 2017 · 16 revisions

Some Useful Articles

react-native getting-started.html

https://medium.com/@vinceyuan/react-native-debugging-tools-3a24e4e40e4

medium.com react-native-my-developer-guide-to-configure-build-and-publish-using-mac-for-android

medium.com running-react-native-app-on-the-android-emulator

So far it seems like those Facebook guys like iOS much better than Android, the tools are better for iOS and the instructions are better for iOS. And probably since all the app developer $ is in iOS, the github issues and stack overflow issues are more helpful for iOS.

Some pictures from my setup:

10/1/17 -- these images won't display until my pull request gets approved.

The Facebook SDK for iOS

The Facebook SDK for iOS needs the facebook/react-native-fbsdk to work. The facebook/react-native-fbsdk is a wrapper for the Facebook SDK for iOS. They are not redundant or duplicative!

Debugging react-native Android:

Open Android Studio, by selecting the android dir within the WeVoteReactNative dir.

Android Studio is not be useful for the JavaScript part, only for the Java, packing, simulator launching, and logger viewing for the app.

You need to get a simulator running before going much further. I used the free one that comes from Facebook (not Genymotion). And Nuclide is no longer available for react-native. As of October 2, 2017 don't choose the latest 8.0 Nougat, instead use 7.1 Nougat -- react-native-oauth has a problem with 8.0.

If you run into compile issues, see the following section.

Once the simulator is running, and you have the JavaScript packager is running on port 8081, you should see the app in the simulator. On the app, press ⌘+M to see the simulator menu, and click "Debug JS Remotely" (This is like ⌘+D for iOS simulator debugging). Then you should see the debuggerWorker.js in the Sources pane, click through to find your source files and apply breakpoints as needed.

Issues you may encounter

Unable to make XHR (ajax) requests to python server running on my Mac

The Android Emulator (in my case Genymotion runs in an Oracle VirtualBox vm. The VirtualBox has a specific virtual ip for accessing the localhost outside of the VBox (where the python API server is running). In Config.js, if you set LIVE_SERVER to false, the conditional code that follows should allow you to access the Python API server on your local:

const LIVE_SERVER = false;  // is this the live production server?  (false for developers with local api servers)

If you use the AVD emulator in the VM you will need to access localhost with http://10.0.2.2:8000/ and will need to change your config.js to match. If you are using Genymotion the default value of http://10.0.3.2:8000/ will work as is.

See React-native issue 10404

App crashes on return from Twitter OAuth and needs to be restarted

They are working on a fix for this... Twitter Android Crash When Redirecting #142

Here is an (awful) temporary solution:

I was able to make it work, by copying OAuthManagerModule.java, and OAuthManagerProviders from this pull request https://github.com/fullstackreact/react-native-oauth/pull/121

Gilnave's changes worked for me with one additional fix

In OAuthManagerModule.java at line 410, I replaced

String oauthTokenSecret = (String) accessTokenMap.get("oauth_token_secret");

with

String oauthTokenSecret = (String) accessToken.getParameter("token_secret");

then it worked.

Android Studio fails to compile the java/gradle with a “Configure Build” error

In at terminal window, make sure your ~/.bash_profile contains (substitute in your path!)

export ANDROID_HOME=/Users/stevepodell/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

Then source ~/.bash_profile

In Android Studio at Tools/Android/SDK Manager, change to the SDK Tools tab, and under Support Repository, uninstall the "Android Support Registry", then reinstall it.

A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugApkCopy'

The full error is

A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
   > Could not find com.github.delight-im:Android-AdvancedWebView:v3.0.0.
     Required by:
         WeVoteReactNative:app:unspecified > WeVoteReactNative:react-native-oauth:unspecified

See https://github.com/fullstackreact/react-native-oauth/blob/master/README.md#android-setup

Get a Java compile error for :react-native-oauth:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).

    :react-native-oauth:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/stevepodell/WebstormProjects/WeVoteReactNative/node_modules/react-native-oauth/android/src/main/java/io/fullstack/oauth/OAuthManagerPackage.java:39: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: /Users/stevepodell/WebstormProjects/WeVoteReactNative/node_modules/react-native-oauth/android/src/main/java/io/fullstack/oauth/OAuthManagerDialogFragment.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
:react-native-oauth:compileReleaseJavaWithJavac FAILED

See https://github.com/fullstackreact/react-native-oauth/issues/158

Commenting the @Override in node_modules/react-native-oauth/android/src/main/java/io/fullstack/oauth/OAuthManagerPackage.java createJSModules method makes the build succeed:

// @Override
    public List<Class<? extends JavaScriptModule>> createJSModules() {
        return Collections.emptyList();
    }

If a packaging terminal session is not automatically started by Android Studio

Do it yourself...

/usr/local/bin/node /Users/<adjust for your actual path>/NodeEnvironments/WebAppEnv/lib/node_modules/react-native-cli start