Search code examples
androidunity-game-enginearcore

Program type already present: android.media.VisibleImage error when I am Using Unity library (With ARCore) in Android native project (With ARCore)


I'm trying to build an app using ARcore. Everything worked fine, but I can't implement some requirements in Android Native app, so we chosen Unity for that. We have implemented ARCore in Unity library Project. Then we have implemented that Unity library project into the Android basic app(Native app without ARCore). It worked fine, but If I am implementing unity library project in Native Android project with ARCore I am getting a conflict error.

This is my app dependency :

dependencies {
    // ARCore library
    implementation 'com.google.ar:core:1.1.0'

    // Obj - a simple Wavefront OBJ file loader
    // https://github.com/javagl/Obj
    implementation 'de.javagl:obj:0.2.1'
    implementation project(':unity_ar_library')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'

    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
}

This is unity Library dependency :

 implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':arcore_client')
    implementation project(':google_ar_required')
    implementation project(':unitygar')
    implementation project(':unityandroidpermissions') 

I am getting this error :

Program type already present: android.media.VisibleImage$Plane
Message{kind=ERROR, text=Program type already present: android.media.VisibleImage$Plane, sources=[Unknown source file], tool name=Optional.of(D8)}

Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\32, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\externalLibsDexMerger\debug\0, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\26.jar, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\27.jar, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\29.jar, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\30.jar, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\31.jar

Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\32, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\externalLibsDexMerger\debug\0, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\26.jar, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\27.jar, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\29.jar, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\30.jar, E:\AR_New\arcore-android-sdk-master\samples\hello_ar_java\app\build\intermediates\transforms\dexBuilder\debug\31.jar

com.android.tools.r8.CompilationFailedException: Compilation failed to complete 

com.android.tools.r8.utils.AbortException   

You can tell me if there is anything else to add to understand what I'm doing or where I'm wrong.

I have tried to change Android support libraries version but it didn't help.

If I remove Unity project, my native ARCore project is working. If I am using Unity Library AR core project in another native android app (Without ARCore)it is working fine.


Solution

  • As I have mentioned in my question I have used 1.1.0 AR Core version in my native app.

     // ARCore library
        implementation 'com.google.ar:core:1.1.0'
    

    In unity Android library they too used the same 1.1.0 version

    We have tried to downgrade the Ar core version to 1.0.0 on both (In android native app and also in unity library) then the android.media.VisibleImage error resolved.

    This above mentioned error only happened on 1.1.0 AR core version