Search code examples
androidandroid-manifestarcore

Error meta-data with ARCore in AndroidStudio


I try to follow this guide for ARCore in Android Studio : https://developers.google.com/ar/develop/java/enable-arcore#manifest

I follow the steps but when I try to check if ARCore is supported on the device i have an error :

E/ARCore-ArCoreApk: Error while checking app details and ARCore status
com.google.ar.core.exceptions.FatalException: Application manifest must contain meta-data com.google.ar.core.min_apk_version
    at com.google.ar.core.k.e(ArCoreApkImpl.java:41)
    at com.google.ar.core.k.b(ArCoreApkImpl.java:52)
    at com.google.ar.core.k.checkAvailability(ArCoreApkImpl.java:5)

I don't understand why i should specify the min apk version in the manifest. I have it in the build.gradle(:app) :

minSdkVersion 21

In the dependencies I have :

    implementation 'com.google.ar:core:1.18.0'

In the repositories I have :

    repositories {
    google()

In the manifest I have :

<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="XXXXX">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="Test"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    tools:node="replace"
    android:theme="@style/AppTheme">

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


    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="${applicationId}.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths" />
    </provider>

    <activity android:name=".MainActivity" android:screenOrientation="sensorLandscape"
        tools:ignore="LockedOrientationActivity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
</manifest>

In the class :

    public void Check_AR()
{
    ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(getApplicationContext());
    if (availability.isTransient())
    {
        // Re-query at 5Hz while compatibility is checked in the background.
        new Handler().postDelayed(new Runnable()
        {
            @Override
            public void run()
            {
                Check_AR();
            }
        }, 200);
    }
    if (availability.isSupported())
    {
        Flag_AR = true;
    }
    else
    { // Unsupported or unknown.
        Flag_AR = false;
    }
    Log.d("TAG", "Check_AR: " + Flag_AR);
}

Can anybody help me ? Thank you in advance !

EDIT : When i analyse APK in android studio, I can see that the uses-sdk is here and match the graddle. But I have an error on xmlns:android="http://schemas.android.com/apk/res/android" --> URI is not registred (Settings | Languages & FrameWorks | Schemas and DTDs) Can this be related ?


Solution

  • I found the answer. Just replace :

     tools:node="replace"
    

    by

    tools:node="merge"
    

    In the manifest.