Манифест приложения должен содержать метаданные com.google.ar.core andform sceneform AR - PullRequest
0 голосов
/ 27 сентября 2019

Я использовал Google Sceneform Tools (версия1.12.0) Плагин для Android Ar.Я использовал эмулятор pixel 2 на уровне API 29 .Я показываю ниже ошибку

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

Но я использовал ниже код ..

  1. В файле манифеста я использовал ниже код ..

      <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>
    
  2. Я использовал файл гаджета, как показано ниже

    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')
    
  3. В работе 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" />
    
  4. Я использовал приведенный ниже код в 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;
                    });
    

    Что с ним не так?Я не знаю.Можете ли вы помочь мне решить эту проблему

1 Ответ

0 голосов
/ 27 сентября 2019

Глупая ошибка. Я использовал приведенный ниже код внутри MainActivity

<meta-data android:name="com.google.ar.core" android:value="required" />

Мой манифест будет ..

 <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>
...