google-ar / arcore-android-sdk

ARCore SDK for Android Studio
https://developers.google.com/ar
Other
4.91k stars 1.2k forks source link

Arcore cannot be included in dynamic feature module with shrinkResources enabled #1657

Closed sangrao closed 2 weeks ago

sangrao commented 3 weeks ago

When arcore dependency is included in featuremodule with base app that uses shrinkResource build feature, build fails with the following error message when attempting to make the App bundle/apk.

Resource table of module contains references to non-existing files: [res/raw/keep_arcore.xml]

VERSIONS USED

STEPS TO REPRODUCE THE ISSUE

  1. run makeApkFromBundleForDebug from the attached demo project shrinkResourceExample.zip

    ADDITIONAL COMMENTS

devbridie commented 3 weeks ago

Here's a workaround for you:

Add module/src/res/raw/keep.xml with the following contents:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:keep="
       @raw/keep_arcore,
       @raw/keep"
    />

I can't see the resources in the output artifacts so this should be minified.

sangrao commented 2 weeks ago

Thanks, the suggestion in https://github.com/google-ar/arcore-android-sdk/issues/1657#issuecomment-2152894739 worked.