简体   繁体   English

使用Android Studio调试旧版Android

[英]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. 我使用Android 23版进行开发。但是现在,我想调试仅安装19版的设备。

To do it I changed my gradle file to 为此,我将gradle文件更改为

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.+' 无法解析“ 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. 这是我的build.gradle的示例,并且可以在API 19设备上正常运行。

Few things to note are that you don't need to decrement the compile SDK. 需要注意的几件事是您不需要减少编译SDK。 This is like having Java 8 installed, but compiling Java 6 code. 这就像安装了Java 8,但编译Java 6代码一样。 It still works. 它仍然有效。

Also, I think the appcompat-v7 library depends on the support-v4 library, so you don't need to include that. 另外,我认为appcompat-v7库依赖于support-v4库,因此您无需包括该库。

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.+'然后尝试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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