我需要开发一个可以支持从 4.0 到最新的 android 版本的应用程序。但由于这是我的第一个应用程序,我开始使用 android jetpack 组件等进行开发。我的问题是可以使用 androidX 支持库来支持旧版本的设备还是我必须从头开始制作一个新应用程序?如果我可以使用 androidX 支持库从 min sdk 26 迁移到 14,请帮助我提供任何示例。这是我的依赖项:
dependencies {
def room_version = "2.2.6"
compileOnly "com.squareup.inject:assisted-inject-annotations-dagger2:0.5.2"
kapt "androidx.room:room-compiler:$room_version"
kapt "com.google.dagger:hilt-android-compiler:2.30.1-alpha"
kapt "androidx.hilt:hilt-compiler:1.0.0-alpha02"
kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.5.2'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation "androidx.activity:activity-ktx:1.1.0"
implementation 'com.google.android.material:material:1.2.1'
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation "androidx.fragment:fragment-ktx:1.2.5"
def nav_version = "2.3.2"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"
implementation 'com.squareup.picasso:picasso:2.71828'
implementation "com.google.dagger:hilt-android:2.30.1-alpha"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
并构建脚本
buildscript {
ext.kotlin_version = "1.4.10"
repositories {
google()
jcenter()
}
dependencies {
def nav_version = "2.3.2"
ext.hilt_version = '2.28-alpha'
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}