簡體   English   中英

設計支持庫中不同模塊的Android SDK兼容性

[英]Android SDK compatibility for different modules from the Design Support Library

我想在我的應用程序中創建一個底部導航,並通過Material Design提供的底部導航找到了一種簡單的方法。

我唯一的問題是我希望該應用程序在Android SDK 23上運行,並且我可以看到從Material的底部導航需要compile 'com.android.support:design:25.0.0' ,而該文件需要'com.android.support:appcompat-v7:25.0.0' 目前,我正在使用23.4.0並且我假設更改此設置將使我的應用程序只能在Android SDK 25及更高版本上運行。

這個對嗎?

不,那是不正確的。 編譯版本和最低版本之間有很大的重要區別。 此更改僅在編譯版本中。

  • 編譯版本是編譯器在編譯代碼時將查看的版本。 這只是讓編譯器知道設備上可用的方法。 例如,要知道一個Activity有一個findViewById ,一個ViewGroup有一個addView 只要您不使用高於最小值的方法就沒有區別。

  • 最低版本是您要告訴Google Play和Android系統的最低版本,可以在該版本中安裝您的應用,並且該版本應能正常運行。 那是限制可以安裝哪個版本的版本。

有關更多信息,我建議您在https://developer.android.com/training/material/compatibility.html上閱讀官方培訓材料,更具體地說,在“檢查系統版本”部分https://developer.android中閱讀。 com / training / material / compatibility.html#CheckVersion

不用擔心,您指的是compile 'com.android.support:design:25.0.0這只是您的依賴項,因此首先

1.-如果要使用'com.android.support:design:25.0.0 ,則應至少使用建築版本25:

compileSdkVersion 25
buildToolsVersion '25.0.0'

2.-如果您在gradle中定義了小於25的最小SDK或目標SDK,則您的應用程序可與'com.android.support:design:25.0.0一起使用:

minSdkVersion 15
targetSdkVersion 25

現在看一下這個問題,來自適用於API 19的應用程序,並且底部導航視圖可以正常工作

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.0'
    defaultConfig {
        applicationId "**********"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    dexOptions {
        jumboMode true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:support-v4:25.3.0'
    compile 'com.android.support:design:25.3.0'
    compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
    testCompile 'junit:junit:4.12'
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM