【发布时间】:2019-09-27 10:47:27
【问题描述】:
我使用了 Google Sceneform Tools(version1.12.0) 插件 for android ar。我在 API 级别 29 中使用了 pixel 2 模拟器。我显示以下错误
Error: Failed to create AR session
com.google.ar.core.exceptions.UnavailableException..........
Caused by: com.google.ar.core.exceptions.FatalException: Application manifest must contain meta-data com.google.ar.core
但我使用了下面的代码..
-
在清单文件中我使用了下面的代码..
<uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:glEsVersion="0x00030000" android:required="true" /> <uses-feature android:name="android.hardware.camera.ar" /> <application ... <activity android:name=".MainActivity"> <meta-data android:name="com.google.ar.core" android:value="required" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> -
我用过像下面这样的 gadle 文件
apply plugin: 'com.android.application' apply plugin: 'com.google.ar.sceneform.plugin' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.example.sceneform_ar" minSdkVersion 15 targetSdkVersion 26 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.12.0' } sceneform.asset('sampledata/models/bear.fbx', 'default', 'sampledata/models/bear.sfa', 'src/main/res/raw/bear') -
在活动 xml 中我使用了下面的代码..
<fragment android:name="com.google.ar.sceneform.ux.ArFragment" android:id="@+id/ux_fragment" android:layout_width="match_parent" android:layout_height="match_parent" /> -
我在 MainActivity 中使用了下面的代码
ModelRenderable.builder() .setSource(this, R.raw.bear) .build() .thenAccept(renderable -> bearRenderable = renderable) .exceptionally( throwable -> { Log.e("Errror***** >", "Unable to load Renderable.", throwable); return null; });它有什么问题?我不知道。你能帮我解决这个问题吗
【问题讨论】:
-
似乎没有下载AR元素。像移动视觉一样,它需要惰性下载库。所以请检查两件事。 1. 首次安装时使用移动数据 2. 使用应用程序标签内的元数据而不是活动标签
-
@TariqulIslam 谢谢先生,我已经解决了问题