{"_id":"5ba1a04d4f89f700039d85a2","category":{"_id":"5ba1a04d4f89f700039d8594","version":"5ba1a04d4f89f700039d85d0","project":"5a065a6134873d0010b396ab","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-10-25T23:36:45.975Z","from_sync":false,"order":0,"slug":"basics","title":"Getting Started"},"project":"5a065a6134873d0010b396ab","user":"576c22a3808cf02b00d37419","parentDoc":null,"version":{"_id":"5ba1a04d4f89f700039d85d0","project":"5a065a6134873d0010b396ab","__v":0,"forked_from":"5b8469fbe0a7ea00039d96b8","createdAt":"2018-04-18T18:19:34.288Z","releaseDate":"2018-04-18T18:19:34.288Z","categories":["5ba1a04d4f89f700039d8594","5ba1a04d4f89f700039d8595","5ba1a04d4f89f700039d8596","5b05923ea5a2f9000357b452","5b05f793c2c86c0003cbe414","5ba1a04d4f89f700039d8597","5ba1a04d4f89f700039d8598","5ba1a04d4f89f700039d8599"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.11.0","version":"1.11.0"},"githubsync":"","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-09-17T20:14:44.025Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":8,"body":"To distribute your application follow the instructions for each respective platform. If you are distributing with Viro, please follow our [Attribution](doc:attribution) guidelines. Links provided below. \n\nARCore (in developer preview) \nhttps://developers.google.com/ar/discover/#supported_devices\n\nAndroid Cardboard Distribution:\nhttps://developers.google.com/vr/distribute/cardboard/\n\nGoogle Daydream Distribution: \nhttps://developers.google.com/vr/distribute/daydream/\n\nOculus Gear VR Distribution: \nhttps://developer3.oculus.com/documentation/publish/latest/\n[block:api-header]\n{\n  \"title\": \"Targeting Older Android Builds\"\n}\n[/block]\nDepending on you users and application, you might need to target and build with older versions of the Android SDK in Android Studio. To do so, simply lower the **minSdkVersion** version number as specified in the build.gradle file to the desired version. You will also need to inform Android about the version override in your Android manifest file with the **overrideLibrary* tag: \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n<manifest xmlns:android=\\\"http://schemas.android.com/apk/res/android\\\"\\n    package=\\\"com.example.virosample\\\">\\n  \\n  \\t<!-- Required to read the paired viewer's distortion parameters -->\\n    <uses-permission android:name=\\\"android.permission.READ_EXTERNAL_STORAGE\\\"/>\\n    ... other permissions ...\\n   \\n    <!-- Perform our override here -->\\n    <uses-sdk tools:overrideLibrary=\\\"com.viro.renderer\\\"/>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nDepending on the features that you want to use in your application, there is also a minimum sdk version number to which you can lower the minSdkVersion towards for them to function properly. These features and their corresponding numbers are as shown below:\n[block:parameters]\n{\n  \"data\": {\n    \"h-1\": \"Required Android Min Sdk Version\",\n    \"h-0\": \"Renderer\",\n    \"0-0\": \"ViroSceneView features\\n(3D rendering *without* AR / VR)\",\n    \"1-0\": \"ViroViewARCore features\\n(3D rendering with AR Core)\",\n    \"2-0\": \"ViroViewGVR features\\n(3D Rendering with VR)\",\n    \"0-1\": \"API level 18, as restricted by [OpenGL ES 3.0](https://developer.android.com/guide/topics/graphics/opengl.html).\",\n    \"1-1\": \"[API level 24](https://developers.google.com/ar/develop/java/enable-arcore) for an AR Required App.\",\n    \"2-1\": \"[API level 19 for cardboard compatibility.](https://developers.google.com/vr/develop/android/get-started)\\n[API level 25 for daydream compatibility.](https://developers.google.com/vr/develop/android/get-started)\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\nYou can also target a wider range of Android SDK versions by building a hybrid application made out of mutually exclusive 3D ViroCore and 2D Android layout experiences. These applications delay the creation and use of AR / VR components and only inflates them on an AR / VR capable device. Else, on non-compatible devices, developers can then display their original 2D Android content as per normal. This drastically helps increase the application's audience size and reach.\n\n[block:api-header]\n{\n  \"title\": \"Additional Android Device Type Support\"\n}\n[/block]\nAn application's audience size, or the number of supported devices are ultimately defined by the Google Play Store. It filters out in-compatible devices, based on defined features in your manifest file. For example, devices without gyroscope sensors will be deemed incompatible if your app defines a gyroscope uses-feature in your manifest. For VR / AR, features like openGL, accelerometer and gyroscopes are required. \n\nHowever, for hybrid apps with exclusive 2D + optional AR experiences, there are situations where you may not want to use the gyroscope sensor at all - say, for your non-AR experiences on older devices. Currently, your app is ultimately 'blocked' from being downloaded by a larger audience with incompatible device types. For example, the gyroscope uses-feature tag required for AR then effectively blocks a large portion of your customers from downloading your app (those who don't have a gyroscope sensor), **even though your app is \"AR Optional\" and has an exclusive 2D layout experience!**\n\nThus, to get around this problem, we've provided you a list of **uses-feature overrides** that you can define in your manifest as shown below. These overrides effectively makes required features (like gyroscope / openGL / camera) optional instead. As a result, the Google Play store will then be able to identify a larger selection of compatible devices, where you can then dynamically determine AR/VR/Rendering capability and inflate your Android 2D or Viro Core 3D views as needed.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"When using Overriding <uses-feature> Tags:\",\n  \"body\": \"Note: Because Google Play no longer has the feature tags that are overwritten to filters apps by device compatibility, **developers are responsible for dynamically checking required uses-features that are needed for AR / VR rendering**. As such for every uses-feature that you override with, ensure that you dynamically check for this feature in Java before loading the desired AR / VR experience!\"\n}\n[/block]\nNote that you can also pick any set of overrides above that you desire:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<uses-feature android:glEsVersion=\\\"0x00030000\\\" android:required=\\\"false\\\" tools:node=\\\"remove\\\" tools:replace=\\\"required\\\" />\\n<uses-feature android:name=\\\"android.hardware.sensor.accelerometer\\\" android:required=\\\"false\\\" tools:replace=\\\"required\\\" />\\n<uses-feature android:name=\\\"android.hardware.sensor.gyroscope\\\" android:required=\\\"false\\\" tools:replace=\\\"required\\\" />\\n<uses-feature android:name=\\\"android.hardware.camera\\\" android:required=\\\"false\\\" tools:replace=\\\"required\\\" />\\n<uses-feature android:name=\\\"android.hardware.microphone\\\" android:required=\\\"false\\\" tools:replace=\\\"required\\\" />\",\n      \"language\": \"xml\",\n      \"name\": \"uses-feature overrides\"\n    }\n  ]\n}\n[/block]\nHere's an example of the total number of supported devices that you can target on the Google Play store with the above overrides on a Viro Core Hello World AR project:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/026aa04-Screen_Shot_2018-03-02_at_11.44.35_AM.png\",\n        \"Screen Shot 2018-03-02 at 11.44.35 AM.png\",\n        1960,\n        344,\n        \"#3b6885\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"ABI Splitting\"\n}\n[/block]\nViroCore includes architectures for two generations of ARM devices: armeabi-v7a and arm64-v8a. This means both of these will be packaged in your APK -- even though your customers only need one or the other. To ensure that your customers only receive the ABI they need, we recommend using Android's [ABI splitting feature](https://developer.android.com/studio/build/configure-apk-splits.html). This will dramatically reduce the binary size of your app.\n\nTo use ABI splitting, add a splits block to your module-level build.gradle file. In the example below, we produce on APK for armeabi-v7a architectures, and one for arm64-v8a architectures. This is the recommended configuration for apps using Viro.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"android {\\n  ...\\n  splits {\\n    abi {\\n      enable true\\n      reset()\\n\\n      // Specifies a list of ABIs that Gradle should create APKs for\\n      include \\\"armeabi-v7a\\\", \\\"arm64-v8a\\\"\\n\\n      // Specifies that we do not want to also generate a universal APK that includes all ABIs\\n      universalApk false\\n    }\\n  }\\n}\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\nOnce you've added this to your gradle, select the module in the Project Pane and build with ```Build > Build APK```. The APKs for each ABI will be placed in the project's ```build/outputs/apk/``` directory.","excerpt":"","slug":"android-distribution","type":"basic","title":"Distribution"}
To distribute your application follow the instructions for each respective platform. If you are distributing with Viro, please follow our [Attribution](doc:attribution) guidelines. Links provided below. ARCore (in developer preview) https://developers.google.com/ar/discover/#supported_devices Android Cardboard Distribution: https://developers.google.com/vr/distribute/cardboard/ Google Daydream Distribution: https://developers.google.com/vr/distribute/daydream/ Oculus Gear VR Distribution: https://developer3.oculus.com/documentation/publish/latest/ [block:api-header] { "title": "Targeting Older Android Builds" } [/block] Depending on you users and application, you might need to target and build with older versions of the Android SDK in Android Studio. To do so, simply lower the **minSdkVersion** version number as specified in the build.gradle file to the desired version. You will also need to inform Android about the version override in your Android manifest file with the **overrideLibrary* tag: [block:code] { "codes": [ { "code": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"com.example.virosample\">\n \n \t<!-- Required to read the paired viewer's distortion parameters -->\n <uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>\n ... other permissions ...\n \n <!-- Perform our override here -->\n <uses-sdk tools:overrideLibrary=\"com.viro.renderer\"/>", "language": "xml" } ] } [/block] Depending on the features that you want to use in your application, there is also a minimum sdk version number to which you can lower the minSdkVersion towards for them to function properly. These features and their corresponding numbers are as shown below: [block:parameters] { "data": { "h-1": "Required Android Min Sdk Version", "h-0": "Renderer", "0-0": "ViroSceneView features\n(3D rendering *without* AR / VR)", "1-0": "ViroViewARCore features\n(3D rendering with AR Core)", "2-0": "ViroViewGVR features\n(3D Rendering with VR)", "0-1": "API level 18, as restricted by [OpenGL ES 3.0](https://developer.android.com/guide/topics/graphics/opengl.html).", "1-1": "[API level 24](https://developers.google.com/ar/develop/java/enable-arcore) for an AR Required App.", "2-1": "[API level 19 for cardboard compatibility.](https://developers.google.com/vr/develop/android/get-started)\n[API level 25 for daydream compatibility.](https://developers.google.com/vr/develop/android/get-started)" }, "cols": 2, "rows": 3 } [/block] You can also target a wider range of Android SDK versions by building a hybrid application made out of mutually exclusive 3D ViroCore and 2D Android layout experiences. These applications delay the creation and use of AR / VR components and only inflates them on an AR / VR capable device. Else, on non-compatible devices, developers can then display their original 2D Android content as per normal. This drastically helps increase the application's audience size and reach. [block:api-header] { "title": "Additional Android Device Type Support" } [/block] An application's audience size, or the number of supported devices are ultimately defined by the Google Play Store. It filters out in-compatible devices, based on defined features in your manifest file. For example, devices without gyroscope sensors will be deemed incompatible if your app defines a gyroscope uses-feature in your manifest. For VR / AR, features like openGL, accelerometer and gyroscopes are required. However, for hybrid apps with exclusive 2D + optional AR experiences, there are situations where you may not want to use the gyroscope sensor at all - say, for your non-AR experiences on older devices. Currently, your app is ultimately 'blocked' from being downloaded by a larger audience with incompatible device types. For example, the gyroscope uses-feature tag required for AR then effectively blocks a large portion of your customers from downloading your app (those who don't have a gyroscope sensor), **even though your app is "AR Optional" and has an exclusive 2D layout experience!** Thus, to get around this problem, we've provided you a list of **uses-feature overrides** that you can define in your manifest as shown below. These overrides effectively makes required features (like gyroscope / openGL / camera) optional instead. As a result, the Google Play store will then be able to identify a larger selection of compatible devices, where you can then dynamically determine AR/VR/Rendering capability and inflate your Android 2D or Viro Core 3D views as needed. [block:callout] { "type": "danger", "title": "When using Overriding <uses-feature> Tags:", "body": "Note: Because Google Play no longer has the feature tags that are overwritten to filters apps by device compatibility, **developers are responsible for dynamically checking required uses-features that are needed for AR / VR rendering**. As such for every uses-feature that you override with, ensure that you dynamically check for this feature in Java before loading the desired AR / VR experience!" } [/block] Note that you can also pick any set of overrides above that you desire: [block:code] { "codes": [ { "code": "<uses-feature android:glEsVersion=\"0x00030000\" android:required=\"false\" tools:node=\"remove\" tools:replace=\"required\" />\n<uses-feature android:name=\"android.hardware.sensor.accelerometer\" android:required=\"false\" tools:replace=\"required\" />\n<uses-feature android:name=\"android.hardware.sensor.gyroscope\" android:required=\"false\" tools:replace=\"required\" />\n<uses-feature android:name=\"android.hardware.camera\" android:required=\"false\" tools:replace=\"required\" />\n<uses-feature android:name=\"android.hardware.microphone\" android:required=\"false\" tools:replace=\"required\" />", "language": "xml", "name": "uses-feature overrides" } ] } [/block] Here's an example of the total number of supported devices that you can target on the Google Play store with the above overrides on a Viro Core Hello World AR project: [block:image] { "images": [ { "image": [ "https://files.readme.io/026aa04-Screen_Shot_2018-03-02_at_11.44.35_AM.png", "Screen Shot 2018-03-02 at 11.44.35 AM.png", 1960, 344, "#3b6885" ] } ] } [/block] [block:api-header] { "title": "ABI Splitting" } [/block] ViroCore includes architectures for two generations of ARM devices: armeabi-v7a and arm64-v8a. This means both of these will be packaged in your APK -- even though your customers only need one or the other. To ensure that your customers only receive the ABI they need, we recommend using Android's [ABI splitting feature](https://developer.android.com/studio/build/configure-apk-splits.html). This will dramatically reduce the binary size of your app. To use ABI splitting, add a splits block to your module-level build.gradle file. In the example below, we produce on APK for armeabi-v7a architectures, and one for arm64-v8a architectures. This is the recommended configuration for apps using Viro. [block:code] { "codes": [ { "code": "android {\n ...\n splits {\n abi {\n enable true\n reset()\n\n // Specifies a list of ABIs that Gradle should create APKs for\n include \"armeabi-v7a\", \"arm64-v8a\"\n\n // Specifies that we do not want to also generate a universal APK that includes all ABIs\n universalApk false\n }\n }\n}", "language": "groovy" } ] } [/block] Once you've added this to your gradle, select the module in the Project Pane and build with ```Build > Build APK```. The APKs for each ABI will be placed in the project's ```build/outputs/apk/``` directory.