Skip to content

Instantly share code, notes, and snippets.

@achuvm
Last active June 15, 2022 09:00
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achuvm/fe0136818158bec2cdf4d1cd11053f6d to your computer and use it in GitHub Desktop.
Save achuvm/fe0136818158bec2cdf4d1cd11053f6d to your computer and use it in GitHub Desktop.
diff --git a/android/app/build.gradle b/android/app/build.gradle
index e381dda..a9ba303 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -94,7 +94,8 @@ def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
- compileSdkVersion rootProject.ext.compileSdkVersion
+ compileSdkVersion 28
+ flavorDimensions "platform"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
@@ -103,8 +104,9 @@ android {
defaultConfig {
applicationId "com.virosample"
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
+ minSdkVersion 23
+ targetSdkVersion 28
+ multiDexEnabled true
versionCode 1
versionName "1.0"
}
@@ -116,6 +118,21 @@ android {
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
+ 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
@@ -138,9 +155,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 6ba10b1..50d82c0 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -2,6 +2,7 @@
package="com.virosample">
<uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.CAMERA" />
<application
android:name=".MainApplication"
@@ -9,18 +10,21 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
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 c6e7c7c..0e89926 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 = "28.0.3"
- minSdkVersion = 16
- compileSdkVersion = 28
- targetSdkVersion = 28
- supportLibVersion = "28.0.0"
- }
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.3.1'
+ classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -21,8 +14,16 @@ buildscript {
}
allprojects {
+ configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
+ config.resolutionStrategy.eachDependency { details ->
+ details.useVersion("3.5.0-alpha03-5252756")
+ }
+ }
repositories {
mavenLocal()
+ maven {
+ url 'https://maven.google.com/'
+ }
google()
jcenter()
maven {
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')
<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>
@venkymrv
Copy link

venkymrv commented Jul 4, 2018

please tell me file location .

@anhtuank7c
Copy link

@venkymrv
android/app/src/main/AndroidManifest.xml
android/build.gradle
android/app/build.gradle

@dc-nikolaev
Copy link

dc-nikolaev commented Dec 26, 2018

Revision from 10 Jun work with compile 'com.android.support:appcompat-v7:27.0.0' in android/app/build.gradle.
Also required next changes:

compileSdkVersion 26
buildToolsVersion "26.0.1"
targetSdkVersion 26

@kevinrodriguez-io
Copy link

kevinrodriguez-io commented Feb 17, 2019

Do i need any of the aws cognito stuff for viro?

@Jackyaung
Copy link

Android doesn't work, have been struggling for two days:( .

below line will report error, it says VR_PLATFORM can't not found. And I did add this veriable in BuildConfig, but it will automatically deleted every time when you run it. it is not allowed to add value by manually. I change the BuildConfig.VR_PLATFORM as specific number ( like "2.0"), but it will flashback when you run the app.

new ReactViroPackage(ReactViroPackage.ViroPlatform.valueOf(BuildConfig.VR_PLATFORM))

Plus below code also don't work, it reports that code seems can't not recognize :

  • productFlavors {
  •    ar {
    
  •        resValue 'string', 'app_name', 'ViroSample-ar'
    
  •        buildConfigField 'String', 'VR_PLATFORM', '"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"'
    
  •    }
    
  • }

Anyone knows how to fix this ?

@amandeepmittal
Copy link

amandeepmittal commented Mar 10, 2019

This is not the updated version. Please update!

Especially the dependencies part in file /android/app/build.gradle.

@craoul10
Copy link

craoul10 commented Mar 21, 2019

Hi,
Can you update the documentation?
Ive made all this steps, fix al warnings, but still not working,its full of errors.

Ive created the project with react-native init, run npm install --save react-viro Edit AndroidManifest and the rest of files from documentation. Project its not running.
Error:

  • What went wrong:
    Task 'installDebug' not found in project ':app'. Some candidates are: 'installArDebug', 'installGvrDebug'.

  • Try:
    Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Thanks

@cristianoccazinsp
Copy link

Please, update this to gradle 3.x.x since this is right now outdated and won't work, use https://docs.viromedia.com/docs/integrating-existing-projects-android instead.

@antoinerousseau
Copy link

@octocat01
Copy link

Hi,
Can you update the documentation?
Ive made all this steps, fix al warnings, but still not working,its full of errors.

Ive created the project with react-native init, run npm install --save react-viro Edit AndroidManifest and the rest of files from documentation. Project its not running.
Error:

  • What went wrong:
    Task 'installDebug' not found in project ':app'. Some candidates are: 'installArDebug', 'installGvrDebug'.
  • Try:
    Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Thanks

Hi @craoul10 try this solution viromedia/viro#593 (comment)

@ben-depew
Copy link

Please update. Dead in the water on Android until these docs are brought up to date.

@ayepRahman
Copy link

Hi,

I appreciate a lot, is there an update on this. Stuck on this =(

@waqaramjad
Copy link

update that document , i tried every things but nothing work

@lumixraku
Copy link

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':app'.

Failed to notify project evaluation listener.
org.gradle.api.file.ProjectLayout.directoryProperty(Lorg/gradle/api/provider/Provider;)Lorg/gradle/api/file/DirectoryProperty;

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 722ms
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.

@akeemphilbert
Copy link

update that document , i tried every things but nothing work

This is a gist I created with the changes that worked for me https://gist.github.com/akeemphilbert/8323a7b71e682469b922920a624b35a8

@akeemphilbert
Copy link

akeemphilbert commented Oct 4, 2020 via email

@rgouzal
Copy link

rgouzal commented Oct 4, 2020

@akeemphilbert So I got it to build, but it's crashing not sure why.

@rgouzal
Copy link

rgouzal commented Oct 4, 2020

@akeemphilbert This is the output of logcat when app crashes:

BTW I am not running this on an emulator I am running this on a real samsung android device

10-04 23:15:04.594 20863 20911 E AndroidRuntime: FATAL EXCEPTION: create_react_context
10-04 23:15:04.594 20863 20911 E AndroidRuntime: Process: com.mapnav, PID: 20863
10-04 23:15:04.594 20863 20911 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.mapnav-dtEXw_9W0yDS3Ckp1RPt5Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.mapnav-dtEXw_9W0yDS3Ckp1RPt5Q==/lib/arm64, /data/app/com.mapnav-dtEXw_9W0yDS3Ckp1RPt5Q==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]] couldn't find "libviro_renderer.so"
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at java.lang.System.loadLibrary(System.java:1667)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at com.viromedia.bridge.module.MaterialManager.<clinit>(MaterialManager.java:37)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at com.viromedia.bridge.ReactViroPackage.createNativeModules(ReactViroPackage.java:87)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:42)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1347)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1318)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1225)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:131)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1016)
10-04 23:15:04.594 20863 20911 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:919)

@benndip
Copy link

benndip commented Oct 5, 2020

@akeemphilbert Thank you very much for your gist you made. It helped me and after few minutes mine works just fine and I'm up and running with AR in React Native.

@rofirezkin
Copy link

@akeemphilbert Thank you very much for your gist you made. It helped me and after few minutes mine works just fine and I'm up and running with AR in React Native.

can I see your source code ? my App always error, plz...

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