Not Able To Debug App In Android Studio

前端 未结 30 2576
小蘑菇
小蘑菇 2020-12-01 02:30

I am making an app in Android Studio, now trying to debug it through adb. When I click on the word Android and the logo on the bottom bar, logcat comes up and recognizes my

相关标签:
30条回答
  • 2020-12-01 02:59

    In my case near any line a red circle appeared with a cross and red line with a message: "No executable code found at line ..." like in Android studio gradle breakpoint No executable code found at line.

    A problem appeared after updating of build.gradle. We included Kotlin support, so a number of methods exceeded 64K. Problem lines:

    buildTypes {
        debug {
            minifyEnabled true
    

    Change them to:

    buildTypes {
        debug {
            minifyEnabled false
            debuggable true
    

    Then sync a gradle with a button "Sync Project with Gradle Files". If after restarting of your application you will get an error: "Error:The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html", then, like in The number of method references in a .dex file cannot exceed 64k API 17 add the following lines to build.gradle:

    android {
    
        defaultConfig {
            ...
    
            // Enabling multidex support.
            multiDexEnabled true
        }
        ...
    }
    
    dependencies {
        implementation 'com.android.support:multidex:1.0.2'
    }
    

    UPDATE

    According to https://developer.android.com/studio/build/multidex.html do the following to enable multidex support below Android 5.0. Else it won't start in these devices.

    Open AndroidManifest and find tag <application>. Near android:name= is a reference to an Application class. Open this class. Extend Application class with MultiDexApplication so:

    public class MyApplication extends MultiDexApplication { ... }
    

    If no Application class set, write so:

    <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
    
    0 讨论(0)
  • 2020-12-01 03:03

    I tested all ways and non of them worked !!!

    finally had to change the adb port and it worked. first kill adb server like below:

    adb kill-server
    

    then restart it using another port

    adb -P 5038 start-server
    
    0 讨论(0)
  • 2020-12-01 03:04

    This occasionally happens to me and I have yet to figure out why. None of the already posted solutions have worked for me. The only thing that works for me is to:

    1. Uninstall application from device.
    2. Clean Project. "Build -> Clean Project."
    3. Rebuild and install.
    0 讨论(0)
  • 2020-12-01 03:04

    I was able to fix it by going to Run -> Edit Configurations, selecting my project, selecting the Debugger tab, then changing 'Debug type' from 'Auto' to 'Dual':

    0 讨论(0)
  • 2020-12-01 03:05

    Restart the adb server, from android studio: Tools -> "Troubleshhot Device Connection"

    0 讨论(0)
  • 2020-12-01 03:06
    <application android:debuggable="true">
    </application>
    

    That above code is not longer a solution. You need to enable debugging inside your build.gradle file. If you have different buildTypes make sure you set "debuggable true" in one of the build types. Here is a sample code from one of my projects.

    buildTypes {
        debug {
            debuggable true
        }
    
        release {
            debuggable false
        }
    }
    

    **I have deleted other lines inside the buildTypes which are not relevant to this question from my gradle file here.

    Also Make sure you select the correct build variant in your android studio while doing the debugging.

    0 讨论(0)
提交回复
热议问题