Is there a way to code an application using Kotlin on Android Studio to upload data to ThingSpeak?

20 views (last 30 days)

I am attempting to take a user input value on an android application and then upload that value to ThingSpeak for further use. I am trying to use Android Studio and Kotlin, but I keep getting the same error. Any guidance will be much appreciated as I would just like to get the application to run. I have created a Button to execute and Two Texts - Number (Signed) for input.

Below is the code that I have attempted:

    import android.os.Bundle
  import android.view.View
  import android.widget.Button
  import androidx.appcompat.app.AppCompatActivity
  import com.squareup.okhttp.Request
  import com.squareup.okhttp.OkHttpClient
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
          val waterAmount = findViewById<View>(R.id.WaterAmount)
          val temperatureAmount = findViewById<View>(R.id.TemperatureAmount)
          val dispenseButton = findViewById<Button>(R.id.DispenseButton)
          dispenseButton.setOnClickListener {
              val okHttpClient = OkHttpClient()
              val builder: Request.Builder = Request.Builder()
              val request: Request = builder.url("https://api.thingspeak.com/update?api_key=APIKEY&field1=" + waterAmount).build()
          }
      }
}
The error that I keep receiving is:

Duplicate class org.objectweb.asm.AnnotationVisitor found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.AnnotationWriter found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Attribute found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.ByteVector found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.ClassReader found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.ClassVisitor found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.ClassWriter found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Edge found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.FieldVisitor found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.FieldWriter found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Frame found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Handler found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Item found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Label found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.MethodVisitor found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.MethodWriter found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Opcodes found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Type found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.signature.SignatureReader found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.signature.SignatureVisitor found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.signature.SignatureWriter found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0)

Go to the documentation to learn how to Fix dependency resolution errors.

Answers (1)

Sutanu Maiti
Sutanu Maiti on 2 Sep 2021
Edited: Sutanu Maiti on 2 Sep 2021
You may use Simulink® Support Package for Android™ Devices that will alow you to create an app without writing a single line of code. Simulink® Support Package for Android™ Devices has ThingSpeak Read and Write blocks that allows to update or retrieve data from a ThingSpeak channel.
For mor information about Simulink® Support Package for Android™ Devices please foolow the link below:
Below link explain how to use ThingSpeak Read/Write blocks:

Communities

More Answers in the  ThingSpeak Community

Categories

Find more on MATLAB Mobile in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by