Unresolved reference: easyadapter

huangapple go评论70阅读模式
英文:

Unresolved reference: easyadapter

问题

未解决的引用: easyadapter

我已经使用 "implementation 'com.github.derysudrajat:EasyAdapter:2.0.0'" 将 easyAdapter 导入我的项目,并且它显示在项目的依赖项中,但当我尝试像这样导入它时:

import com.myproject.easyadapter.EasyAdapter

它给我一个 "未解决的引用: easyadapter" 错误。如果有人知道我如何解决这个问题,请帮忙!谢谢。

Build.gradle 模块文件:

dependencies {
    // 其他依赖...
    implementation 'com.github.derysudrajat:EasyAdapter:2.0.0'
    // 其他依赖...
}

build.gradle 项目文件:

dependencies {
    // 其他依赖...
    classpath 'com.google.gms:google-services:4.3.14'
    // 其他依赖...
}
英文:

Unresolved reference: easyadapter

i have imported easyAdapter to my project with " implementation 'com.github.derysudrajat:EasyAdapter:2.0.0'" and it shows in the project dependecies
but when i try to import it like :
"import com.myproject.easyadapter.EasyAdapter"
it give me the Unresolved reference: easyadapter error
if anyone knows how can i solve this please help ! Thanks
Build.gradle module file :

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 project file :

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
}

答案1

得分: 0

我通过在com.myproject目录中创建一个名为easyAdapter的新包来解决了这个问题其中包含以下代码
```java
package com.nelu.easyadapter

import id.derysudrajat.easyadapter.BaseEasyAdapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding

class EasyAdapter<T, Binding : ViewBinding>(
    data: List<T>,
    bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> Binding,
    val onBindView: (binding: Binding, data: T) -> Unit
) : BaseEasyAdapter<T, Binding>(data.toMutableList(), bindingInflater) {
    override fun onBind(binding: Binding, data: T, position: Int) {
        onBindView(binding, data)
    }

    companion object {
        fun <T, Binding : ViewBinding> init(bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> Binding) =
            EasyAdapter<T, Binding>(listOf(), bindingInflater) { _, _ -> }
    }
}

class EasyAdapterIndexed<T, Binding : ViewBinding>(
    data: List<T>,
    bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> Binding,
    val onBindView: (binding: Binding, data: T, index: Int) -> Unit
) : BaseEasyAdapter<T, Binding>(data.toMutableList(), bindingInflater) {

    override fun onBind(binding: Binding, data: T, position: Int) {
        onBindView(binding, data, position)
    }

    companion object {
        fun <T, Binding : ViewBinding> init(bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> Binding) =
            EasyAdapterIndexed<T, Binding>(listOf(), bindingInflater) { _, _, _ -> }
    }
}
英文:

SOLVED :
I solved it by creating a new package "easyAdapter" in the "com.myproject" directory with the following code in it :

package com.nelu.easyadapter
import id.derysudrajat.easyadapter.BaseEasyAdapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
class EasyAdapter&lt;T, Binding : ViewBinding&gt;(
data: List&lt;T&gt;,
bindingInflater: (LayoutInflater, ViewGroup, Boolean) -&gt; Binding,
val onBindView: (binding: Binding, data: T) -&gt; Unit
) : BaseEasyAdapter&lt;T, Binding&gt;(data.toMutableList(), bindingInflater) {
override fun onBind(binding: Binding, data: T, position: Int) {
onBindView(binding, data)
}
companion object {
fun &lt;T, Binding : ViewBinding&gt; init(bindingInflater: (LayoutInflater, ViewGroup, Boolean) -&gt; Binding) =
EasyAdapter&lt;T, Binding&gt;(listOf(), bindingInflater) { _, _ -&gt; }
}
}
class EasyAdapterIndexed&lt;T, Binding : ViewBinding&gt;(
data: List&lt;T&gt;,
bindingInflater: (LayoutInflater, ViewGroup, Boolean) -&gt; Binding,
val onBindView: (binding: Binding, data: T, index: Int) -&gt; Unit
) : BaseEasyAdapter&lt;T, Binding&gt;(data.toMutableList(), bindingInflater) {
override fun onBind(binding: Binding, data: T, position: Int) {
onBindView(binding, data, position)
}
companion object {
fun &lt;T, Binding : ViewBinding&gt; init(bindingInflater: (LayoutInflater, ViewGroup, Boolean) -&gt; Binding) =
EasyAdapterIndexed&lt;T, Binding&gt;(listOf(), bindingInflater) { _, _, _ -&gt; }
}
}

huangapple
  • 本文由 发表于 2023年6月26日 08:59:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76552974.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定