0

I cannot debug a custom view. "No executable code found at line" message shown. Also on a MainActivity the debug works fine and stop on setText method, but in my custom view not. The debug cannot in to my custom view method. And on the other methods did not stop, like onDraw. How can I fix it?

I have tried to clean, rebuild and restart project. Instant run is disabled. The Android Studio 3.4.1 version.

buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }

        debug {
            debuggable true
            minifyEnabled false
        }
    }

class MainActivity : AppCompatActivity() {

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

        val pipsTextView = findViewById<PipsTextView>(R.id.pips_text_view)
        pipsTextView.setText("1123.23444", 5, 2, 3, -1)
    }
}

override fun setText(value: String, pipSize: Int, prePipSize: Int, floatingPipSize: Int, direction: Int) {
        this.pipSize = pipSize
        this.prePipSize = prePipSize
        this.floatingPipSize = floatingPipSize
        this.direction = if (direction < 0) DOWN else if (direction == 0) NEUTRAL else UP
        preparePipValues(value)
        invalidate()
    }

I expect the debug will work.

  • you setup a breakpoint in `setText` and it stops there? so if it doesnt stop in your custom view method it means that it is not called – pskink Jun 16 '19 at 13:31
  • No the `setText` is called. I cannot fix it properly, but after 3th `clean and invalidate and restart -> clean -> rebuild` I got some result. Now I do not start project in Debug mode. I start and then attach the process to debug, now the debug stops in `preparePipValues(values)` method in the `setText` method. It is very strange behaviour. On the Java I never got this issue. – Valerii Popov Jun 16 '19 at 13:43

1 Answers1

0

Based on this question, the following steps may help you:

  1. If you are using Maven dependencies, go to Maven Projects -> refresh
  2. If that does not work, Try top menu --> Build --> Rebuild Project
  3. If that still doesn't work, try top menu --> File --> Invalidate Cache/Restart
  4. If that still doesn't work, then $CATALINA_BASE/bin/catalina.sh stop, then start

After this, usually it covers 99% of the problems. Otherwise, Probably you will have to examine some other possibilities.

Payam Asefi
  • 2,677
  • 2
  • 15
  • 26