简体   繁体   中英

Debug old Android version with Android Studio

I develop with Android version 23. But now I like to debug a device having only version 19 installed.

To do it I changed my gradle file to

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.mydomain.myapp"
        minSdkVersion 16
        targetSdkVersion 19
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile fileTree(include: ['dtp_library'], dir: 'libs')
    compile project(':libs:dtp_library')

    compile 'com.android.support:appcompat-v7:19.+'
    compile 'com.android.support:design:19.+'
    compile 'com.android.support:support-v4:19.+'        
}

But this line

compile 'com.android.support:design:19.+'

throws the compiler error

Failed to resolve 'com.android.support:design:19.+'

How to make it work?

This is a sample of my build.gradle and it runs absolutely fine on an API 19 device.

Few things to note are that you don't need to decrement the compile SDK. This is like having Java 8 installed, but compiling Java 6 code. It still works.

Also, I think the appcompat-v7 library depends on the support-v4 library, so you don't need to include that.

apply plugin: 'com.android.application'

repositories {
    jcenter()
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.androidstack.app"
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
}

ext {
    supportLibVersion = '23.2.1'  // variable that can be referenced to keep support libs consistent
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
}

删除compile 'com.android.support:design:19.+'然后尝试

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM