You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入EasyAdapter后遇Unresolved reference错误求助

问题描述

已通过implementation 'com.github.derysudrajat:EasyAdapter:2.0.0'将EasyAdapter导入Android项目,该依赖已显示在项目依赖列表中,但尝试使用import com.myproject.easyadapter.EasyAdapter语句导入时,出现“Unresolved reference: easyadapter”错误。以下是模块和项目的build.gradle配置:

模块build.gradle文件

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.firebase-perf'
    id 'com.google.firebase.crashlytics'
    id 'kotlin-kapt'
    id 'kotlin-parcelize'
    id 'dagger.hilt.android.plugin'
}

android {
    compileSdkVersion 33
    buildToolsVersion "30.0.3"

    signingConfigs {
        release {
            storeFile file('C:\\Users\\soura\\Documents\\Exporter\\Exporter.jks')
            storePassword 'password'
            keyPassword 'password'
            keyAlias 'Key0'
        }
    }

    defaultConfig {
        applicationId "com.nelu.quran"
        minSdkVersion 21
        //noinspection OldTargetApi
        targetSdkVersion 31
        versionCode 2
        versionName "2.2.3"
        signingConfig signingConfigs.release
        multiDexEnabled true

        //Blur
//        renderscriptTargetApi 30
//        renderscriptSupportModeEnabled true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            signingConfig signingConfigs.release
            manifestPlaceholders = [crashlyticsCollectionEnabled:"true"]
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            manifestPlaceholders = [crashlyticsCollectionEnabled:"false"]
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildFeatures {
        viewBinding true
        dataBinding = true
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    configurations.all {
        resolutionStrategy.force "org.antlr:antlr4-runtime:4.7.1"
        resolutionStrategy.force "org.antlr:antlr4-tool:4.7.1"
    }
    namespace 'com.nelu.quran'
}

dependencies {
    //noinspection GradleDependency
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.work:work-runtime:2.7.0-alpha05'
    implementation 'com.google.android.gms:play-services-location:20.0.0'
    //retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
//    implementation "com.squareup.retrofit2:converter-gson:2.9.0"
    implementation "com.squareup.retrofit2:converter-gson:2.9.0"

    implementation 'androidx.core:core-ktx:1.10.1'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
    implementation "androidx.test:core:1.5.0"
    implementation "androidx.fragment:fragment-ktx:1.6.0"
    implementation 'androidx.annotation:annotation:1.6.0'
    implementation 'androidx.preference:preference-ktx:1.2.0'

    //Network
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    implementation 'com.github.derysudrajat:EasyAdapter:2.0.0'

//    implementation 'com.squareup.okhttp3:okhttp:4.9.0'
    // room
    implementation "androidx.room:room-runtime:2.4.3"
    implementation "androidx.room:room-ktx:2.4.3"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
    kapt "androidx.room:room-compiler:2.4.3"
    //Coroutine
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'

    //Firebase
    implementation platform('com.google.firebase:firebase-bom:28.2.1')
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
//    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-perf-ktx'
    implementation 'com.google.firebase:firebase-database-ktx'
    implementation 'com.google.firebase:firebase-analytics-ktx:21.1.1'
    implementation 'com.google.firebase:firebase-firestore:24.3.1'

    //dagger hilt//
    implementation "com.google.dagger:hilt-android:2.42"

    implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
    kapt 'androidx.hilt:hilt-compiler:1.0.0'
    implementation 'androidx.hilt:hilt-work:1.0.0'
    annotationProcessor 'androidx.hilt:hilt-compiler:1.0.0'
    kapt "com.google.dagger:hilt-android-compiler:2.42"
    implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
    //Blur
//    implementation 'com.eightbitlab:blurview:1.6.6'

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
kapt {
    correctErrorTypes = true
}

项目build.gradle文件

buildscript {
    ext {
        compose_ui_version = '1.2.1'
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.14'
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.3.0' apply false
    id 'com.android.library' version '7.3.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
    id 'com.google.dagger.hilt.android' version '2.41' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
解决方案
  • 修正导入包名:EasyAdapter的官方包名是com.derysudrajat.easyadapter,而非自定义的com.myproject.easyadapter,将导入语句改为:
    import com.derysudrajat.easyadapter.EasyAdapter
    
  • 添加JitPack仓库:该依赖托管在JitPack,项目级build.gradle缺少对应仓库配置,需补充:
    在项目级build.gradle中加入allprojects块(已有则直接添加JitPack地址):
    allprojects {
        repositories {
            google()
            mavenCentral()
            maven { url 'https://jitpack.io' }
        }
    }
    
  • 同步并重建项目:修改配置后,点击Android Studio顶部的Sync Project with Gradle Files按钮,之后依次执行Build > Clean Project和Build > Rebuild Project,清除缓存后重新编译。
  • 检查依赖下载状态:查看External Libraries目录下是否存在EasyAdapter,若未出现,可手动删除项目根目录下的.gradle文件夹,再次同步项目。

内容的提问来源于stack exchange,提问作者Mohammad Dayarneh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 18:57:57