Skip to content

Instantly share code, notes, and snippets.

@manbod
Created January 14, 2019 21:13
Show Gist options
  • Save manbod/5a7f7d0511ff4b4c7f78086ee4706932 to your computer and use it in GitHub Desktop.
Save manbod/5a7f7d0511ff4b4c7f78086ee4706932 to your computer and use it in GitHub Desktop.
List of changes to make to a react-native package to correctly link react-viro.
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 72ae42a..cbac9d3 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -94,13 +94,15 @@ def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
- compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
+ compileSdkVersion 28
+ buildToolsVersion '28.0.3'
+ flavorDimensions "platform"
defaultConfig {
applicationId "com.virosample"
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
+ minSdkVersion 23
+ targetSdkVersion 28
+ multiDexEnabled true
versionCode 1
versionName "1.0"
ndk {
@@ -115,6 +117,21 @@ android {
include "armeabi-v7a", "x86"
}
}
+ productFlavors {
+ ar {
+ resValue 'string', 'app_name', 'ViroSample-ar'
+ buildConfigField 'String', 'VR_PLATFORM', '"GVR"' //default to GVR
+ }
+ gvr {
+ resValue 'string', 'app_name', 'ViroSample-gvr'
+ buildConfigField 'String', 'VR_PLATFORM', '"GVR"'
+ }
+ ovr {
+ resValue 'string', 'app_name', 'ViroSample-ovr'
+ applicationIdSuffix '.ovr'
+ buildConfigField 'String', 'VR_PLATFORM', '"OVR_MOBILE"'
+ }
+ }
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
@@ -137,9 +154,20 @@ android {
}
dependencies {
- implementation fileTree(dir: "libs", include: ["*.jar"])
- implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
- implementation "com.facebook.react:react-native:+" // From node_modules
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'com.facebook.react:react-native:+'
+ implementation project(':arcore_client') // remove this if AR not required
+ implementation project(':gvr_common')
+ implementation project(path: ':viro_renderer')
+ implementation project(path: ':react_viro')
+ implementation 'com.google.android.exoplayer:exoplayer:2.7.1'
+ implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
+ implementation 'com.amazonaws:aws-android-sdk-core:2.7.7'
+ implementation 'com.amazonaws:aws-android-sdk-ddb:2.7.7'
+ implementation 'com.amazonaws:aws-android-sdk-ddb-mapper:2.7.7'
+ implementation 'com.amazonaws:aws-android-sdk-cognito:2.7.7'
+ implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.7.7'
}
// Run this once to be able to run the application with BUCK
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index ef8e4af..0234277 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -3,24 +3,28 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
+ <uses-permission android:name="android.permission.CAMERA" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
+ android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
- android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
+ <category android:name="com.google.intent.category.CARDBOARD" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
+ <meta-data android:name="com.google.ar.core" android:value="optional" />
</application>
</manifest>
diff --git a/android/app/src/main/java/com/virosample/MainApplication.java b/android/app/src/main/java/com/virosample/MainApplication.java
index 2e279a8..deaecae 100644
--- a/android/app/src/main/java/com/virosample/MainApplication.java
+++ b/android/app/src/main/java/com/virosample/MainApplication.java
@@ -6,6 +6,8 @@ import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
+
+import com.viromedia.bridge.ReactViroPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
@@ -22,7 +24,8 @@ public class MainApplication extends Application implements ReactApplication {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
- new MainReactPackage()
+ new MainReactPackage(),
+ new ReactViroPackage(ReactViroPackage.ViroPlatform.valueOf(BuildConfig.VR_PLATFORM))
);
}
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 5755f2a..8542005 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -1,3 +1,2 @@
<resources>
- <string name="app_name">ViroSample</string>
</resources>
diff --git a/android/build.gradle b/android/build.gradle
index a1e8085..c3ca947 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,19 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext {
- buildToolsVersion = "27.0.3"
- minSdkVersion = 16
- compileSdkVersion = 27
- targetSdkVersion = 26
- supportLibVersion = "27.1.1"
- }
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.4'
+ classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -23,6 +16,9 @@ buildscript {
allprojects {
repositories {
mavenLocal()
+ maven {
+ url 'https://maven.google.com/'
+ }
google()
jcenter()
maven {
@@ -34,6 +30,6 @@ allprojects {
task wrapper(type: Wrapper) {
- gradleVersion = '4.4'
+ gradleVersion = '4.6'
distributionUrl = distributionUrl.replace("bin", "all")
}
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index b6517bb..3f0f9be 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
diff --git a/android/settings.gradle b/android/settings.gradle
index e646b99..5255fa5 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -1,3 +1,8 @@
rootProject.name = 'ViroSample'
include ':app'
+include ':react_viro', ':arcore_client', ':gvr_common', ':viro_renderer'
+project(':arcore_client').projectDir = new File('../node_modules/react-viro/android/arcore_client')
+project(':gvr_common').projectDir = new File('../node_modules/react-viro/android/gvr_common')
+project(':viro_renderer').projectDir = new File('../node_modules/react-viro/android/viro_renderer')
+project(':react_viro').projectDir = new File('../node_modules/react-viro/android/react_viro')
<!-- Add this AndroidManifest.xml file at ViroSample/android/app/src/ovr/ only
if you are building a VR app for Samsung GearVR-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<meta-data
android:name="com.samsung.android.vr.application.mode"
android:value="vr_only"/>
</application>
</manifest>
@knightcube
Copy link

Getting this error after running ./gradlew installArDebug

Execution failed for task ':app:generateArDebugBuildConfig'.
> org.xml.sax.SAXParseException; systemId: file:/D:/Projects/ReactNative/ARDemo/ARDemo/android/app/src/main/AndroidManifest.xml; lineNumber: 26; columnNumber: 39; 

Attribute "usesCleartextTraffic" bound to namespace "http://schemas.android.com/apk/res/android" was already specified for element "application"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment