英文:
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<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) { _, _, _ -> }
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论