Skip to content

Use SQL to read and write to a database: Cannot make project #67

Open
@Andy-Cuong

Description

@Andy-Cuong

URL of codelab

In which task and step of the codelab can this issue be found?

Describe the problem
After downloading the sample, it is impossible to make (build) the project due to multiple errors after updating Gradle dependencies, AGP and Kapt-to-KSP migration. The untouched version of the sample cannot be built either (different error). It is even using View UI instead of Compose. The project should be updated in order to keep up with the latest technology.

Steps to reproduce?

  1. Download the sample
  2. Perform AGP upgrade
  3. Update Gradle dependencies as well as Android minSdk and targetSdk
  4. Migrate from Kapt to KSP according to (https://developer.android.com/build/migrate-to-ksp)
  5. Build > Make project

Versions
Android Studio version: Android Studio Ladybug | 2024.2.1
API version of the emulator:

Additional information
Build output:

Task :app:kspDebugKotlin FAILED
Execution failed for task ':app:kspDebugKotlin'.
Error while evaluating property 'compilerOptions.jvmTarget' of task ':app:kspDebugKotlin'.
Failed to calculate the value of property 'jvmTarget'.
> Unknown Kotlin JVM target: 21

build.gradle (Module:app)

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id("com.google.devtools.ksp")
}

android {
    compileSdk 34

    defaultConfig {
        applicationId "com.example.sqlbasics"
        minSdkVersion 24
        targetSdkVersion 34
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    namespace 'com.example.sqlbasics'
}

dependencies {
    def room_version = '2.6.1'

    implementation "androidx.room:room-runtime:$room_version"
    ksp("androidx.room:room-compiler:$room_version")

    // optional - Kotlin Extensions and Coroutines support for Room
    implementation "androidx.room:room-ktx:$room_version"

    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1'
    implementation 'androidx.core:core-ktx:1.13.1'
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'com.google.android.material:material:1.12.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.2.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
}

build.gradle (Project: SQL_Basics)

buildscript {
    ext.kotlin_version = "1.7.10"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.7.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

plugins {
    id("com.google.devtools.ksp") version "1.8.10-1.0.9" apply false
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

tasks.register('clean', Delete) {
    delete rootProject.buildDir
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions