2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ARCore SDK(Java)の Duplicate class 問題

Last updated at Posted at 2021-08-16

ARCore の開発を行っていて、困っていた問題が解決したのでメモ

発生していた問題

ARCore SDK の内部のクラスが a.a.a という名前となっているため、他の Google ライブラリと競合が発生してしまうことがあった

build.gradle
implementation 'com.google.ar:core:1.25.0'
implementation 'com.android.installreferrer:installreferrer:2.2'
Duplicate class a.a.a found in modules jetified-core-1.25.0-runtime (com.google.ar:core:1.24.5) and jetified-installreferrer-2.2-runtime (com.android.installreferrer:installreferrer:2.2)

Github の issue
https://github.com/google-ar/arcore-android-sdk/issues/1140

1.26.0 で解消を確認

対処法(1.25.0まで)

shadowJar などで無理やり書き換え

{project}/build.gradle
buildscript {

    repositories {
        google()
        gradlePluginPortal()
    }
    dependencies {
        classpath fileTree(dir: 'libs', include: '*.jar')
        // Android Studio で使うには Gradle 7以上が必要
        classpath 'com.android.tools.build:gradle:7.0.0'
        classpath 'gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0'
    }
}

build.gradle にタスクを追記

build.gradle
assemble.dependsOn {tasks.shadowJar}

task shadowJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
    archiveBaseName = 'shadow-com.google.ar'
    relocate 'a.a.a', 'a.a.c'
    from zipTree(project.configurations.shadowMe.singleFile)
}


注意点

同じ問題は sceneform などでも起きるため、そちらは対応待ちとなる
google-ar/sceneform-android-sdk は更新されていないため、 ThomasGorisse/sceneform-android-sdk は更新待ちとなる

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?