0

I have browsed through the logcat and found this error.

    2022-05-03 12:48:40.132 6288-6288/? E/ng:quick_launc: Not starting debugger since process cannot load the jdwp agent.
    2022-05-03 12:48:40.303 6331-6331/? E/.apps.messagin: Not starting debugger since process cannot load the jdwp agent.
    2022-05-03 12:48:40.343 6350-6350/? E/id.partnersetu: Not starting debugger since process cannot load the jdwp agent.

I am unable to find anything anywhere to mend this problem. I have no idea how to solve this, I have listed my code below.

The

My xml code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical">

    <TextView
        android:id="@+id/tv_input"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:background="#efefef"
        android:textSize="48sp"
        android:maxLength="12"
        ></TextView>
    <!-- Row1 -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        >
        <Button
            android:id="@+id/seven"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="7"
            android:onClick="onDigit"
            />
        <Button
            android:id="@+id/eight"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="8"
            android:onClick="onDigit"
            />
        <Button
            android:id="@+id/nine"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="9"
            android:onClick="onDigit"
            />

        <Button
            android:id="@+id/divide"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="/"
            android:onClick="onDigit"


            />
    </LinearLayout>
    <!-- Row2 -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        >
        <Button
            android:id="@+id/four"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="4"
            android:onClick="onDigit"
            />
        <Button
            android:id="@+id/five"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="5"
            android:onClick="onDigit"
            />
        <Button
            android:id="@+id/six"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="6"
            android:onClick="onDigit"
            />

        <Button
            android:id="@+id/multiplication"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="x"
            android:onClick="onDigit"
            />
    </LinearLayout>
    <!-- Row3 -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:layout_weight="1"
        android:orientation="horizontal"

        >
        <Button
            android:id="@+id/one"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="1"
            android:onClick="onDigit"

            />
        <Button
            android:id="@+id/two"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="2"
            android:onClick="onDigit"
            />
        <Button
            android:id="@+id/three"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="3"
            android:onClick="onDigit"
            />

        <Button
            android:id="@+id/addition"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="+"
            android:onClick="onDigit"
            />
    </LinearLayout>
    <!-- Row4 -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        >
        <Button
            android:id="@+id/zero"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="0"
            android:onClick="onDigit"
            />
        <Button
            android:id="@+id/decimal_point"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="."
            android:onClick="onDigit"
            />
        <Button
            android:id="@+id/backspace"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="CLR"
            android:onClick= "Onclear"
             />

        <Button
            android:id="@+id/Minus"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="-"
            android:onClick="onDigit"

            />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:orientation="horizontal"

        >
        <Button
            android:id="@+id/equal"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text = "="
            android:width="30dp"
            android:onClick="onDigit"

            />
    </LinearLayout>

</LinearLayout>

I have tried commenting everything out line by line, however I can't seem to find the source of the problem.

Kotlin code

package com.example.mycalculatorapp

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.TextView
import android.widget.Toast



class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
    var tv_input = findViewById<TextView>(R.id.tv_input)
    var lastnumeric = false
    var lastdot = false

    fun onDigit(view: View) {


        tv_input.append((view as Button).text)
        lastnumeric = true
    }
    fun Onclear (view: View){

        tv_input.text = ""
        lastnumeric = false
        lastdot = false

    }

    fun ondecimalpoint(view: View){
        if(lastnumeric && !lastdot){

            tv_input.append(".")
            lastnumeric = false
            lastdot = true
        }
    }

    fun  onoperator(view: View){
        if(lastnumeric && !isoperatoraddded(tv_input.text.toString())){
            tv_input.append((view as Button).text)
            lastnumeric = false
            lastdot = true
        }

    }
    private fun isoperatoraddded(value:String):Boolean{
        return if (value.startsWith("-")){
            false
        }else{
            value.contains("/") || value.contains("*")
                    ||value.contains("+")|| value.contains("-")
        }
    }
}
AIboi
  • 43
  • 4
  • there's a massive difference between compile time errors and runtime errors. dividing by zero won't cause compile time errors, nullpointers won't cause compile time errors, etc. find the actual cause of the crash – a_local_nobody May 03 '22 at 11:02
  • 2
    Having error log messages doesn't mean there is a crash or that there is something wrong with your app. They could even not be from your app at all – Ivo May 03 '22 at 11:25
  • 1
    So your app is running fine, but you are concerned about errors in logcat? That is a non-issue, there are always tons of logcat errors from other processes and stuff - unless you have good reason to believe it's from your app you can ignore those. – Tyler V May 03 '22 at 11:48

0 Answers0