From a7720216de7a49de19e1acc0f763d10bb0c28929 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Wed, 13 Jan 2016 21:25:10 -0800 Subject: [PATCH] try to make example work --- .../ReactExample/android/app/build.gradle | 17 ++++++++- .../java/com/reactexample/MainActivity.java | 35 +++++++++++++++++++ examples/ReactExample/android/build.gradle | 3 ++ examples/ReactExample/index.android.js | 3 ++ examples/ReactExample/run-android.sh | 7 ++++ 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100755 examples/ReactExample/run-android.sh diff --git a/examples/ReactExample/android/app/build.gradle b/examples/ReactExample/android/app/build.gradle index 3cee3b7c..6a7d934c 100644 --- a/examples/ReactExample/android/app/build.gradle +++ b/examples/ReactExample/android/app/build.gradle @@ -74,5 +74,20 @@ android { dependencies { compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" - compile "com.facebook.react:react-native:0.16.+" + compile 'com.facebook.react:ReactAndroid-debug@aar' + compile 'com.reactexample:app-debug@aar' + + compile 'com.github.KeepSafe:ReLinker:1.1' + compile 'org.nanohttpd:nanohttpd:2.2.0' + compile 'com.google.code.findbugs:jsr305:3.0.0' + compile 'com.facebook.stetho:stetho-okhttp:1.2.0' + compile 'org.webkit:android-jsc:r174650' + compile 'com.squareup.okhttp:okhttp-ws:2.5.0' + compile 'com.facebook.fresco:fresco:0.8.1' + compile 'com.fasterxml.jackson.core:jackson-core:2.2.3' + compile 'com.squareup.okhttp:okhttp:2.5.0' + compile 'com.facebook.fresco:imagepipeline-okhttp:0.8.1' + compile 'com.squareup.okio:okio:1.6.0' + compile 'com.android.support:recyclerview-v7:23.0.1' + compile 'com.facebook.stetho:stetho:1.2.0' } diff --git a/examples/ReactExample/android/app/src/main/java/com/reactexample/MainActivity.java b/examples/ReactExample/android/app/src/main/java/com/reactexample/MainActivity.java index d8a2b3da..f050b3a2 100644 --- a/examples/ReactExample/android/app/src/main/java/com/reactexample/MainActivity.java +++ b/examples/ReactExample/android/app/src/main/java/com/reactexample/MainActivity.java @@ -6,11 +6,22 @@ import android.view.KeyEvent; import com.facebook.react.LifecycleState; import com.facebook.react.ReactInstanceManager; +import com.facebook.react.ReactPackage; import com.facebook.react.ReactRootView; +import com.facebook.react.bridge.JavaScriptModule; +import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.shell.MainReactPackage; +import com.facebook.react.uimanager.ViewManager; import com.facebook.soloader.SoLoader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.reactexample.RealmReactAndroid; + public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler { private ReactInstanceManager mReactInstanceManager; @@ -26,6 +37,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand .setBundleAssetName("index.android.bundle") .setJSMainModuleName("index.android") .addPackage(new MainReactPackage()) + .addPackage(new AnExampleReactPackage()) .setUseDeveloperSupport(BuildConfig.DEBUG) .setInitialLifecycleState(LifecycleState.RESUMED) .build(); @@ -75,4 +87,27 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand mReactInstanceManager.onResume(this, this); } } + + + class AnExampleReactPackage implements ReactPackage { + @Override + public List createNativeModules( + ReactApplicationContext reactContext) { + List modules = new ArrayList<>(); + + modules.add(new RealmReactAndroid(reactContext)); + + return modules; + } + + @Override + public List> createJSModules() { + return Collections.emptyList(); + } + + @Override + public List createViewManagers(ReactApplicationContext reactContext) { + return Collections.emptyList(); + } + } } diff --git a/examples/ReactExample/android/build.gradle b/examples/ReactExample/android/build.gradle index bdb0fcc6..bf560221 100644 --- a/examples/ReactExample/android/build.gradle +++ b/examples/ReactExample/android/build.gradle @@ -19,5 +19,8 @@ allprojects { jcenter { url "http://dl.bintray.com/mkonicek/maven" } + flatDir{ + dirs 'lib' + } } } diff --git a/examples/ReactExample/index.android.js b/examples/ReactExample/index.android.js index c506bc04..ede936bc 100644 --- a/examples/ReactExample/index.android.js +++ b/examples/ReactExample/index.android.js @@ -4,6 +4,9 @@ 'use strict'; +var RealmReactAndroid = require('NativeModules').RealmReactAndroid; +var Realm = require('realm'); + const React = require('react-native'); const TodoApp = require('./components/todo-app'); diff --git a/examples/ReactExample/run-android.sh b/examples/ReactExample/run-android.sh new file mode 100755 index 00000000..f04aaac6 --- /dev/null +++ b/examples/ReactExample/run-android.sh @@ -0,0 +1,7 @@ +#!/bin/bash +cp ../../react-native/android/app/build/outputs/aar/app-debug.aar android/app/lib/ +rm -rf node_modules/realm node_modules/realm-tests +npm install realm +adb forward tcp:8082 tcp:8082 +adb reverse tcp:8081 tcp:8081 +react-native run-android