Android studio shows sources from API of compileSdkVersion when debugging on device with older API

前端 未结 5 1459
慢半拍i
慢半拍i 2020-12-13 12:46

I am debugging with Android Studio (A.S) 1.0.2 with compileSdkVersion 21 set up in build.gradle. When using an emulator with API 21 everything works fine. The problem occurs

5条回答
  •  忘掉有多难
    2020-12-13 13:36

    Answered with working solution here:

    https://stackoverflow.com/a/32236703/1267536

    Full content:

    I use appcompat support library quite a lot. Changing the compileSdkVersion only results in massive compile errors. If you are using appcompat-21, you must compile against api 21 or you will get compile errors.

    This works fine if you are debugging against version 21. But when you are debugging on Jelly Bean (API 17), your debugger keeps dropping you to the API 21 source. Very annoying and hard to debug.

    The solution I've ended up using is very hacky but works! Let's say you are trying to debug against API 17. Do the following:

    1. mv $ANDROID_HOME/sources/android-21 $ANDROID_HOME/sources/android-21-orig
    2. cp $ANDROID_HOME/sources/android-17 $ANDROID_HOME/sources/android-21
    3. restart android studio so it will pick up the correct paths.
    4. Debug

    Just don't forget to put all the directories back after you're done.

    Here's an android studio bug report about this issue: https://code.google.com/p/android/issues/detail?id=183976

提交回复
热议问题