Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: How to debug older version of Android SDK step-by-step

I have an Android project targetting the Android SDK v21. Now I need to debug it on a device with Android 4.4 (i.e. SDK v20). How do I tell Android Studio to attach an older version of the source to the internal classes so that I can step through them?

like image 893
Kirill Rakhman Avatar asked Apr 23 '15 12:04

Kirill Rakhman


People also ask

How do I fix Android SDK is missing or corrupted?

Quick fix: Go to the Tools –> SDK manager –> SDK tools. Deselect Hide obsolete packages option on the right bottom and further install Android SDK Tools(obsolete).

How can you debug your app when it's already released?

You can start a debugging session as follows: Set some breakpoints in the app code. In the toolbar, select a device to debug your app on from the target device drop-down menu. If you don't have any devices configured, then you need to either connect a device via USB or create an AVD to use the Android Emulator.


2 Answers

Here the best solution is to set compile SDK version to 20. So that build tools will compile your project using SDK version 20 and you can debug your app.

Setting Compile SDK version

When you use several modules in your project you need to set same compile SDK version to each module.

like image 155
Azim Ansari Avatar answered Sep 18 '22 19:09

Azim Ansari


I can not confirm my answer works, but it is working for me.

I replace my compileSdkVersion, buildToolsVersion, minSdkVersion and targetSdkVersion with new one like following in my build.gradle file.

android {       compileSdkVersion 22       buildToolsVersion "22.0.1"   defaultConfig {     applicationId "com.example.mytest"     minSdkVersion 15     targetSdkVersion 22     versionCode 1     versionName "1.0" } buildTypes {     release {         minifyEnabled false         proguardFiles getDefaultProguardFile('proguard-android.txt'),  'proguard-rules.pro'          }      } } 

After changing it, you may not need to convert old to new or new to old sdk component.

like image 35
Joseph Mekwan Avatar answered Sep 21 '22 19:09

Joseph Mekwan