try to make example work

This commit is contained in:
Ari Lazier 2016-01-13 21:25:10 -08:00
parent c2d15af000
commit a7720216de
5 changed files with 64 additions and 1 deletions

View File

@ -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'
}

View File

@ -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<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new RealmReactAndroid(reactContext));
return modules;
}
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
}

View File

@ -19,5 +19,8 @@ allprojects {
jcenter {
url "http://dl.bintray.com/mkonicek/maven"
}
flatDir{
dirs 'lib'
}
}
}

View File

@ -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');

View File

@ -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