ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 해결되지 않은 참조 @HiltAndroidApp 또는 Android의 기타 Hilt 주석
    카테고리 없음 2020. 8. 9. 15:14

    질문

    모든 작업을 제대로 수행했지만 여전히 프로젝트에서 Hilt를 사용할 수 없습니다.

    build.gradle (: app)

    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'
    apply plugin: 'com.google.gms.google-services'
    apply plugin: 'com.google.firebase.crashlytics'
    apply plugin: 'kotlin-kapt'
    apply plugin: 'dagger.hilt.android.plugin'
    
    android {
        compileSdkVersion 29
        buildToolsVersion "29.0.3"
    
    
        buildFeatures{
            viewBinding = true
            dataBinding = true
        }
    
    
    
        defaultConfig {
            applicationId "com.emptysheet.pdfreader_autoscroll"
            minSdkVersion 16
            targetSdkVersion 29
            versionCode 7
            versionName "1.7"
            multiDexEnabled true
    
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    
    // To inline the bytecode built with JVM target 1.8 into
    // bytecode that is being built with JVM target 1.6. (e.g. navArgs)
    
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        kotlinOptions {
            jvmTarget = "1.8"
        }
    
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation 'androidx.appcompat:appcompat:1.1.0'
        implementation 'androidx.core:core-ktx:1.3.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation 'com.google.android.material:material:1.1.0'
        implementation 'androidx.preference:preference:1.1.1'
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        implementation 'androidx.navigation:navigation-fragment:2.2.2'
        implementation 'androidx.navigation:navigation-ui:2.2.2'
        implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
        implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
        implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    
        implementation project(path: ':android-pdf-viewer')
    
        //firebase for crashlytics
        implementation 'com.google.firebase:firebase-analytics-ktx:17.4.3'
        implementation 'com.google.firebase:firebase-crashlytics:17.0.1'
        // for ads
        implementation 'com.google.android.gms:play-services-ads:19.1.0'
        // multidex
        //room
        implementation 'androidx.room:room-ktx:2.2.5'
        kapt "androidx.room:room-compiler:2.2.5"
    
        implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7"
        implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0"
        //debug database
        debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
        implementation 'de.psdev.licensesdialog:licensesdialog:2.1.0'
        //support for APK less than 21
        implementation 'androidx.multidex:multidex:2.0.1'
        // in app billing
        implementation 'com.android.billingclient:billing-ktx:3.0.0'
        // Hilt
        implementation "com.google.dagger:hilt-android:2.28-alpha"
        kapt "com.google.dagger:hilt-android-compiler:2.28-alpha"
    
    }

    build.gradle (프로젝트)

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        ext.kotlin_version = '1.3.72'
        repositories {
            google()
            jcenter()
    
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:4.0.0'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
            classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
            classpath 'com.google.gms:google-services:4.3.3'
            classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
            classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha'
    
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
    
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }

    @HiltAndroidApp 또는 다른 Hilt 주석을 사용할 때. 미해결 참조라고 표시됩니다. 주석을 만듭니다. Hilt 재설치를 시도했지만 여전히 작동하지 않습니다.

    Android Studio 4.0 도 사용하고 있습니다.

     

    답변1

    평소 시도 :

    File -> Invalidate Caches / Restart ... (또는 Invalidate and Restart클릭)



    답변2

    1. 툴바에서 'Sync Project with Gradle Files'를 누릅니다.
    2. Invalidate Caches / Restart

     



     

     

     

     

    출처 : https://stackoverflow.com/questions/62463125/unresolved-reference-hiltandroidapp-or-any-other-hilt-annotation-in-android

    댓글

Designed by Tistory.