From f764032ef5678f7248b7084ba0adab001338859f Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Sat, 12 Nov 2016 10:20:16 +0000 Subject: [PATCH] fixing Android example --- .../android/app/src/main/AndroidManifest.xml | 3 +- .../io/realm/react/example/MainActivity.java | 19 ------ .../realm/react/example/MainApplication.java | 41 +++++++++++++ examples/ReactExample/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- react-native/android/build.gradle | 1 + react-native/android/src/main/jni/Android.mk | 61 ++++++++++--------- 7 files changed, 80 insertions(+), 50 deletions(-) create mode 100644 examples/ReactExample/android/app/src/main/java/io/realm/react/example/MainApplication.java diff --git a/examples/ReactExample/android/app/src/main/AndroidManifest.xml b/examples/ReactExample/android/app/src/main/AndroidManifest.xml index eeb0a42c..af4c12bd 100644 --- a/examples/ReactExample/android/app/src/main/AndroidManifest.xml +++ b/examples/ReactExample/android/app/src/main/AndroidManifest.xml @@ -7,7 +7,8 @@ android:allowBackup="true" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme" + android:name=".MainApplication"> getPackages() { - return Arrays.asList( - new MainReactPackage(), - new RealmReactPackage() - ); - } } diff --git a/examples/ReactExample/android/app/src/main/java/io/realm/react/example/MainApplication.java b/examples/ReactExample/android/app/src/main/java/io/realm/react/example/MainApplication.java new file mode 100644 index 00000000..e9977df5 --- /dev/null +++ b/examples/ReactExample/android/app/src/main/java/io/realm/react/example/MainApplication.java @@ -0,0 +1,41 @@ +package io.realm.react.example; + +import android.app.Application; + +import com.facebook.react.ReactApplication; +import com.facebook.react.ReactNativeHost; +import com.facebook.react.ReactPackage; +import com.facebook.react.shell.MainReactPackage; + +import java.util.Arrays; +import java.util.List; + +import io.realm.react.RealmReactPackage; + +public class MainApplication extends Application implements ReactApplication { + + private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { + @Override + protected boolean getUseDeveloperSupport() { + return BuildConfig.DEBUG; + } + + @Override + protected List getPackages() { + return Arrays.asList( + new MainReactPackage(), + new RealmReactPackage() + ); + } + }; + + /** + * A list of packages used by the app. If the app uses additional views + * or modules besides the default ones, add more packages here. + */ + + @Override + public ReactNativeHost getReactNativeHost() { + return mReactNativeHost; + } +} diff --git a/examples/ReactExample/android/build.gradle b/examples/ReactExample/android/build.gradle index 403a0075..4315cea0 100644 --- a/examples/ReactExample/android/build.gradle +++ b/examples/ReactExample/android/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.1' + classpath 'com.android.tools.build:gradle:2.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/examples/ReactExample/android/gradle/wrapper/gradle-wrapper.properties b/examples/ReactExample/android/gradle/wrapper/gradle-wrapper.properties index b9fbfaba..43e743f0 100644 --- a/examples/ReactExample/android/gradle/wrapper/gradle-wrapper.properties +++ b/examples/ReactExample/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Fri Nov 11 18:15:12 GMT 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/react-native/android/build.gradle b/react-native/android/build.gradle index 3809e7fb..3269c7b8 100644 --- a/react-native/android/build.gradle +++ b/react-native/android/build.gradle @@ -65,6 +65,7 @@ task downloadJSCHeaders(type: Download) { task downloadRealmCore(type: Download) { src "https://static.realm.io/downloads/core/realm-core-android-${project.coreVersion}.tar.gz" + // src "https://static.realm.io/downloads/sync/realm-sync-android-${project.coreVersion}.tar.gz" onlyIfNewer true overwrite false dest new File(downloadsDir, "realm-core-android-${project.coreVersion}.tar.gz") diff --git a/react-native/android/src/main/jni/Android.mk b/react-native/android/src/main/jni/Android.mk index c3637412..ab36d77f 100644 --- a/react-native/android/src/main/jni/Android.mk +++ b/react-native/android/src/main/jni/Android.mk @@ -14,40 +14,45 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := librealmreact -LOCAL_SRC_FILES := \ - src/js_realm.cpp \ - src/rpc.cpp \ - src/jsc/jsc_init.cpp \ - src/android/platform.cpp \ - src/android/io_realm_react_RealmReactModule.cpp \ - src/android/jsc_override.cpp \ - src/object-store/src/collection_notifications.cpp \ - src/object-store/src/index_set.cpp \ - src/object-store/src/list.cpp \ - src/object-store/src/object_schema.cpp \ - src/object-store/src/object_store.cpp \ - src/object-store/src/results.cpp \ - src/object-store/src/schema.cpp \ - src/object-store/src/shared_realm.cpp \ - src/object-store/src/parser/parser.cpp \ - src/object-store/src/parser/query_builder.cpp \ - src/object-store/src/impl/collection_change_builder.cpp \ - src/object-store/src/impl/collection_notifier.cpp \ - src/object-store/src/impl/list_notifier.cpp \ - src/object-store/src/impl/realm_coordinator.cpp \ - src/object-store/src/impl/results_notifier.cpp \ - src/object-store/src/impl/transact_log_handler.cpp \ - src/object-store/src/impl/android/external_commit_helper.cpp \ - src/object-store/src/impl/android/weak_realm_notifier.cpp \ - src/object-store/src/util/format.cpp \ - src/object-store/src/util/thread_id.cpp \ - vendor/base64.cpp +LOCAL_SRC_FILES := $(wildcard vendor/*.cpp) $(wildcard src/*.cpp) $(wildcard src/jsc/*.cpp) $(wildcard src/android/*.cpp) $(wildcard src/object-store/src/*.cpp) $(wildcard src/object-store/src/impl/*.cpp) $(wildcard src/object-store/src/parser/*.cpp) $(wildcard src/object-store/src/util/*.cpp) +# $(info >>>>>>>> LIBS>: [${OBJ_STORE}]) + +# LOCAL_SRC_FILES := \ +# src/js_realm.cpp \ +# src/rpc.cpp \ +# src/jsc/jsc_init.cpp \ +# src/android/platform.cpp \ +# src/android/io_realm_react_RealmReactModule.cpp \ +# src/android/jsc_override.cpp \ +# src/object-store/src/collection_notifications.cpp \ +# src/object-store/src/index_set.cpp \ +# src/object-store/src/list.cpp \ +# src/object-store/src/object_schema.cpp \ +# src/object-store/src/object_store.cpp \ +# src/object-store/src/results.cpp \ +# src/object-store/src/schema.cpp \ +# src/object-store/src/shared_realm.cpp \ +# src/object-store/src/parser/parser.cpp \ +# src/object-store/src/parser/query_builder.cpp \ +# src/object-store/src/impl/collection_change_builder.cpp \ +# src/object-store/src/impl/collection_notifier.cpp \ +# src/object-store/src/impl/list_notifier.cpp \ +# src/object-store/src/impl/realm_coordinator.cpp \ +# src/object-store/src/impl/results_notifier.cpp \ +# src/object-store/src/impl/transact_log_handler.cpp \ +# src/object-store/src/impl/android/external_commit_helper.cpp \ +# src/object-store/src/impl/weak_realm_notifier.cpp \ +# src/object-store/src/util/format.cpp \ +# src/object-store/src/util/thread_id.cpp \ +# src/object-store/src/thread_confined.hpp \ +# vendor/base64.cpp LOCAL_C_INCLUDES := src LOCAL_C_INCLUDES += src/jsc LOCAL_C_INCLUDES += src/object-store/src LOCAL_C_INCLUDES += src/object-store/src/impl LOCAL_C_INCLUDES += src/object-store/src/parser +# LOCAL_C_INCLUDES += src/object-store/src/sync LOCAL_C_INCLUDES += src/object-store/external/pegtl LOCAL_C_INCLUDES += vendor LOCAL_C_INCLUDES += $(JAVA_HOME)/include