android / codelab-android-room-with-a-view

Apache License 2.0
746 stars 490 forks source link

Most gradle file updates not working + solutions that are working for me (so far) #261

Open PearlPetal opened 1 month ago

PearlPetal commented 1 month ago

Use these blocks where intended, compileOptions didnt need to be changed since the default code already has the correct JavaVersion, but all the other code had formatting issues (Missing parenthesis, no var declarations, wrong quotation for version numbers) should be fixed. I commented out one of the dependencies because I wasn't sure why it was giving me an error and I hopefully won't need it.

compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

dependencies {
    implementation("androidx.appcompat:appcompat:$rootProject.appCompatVersion")

    // Dependencies for working with Architecture components
    // You'll probably have to update the version numbers in build.gradle (Project)

    // 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-viewmodel:$rootProject.lifecycleVersion")
    implementation("androidx.lifecycle:lifecycle-livedata:$rootProject.lifecycleVersion")
    implementation("androidx.lifecycle:lifecycle-common-java8:$rootProject.lifecycleVersion")

    // UI
    implementation("androidx.constraintlayout:constraintlayout:$rootProject.constraintLayoutVersion")
    implementation("com.google.android.material:material:$rootProject.materialVersion")

    // Testing
    testImplementation("junit:junit:$rootProject.junitVersion")
    androidTestImplementation("androidx.arch.core:core-testing:$rootProject.coreTestingVersion")
    //androidTestImplementation ("androidx.test.espresso:espresso-core:$rootProject.espressoVersion", {
        //exclude group: 'com.android.support', module: 'support-annotations'
    //})
    androidTestImplementation("androidx.test.ext:junit:$rootProject.androidxJunitVersion")
}

ext{
    val appCompatVersion = "1.5.1"
    val constraintLayoutVersion = "2.1.4"
    val coreTestingVersion = "2.1.0"
    val lifecycleVersion = "2.3.1"
    val materialVersion = "1.3.0"
    val roomVersion = "2.3.0"
    // testing
    val junitVersion = "4.13.2"
    val espressoVersion = "3.4.0"
    val androidxJunitVersion = "1.1.2"
}
PearlPetal commented 1 month ago

There's still an issue with the gradle not being able to sync since its still unable to find the root project version extensions (Dependencies can't get the ext values) Ill probably just replace each value manually until I find a solution, since moving the values into the :app gradle and removing $rootProject should solve the issue