0

I have this error

 Duplicate class com.google.ar.sceneform.lullmodel.TextureWrap found in modules jetified-core-1.21.0-runtime (com.gorisse.thomas.sceneform:core:1.21.0) and jetified-sceneform-base-1.15.0-runtime (com.google.ar.sceneform:sceneform-base:1.15.0)
 Duplicate class com.google.ar.sceneform.lullmodel.VariantArrayDef found in modules jetified-core-1.21.0-runtime (com.gorisse.thomas.sceneform:core:1.21.0) and jetified-sceneform-base-1.15.0-runtime (com.google.ar.sceneform:sceneform-base:1.15.0)
.  
.
.

Maybe com.gorisse.thomas.sceneform:core:1.21.0 and com.google.ar.sceneform:sceneform-base:1.15.0 has the same classname.

I googled around and found the solution here

It suggests to use shadow plugin like this below.

plugins {
   id "com.github.johnrengelman.shadow" version "5.2.0"
}
configurations {
   shadowMe { transitive = false } 
} 
dependencies {
   shadowMe 'foo:jar-to-shadow:1.0'
   compile files({tasks.shadowJar})
}
task shadowJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
   archiveBaseName = 'shadowed-foo' 
   relocate 'a.a.a.a.a', 'shadow.a.a.a.a'
   from zipTree(configurations.shadowMe.singleFile)
}

However where should I put this in flutter project?

android/build.gradle ,android/app/build.gradle, or any other place?

my android/app/build.gradle is here below

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 32
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
     
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.arcore_test"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion 24
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.ar:core:1.37.0'
    implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.15.0'
    implementation 'com.google.ar.sceneform:core:1.15.0'

}

my android/build.gradle is here below

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
whitebear
  • 11,200
  • 24
  • 114
  • 237

0 Answers0