Skip to main content
2 de 3
se añadieron 4747 caracteres en el cuerpo

Problema con las clases duplicadas en Android Studio con Kotlin

soy novato en esto y necesito que alguien me ayude con el siguiente error: Estoy desarrollando una app con Realidad Aumentada con Android Studio en Lenguaje Kotlin. Al momento de ejecutar la aplicación me aparecen estos errores y la verdad no entiendo que toca hacer.

Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.10.1-runtime (androidx.core:core:1.10.1) and support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0) Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.10.1-runtime (androidx.core:core:1.10.1) and support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0) Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.10.1-runtime (androidx.core:core:1.10.1) and support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0) Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.10.1-runtime (androidx.core:core:1.10.1) and support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0) Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.10.1-runtime (androidx.core:core:1.10.1) and support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0) Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.10.1-runtime (androidx.core:core:1.10.1) and support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0) Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.10.1-runtime (androidx.core:core:1.10.1) and support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0) Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.10.1-runtime (androidx.core:core:1.10.1) and support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0) Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.10.1-runtime (androidx.core:core:1.10.1) and support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0) Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.10.1-runtime (androidx.core:core:1.10.1) and support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0)

Este es el código Kotlin

import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.Toast
import com.google.ar.core.Anchor
import com.google.ar.core.HitResult
import com.google.ar.core.Plane
import com.google.ar.sceneform.AnchorNode
import com.google.ar.sceneform.rendering.ModelRenderable
import com.google.ar.sceneform.ux.ArFragment
import com.google.ar.sceneform.ux.TransformableNode
import com.joanhac.realidadaumentada.R

class MainActivity : AppCompatActivity() {

private lateinit var arFragment: ArFragment
private lateinit var model1Button: ImageButton
private lateinit var model2Button: ImageButton
private lateinit var model3Button: ImageButton
private lateinit var model4Button: ImageButton
private lateinit var model5Button: ImageButton
private var model: ModelRenderable? = null

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    arFragment = supportFragmentManager.findFragmentById(R.id.sceneView) as ArFragment
    model1Button = findViewById(R.id.buttonModel1)
    model2Button = findViewById(R.id.buttonModel2)
    model3Button = findViewById(R.id.buttonModel3)
    model4Button = findViewById(R.id.buttonModel4)
    model5Button = findViewById(R.id.buttonModel5)

    model1Button.setOnClickListener { loadModel(R.raw.horse) }
    model2Button.setOnClickListener { loadModel(R.raw.horse) }
    model3Button.setOnClickListener { loadModel(R.raw.horse) }
    model4Button.setOnClickListener { loadModel(R.raw.horse) }
    model5Button.setOnClickListener { loadModel(R.raw.horse) }

    arFragment.setOnTapArPlaneListener { hitResult: HitResult, plane: Plane, motionEvent ->
        val anchor = hitResult.createAnchor()
        placeModel(anchor)
    }
}

private fun loadModel(modelResource: Int) {

    ModelRenderable.builder()
        .setSource(this, modelResource)
        .build()
        .thenAccept { modelRenderable -> model = modelRenderable }
        .exceptionally {
            Toast.makeText(this, "Error al cargar el modelo", Toast.LENGTH_SHORT).show()
            null
        }
}

private fun placeModel(anchor: Anchor) {
    model?.let { modelRenderable ->
        val anchorNode = AnchorNode(anchor)
        val transformableNode = TransformableNode(arFragment.transformationSystem)
        transformableNode.setParent(anchorNode)
        transformableNode.renderable = modelRenderable
        arFragment.arSceneView.scene.addChild(anchorNode)
        transformableNode.select()
    }
}

}