我使用了Google Sceneform Tools(version1.12.0) 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
但是我使用了以下代码..
在 list 文件中我使用了以下代码..
<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')
在 Activity 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; });
这有什么问题吗?我不知道。你能帮我解决这个问题吗
最佳答案
愚蠢的错误,我在 MainActivity 中使用了以下代码
<meta-data android:name="com.google.ar.core" android:value="required" />
我的 list 将是..
<application
......">
<meta-data android:name="com.google.ar.core" android:value="required" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
关于android - 应用程序 list 必须包含元数据 com.google.ar.core android sceneform AR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58132998/