/JectpackTest

Jetpack学习的一些Demos

Primary LanguageJavaApache License 2.0Apache-2.0

ArchitectureComponentsTest——架构组件的一些demo

Demos

导入相关

  1. 根目录的**build.gradle**加入google repository

    allprojects {
        repositories {
            google()  //add google repository
            jcenter()
        }
    }
  2. 根目录的**build.gradle**或自定义的gradle文件定义全局版本号:

    ext {
        roomVersion = '2.2.0'
        archLifecycleVersion = '2.2.0-beta01'
        coreTestingVersion = '2.1.0'
        materialVersion = '1.0.0'
        nav_version = '2.1.0'
    }
  3. app的**build.gradle**中导入依赖

    // Room components
    implementation "androidx.room:room-runtime:$rootProject.roomVersion"
    annotationProcessor "androidx.room:room-compiler:$rootProject.roomVersion"
    androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
    
    // Lifecycle components
    implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archLifecycleVersion"
    annotationProcessor "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
    
    // navigation
    implementation "androidx.navigation:navigation-fragment:$rootProject.nav_version"
    implementation "androidx.navigation:navigation-ui:$rootProject.nav_version"
    
    // UI
    implementation "com.google.android.material:material:$rootProject.materialVersion"
    
    // Testing
    androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"