小编Geo*_*man的帖子

未解决的参考:hiltViewModel

这是我的代码,我将其作为参数传递 未解决的参考:hiltViewModel 这是用红色标记我的文件,因此我无法将我的解决方案编译到我的设备中,我也访问过https://developer.android.com/jetpack/ compose/libraries#hilt-navigation但 api 无法解决问题不知道为什么

fun NotesScreen(
    navController: NavController,
    viewModel: NotesViewModel = hiltViewModel()
) 
Run Code Online (Sandbox Code Playgroud)

这是我的应用程序构建 gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'com.google.dagger.hilt.android'
}

android {
    namespace 'com.example.aer'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.aer"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    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'
    } …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-developer-api mobile-development android-jetpack-compose

2
推荐指数
1
解决办法
1677
查看次数