Development Tip

Android Studio에서 앱을 디버그 할 수 없음

yourdevel 2020. 10. 30. 21:09
반응형

Android Studio에서 앱을 디버그 할 수 없음


Android Studio에서 앱을 만들고 있으며 이제 adb를 통해 디버그하려고합니다. Android라는 단어와 하단 표시 줄의 로고를 클릭하면 logcat이 나타나 내 장치를 인식합니다. 그러면 나는 이것을 본다.

스크린 샷

내 앱을 "디버깅 가능"하게하려면 어떻게해야합니까?

참고로 이전에 Eclipse에서이 앱을 개발하고 있었는데 adb가 잘 작동했습니다.


도구 모음에 디버그 아이콘 이 있습니다 . 작은 "버그" 처럼 보이며 실행 아이콘 (재생 버튼 모양) 바로 옆에 있습니다 . 그것으로 응용 프로그램을 시작하십시오.

디버그하려면 여기를 클릭하십시오.

편집 : Gradle과 함께 Android Studio를 사용할 때 다음은 더 이상 사용되지 않습니다.

AndroidManifest.xml 파일 에도 디버그 플래그가 있습니다. 애플리케이션 태그 아래에 있으며 다음과 같이 "true"로 설정해야합니다.

<application android:debuggable="true">
</application>

다음 단계를 수행 한 후이 문제를 해결했습니다.

Tools ==> android ==> ADB 통합 비활성화로 이동하고 다시 활성화하십시오.

그런 다음 장치에서 USB를 분리하고 다시 연결하십시오.

마지막으로 Shift + F9를 누릅니다.


주의해야 할 또 다른 사항은 (이렇게 했으므로 알아요). 디버그를 위해 Proguard를 활성화하지 마십시오!


Android Studio에서 여러 번 디버깅 한 후에도 무작위 로이 문제가 발생했습니다. 언젠가 디버거가 연결되지 않았습니다. Android Studio를 종료하고 다시 열면 디버거가 다시 작동하기 시작했습니다.


이것은 나를 위해 일했습니다.

  1. Android Studio를 닫습니다.
  2. 셸을 열고 다음과 같이 작성합니다.

    adb kill-server

    adb start-server


    <application android:debuggable="true">
</application>

더 이상 작동하지 않습니다! 매니페스트에서 debuggable = "true"를 사용할 필요가 없습니다.

대신 빌드 변형을 "디버그"로 설정해야합니다.

디버그 모드

Android Studio에서 BUILD- > Build Variant 선택

이제 디버깅을 시도하십시오. 감사


ADB 통합을 활성화했는지 확인하십시오.

메뉴에서 : 도구-> Android-> ADB 통합 활성화 (v1.0)


응용 프로그램을 디버깅 할 수 있었는데 갑자기 더 이상 디버깅 할 수없는 경우 여기에 내 솔루션이 있습니다.

  1. USB debug전화기에서 스위치를 비활성화하고 활성화 하십시오.
  2. 애플리케이션을 제거하십시오.
  3. Android Studio에서 실행을 클릭하십시오.

Android 스튜디오에서 애플리케이션을 디버깅 할 수없는 한 가지 경우는 'release'빌드 변형을 선택한 경우입니다. 나에게 일어난 일-Gradle이 앱의 릴리스 버전 (디버깅 할 수 없음)을 빌드 한 다음 Android Studio가 디버거 연결에 실패합니다.


Manifest 파일에서 사용자 정의 "android : process"를 설정할 때 "디버거를 Android 프로세스에 연결"아이콘이 사용됩니다.
제 경우에는 적절한 프로세스를 선택하고 "Wait for debugger"대화 상자가 나타난 직후에 OK 버튼을 클릭해야합니다.
여기에 이미지 설명 입력


이것은 때때로 나에게 발생하며 아직 그 이유를 파악하지 못했습니다. 이미 게시 된 솔루션 중 어느 것도 나를 위해 일하지 않았습니다. 나를 위해 작동하는 유일한 것은 다음과 같습니다.

  1. 장치에서 응용 프로그램을 제거합니다.
  2. 깨끗한 프로젝트. "빌드-> 클린 프로젝트."
  3. 다시 빌드하고 설치하십시오.

디버그 버튼 옆의 드롭 다운 메뉴에서 앱 프로젝트가 선택되어 있는지 확인합니다. 때때로 Android Studio는이 선택을 재설정합니다.

여기에 이미지 설명 입력


또한 예를 들어 Eclipse와 같이 ADB를 사용할 수있는 다른 응용 프로그램을 사용하고 있지 않은지 확인하십시오.


활성화하면

<application android:debuggable="true">
</application>

애플리케이션 manifest.xml 에서 최종 서명 된 apk를 생성 할 때이를 비활성화해야합니다. 이는 공격자의 보안 루프 구멍으로 작용할 수 있기 때문입니다. 애플리케이션 중 하나만 로그를 표시하지 않는 경우에만 사용하십시오. 그러나 해당 옵션을 고려하기 전에 다음을 시도하십시오.

Android Studio의 도구로 이동

 Tools==>android==>disable adb integration and again enable it

아래 명령을 사용하여 깨끗한 빌드를했습니다 .. 놀랍게도 작동했습니다.

sh gradlew 깨끗한 빌드

누군가가 도움을 받기를 바랍니다!


디바이스 또는 에뮬레이터에서 개발자 모드 및 USB 디버깅을 활성화해야합니다. (새로 설정할 때 잊기 쉽습니다.)


또한 Tools-> Android-> Enable ADB Integration이 활성화되어 있어야합니다.


나는 모든 방법을 테스트했지만 그들 중 아무것도 작동하지 않았습니다 !!!

마침내 adb 포트를 변경해야했고 작동했습니다. 먼저 아래와 같이 adb 서버를 종료하십시오.

adb kill-server

그런 다음 다른 포트를 사용하여 다시 시작하십시오.

adb -P 5038 start-server

이것은 내 문제를 해결했습니다. 기기에서 앱을 제거하고 Android 스튜디오를 통해 다시 실행하세요.


여기에 약간의 문제가있을 수 있습니다. 실수로 logcat 출력 창 (돋보기가있는 텍스트 상자)에 필터를 입력하고 잊어 버리는 것은 매우 쉽습니다. 잠재적으로 모든 출력을 필터링하여 아무것도없는 것처럼 보이게합니다.


내 경우에는 줄 근처에 빨간색 원이 빨간색 원과 함께 빨간색 원이 표시되고 "행에 실행 가능한 코드가 없습니다 ..."라는 메시지가 표시됩니다. Android 스튜디오 gradle 중단 점 에서와 같이 실행 가능한 코드가 없습니다 .

을 (를) 업데이트 한 후 문제가 발생했습니다 build.gradle. Kotlin 지원을 포함하여 많은 메서드가 64K를 초과했습니다. 문제 라인 :

buildTypes {
    debug {
        minifyEnabled true

다음으로 변경하십시오.

buildTypes {
    debug {
        minifyEnabled false
        debuggable true

그런 다음 "Sync Project with Gradle Files"버튼으로 gradle을 동기화합니다. 애플리케이션을 다시 시작한 후 "오류 : .dex 파일의 메서드 참조 수는 64K를 초과 할 수 없습니다. https://developer.android.com/tools/building/ 에서이 문제를 해결하는 방법을 알아보세요. multidex.html "그런 다음 .dex 파일의 메서드 참조 수는 64k API 17을 초과 할 수 없습니다 . 다음 줄을 다음에 추가합니다 build.gradle.

android {

    defaultConfig {
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
    implementation 'com.android.support:multidex:1.0.2'
}

최신 정보

에 따르면 https://developer.android.com/studio/build/multidex.html 안드로이드 5.0 아래 multidex 지원을 활성화하려면 다음을 수행하십시오. 그렇지 않으면 이러한 장치에서 시작되지 않습니다.

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>

In my case, Had to remove the proguard in debug Build Type by completely clearing the text file proguard-rules.pro and making minifyEnabled false in build.gradle file

  debug {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

In my case I had the same problem because I try to debug signed apk. In my gradle config I made differents build variants, and try to debug release build with production keystore.jks


For me, it happened when I used Proguard, so by trying all the solutions I cleaned my project and pressed the debug button on Android Studio and it started debugging


<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.

여기에 이미지 설명 입력


What worked for me in Android Studio 3.2.1

Was:

RUN -> Attach debugger to Android Process --> com.my app


Over the years I have visited this thread many times and there was always a different response that helped me. This time I figure out that it's my USB hub that was preventing debugger to work properly. As strange as it sounds, instead of having a phone connected to my computer via a USB hub, I had to connect it directly to my mac and debugging started to work.


I had same problem and I tried almost all kinds of solutions via Google. But I couldn't solve it. Finally, I found the solution. This is Android Studio Bug.

Do not click Run (Alt + F10) — just click Debug (Shift + F9).

Then Android Studio will show you the Warnning Message with ADB, Then Just click "OK".

You can see log in logcat console. And Packages will be shown on DDMS(Devices).

참고 URL : https://stackoverflow.com/questions/16753939/not-able-to-debug-app-in-android-studio

반응형