diff --git a/App.tsx b/App.tsx index 844adee..8c14cd7 100644 --- a/App.tsx +++ b/App.tsx @@ -1,18 +1,18 @@ -import React, { useState } from "react"; -import { StyleSheet } from "react-native"; import { ViroARScene, - ViroText, - ViroTrackingStateConstants, ViroARSceneNavigator, + ViroText, ViroTrackingReason, + ViroTrackingStateConstants, } from "@viro-community/react-viro"; +import React, { useState } from "react"; +import { StyleSheet } from "react-native"; const HelloWorldSceneAR = () => { const [text, setText] = useState("Initializing AR..."); function onInitialized(state: any, reason: ViroTrackingReason) { - console.log("guncelleme", state, reason); + console.log("onInitialized", state, reason); if (state === ViroTrackingStateConstants.TRACKING_NORMAL) { setText("Hello World!"); } else if (state === ViroTrackingStateConstants.TRACKING_UNAVAILABLE) { diff --git a/README.md b/README.md index 3860862..40e0c9f 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ If you are integrating ViroReact into an existing project, have a look at our [I ```bash npm install ``` + ### iOS only: ```bash @@ -46,7 +47,27 @@ npx react-native run-ios npx react-native run-android ``` -If everything is set up _correctly_, you should see your new app running on you device. +If everything is set up _correctly_, you should see your new app running on you device. + +#### Install CocoaPods + +```bash +cd ios +pod install +cd .. +``` + +```bash +# using npm +npm run ios + +# OR using Yarn +yarn ios +``` + +If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly. + +This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. ## Step 4: Modifying your App diff --git a/android/app/build.gradle b/android/app/build.gradle index b108ea1..61b6bc6 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -109,6 +109,16 @@ dependencies { implementation("com.facebook.react:react-android") implementation("com.facebook.react:flipper-integration") + // ======================================================================== + // https://viro-community.readme.io/docs/installation-instructions#2-in-your-androidappbuildgradle-add-the-following-lines-to-the-dependencies-section + implementation project(':gvr_common') + implementation project(':arcore_client') + implementation project(path: ':react_viro') + implementation project(path: ':viro_renderer') + implementation 'com.google.android.exoplayer:exoplayer:2.19.1' + implementation 'com.google.protobuf.nano:protobuf-javanano:3.1.0' + // ======================================================================== + if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 4122f36..fe9123c 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,22 @@ - + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/java/com/virostarterkit/MainApplication.kt b/android/app/src/main/java/com/virostarterkit/MainApplication.kt index ddec879..dc71e20 100644 --- a/android/app/src/main/java/com/virostarterkit/MainApplication.kt +++ b/android/app/src/main/java/com/virostarterkit/MainApplication.kt @@ -1,4 +1,5 @@ package com.virostarterkit +import com.viromedia.bridge.ReactViroPackage import android.app.Application import com.facebook.react.PackageList @@ -20,6 +21,10 @@ class MainApplication : Application(), ReactApplication { PackageList(this).packages.apply { // Packages that cannot be autolinked yet can be added manually here, for example: // add(MyReactNativePackage()) + + // https://viro-community.readme.io/docs/installation-instructions#5-now-add-the-viro-package-to-your-mainapplication + add(ReactViroPackage(ReactViroPackage.ViroPlatform.GVR)) + add(ReactViroPackage(ReactViroPackage.ViroPlatform.AR)) } override fun getJSMainModuleName(): String = "index" diff --git a/android/build.gradle b/android/build.gradle index cb9d623..ac59ef7 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { buildToolsVersion = "34.0.0" - minSdkVersion = 21 + minSdkVersion = 24 compileSdkVersion = 34 targetSdkVersion = 34 ndkVersion = "25.1.8937393" diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index d11cdd9..ac72c34 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/android/gradlew.bat b/android/gradlew.bat index 93e3f59..6689b85 100644 --- a/android/gradlew.bat +++ b/android/gradlew.bat @@ -1,92 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/settings.gradle b/android/settings.gradle index 733cedc..1276401 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -2,3 +2,11 @@ rootProject.name = 'ViroStarterKit' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' includeBuild('../node_modules/@react-native/gradle-plugin') + +// https://viro-community.readme.io/docs/installation-instructions#3-in-your-androidsettingsgradle-add-the-following-lines-to-the-end +include ':react_viro', ':arcore_client', ':gvr_common', ':viro_renderer' +project(':arcore_client').projectDir = new File('../node_modules/@viro-community/react-viro/android/arcore_client') +project(':gvr_common').projectDir = new File('../node_modules/@viro-community/react-viro/android/gvr_common') +project(':viro_renderer').projectDir = new File('../node_modules/@viro-community/react-viro/android/viro_renderer') +project(':react_viro').projectDir = new File('../node_modules/@viro-community/react-viro/android/react_viro') + diff --git a/package-lock.json b/package-lock.json index f52b75a..eb75f2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "ViroStarterKit", "version": "0.0.1", "dependencies": { - "@viro-community/react-viro": "^2.23.1", + "@viro-community/react-viro": "^2.41.0", "react": "18.2.0", "react-native": "0.73.3" }, @@ -3808,9 +3808,9 @@ "license": "ISC" }, "node_modules/@viro-community/react-viro": { - "version": "2.23.1", - "resolved": "https://registry.npmjs.org/@viro-community/react-viro/-/react-viro-2.23.1.tgz", - "integrity": "sha512-RUWW3yH58RnCJGm/3IKA+m4SY1YCfZGHJH1J/xJ9m+nmUdsTZ4y3jyKFP0XmnglUgHy2r//20qBJ5qxa88Kdlg==", + "version": "2.41.0", + "resolved": "https://registry.npmjs.org/@viro-community/react-viro/-/react-viro-2.41.0.tgz", + "integrity": "sha512-Sf0UjjIdqgYmuFfjVTxbnzXNWA+39/OHYQa+wW5pR5SFiXaBsqgS+rT8lvsIFIMJr4tpSB9rSflI9LQQKfIeDw==", "dependencies": { "@expo/config-plugins": "^7.2.5", "react": "^18.2.0" diff --git a/package.json b/package.json index 1dd53af..a4f409b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "test": "jest" }, "dependencies": { - "@viro-community/react-viro": "^2.23.1", + "@viro-community/react-viro": "^2.41.0", "react": "18.2.0", "react-native": "0.73.3" },