Kotlin 从Firebase存储获取图像。未解析引用

Kotlin 从Firebase存储获取图像。未解析引用,kotlin,android-glide,Kotlin,Android Glide,我在网上尝试了各种解决方案,试图解决GlideApp的问题,但没有成功。我是否可以使用另一种方法从Firebase存储中检索图像并将其放入ImageView而不是glide?我担心如果一开始就很难找到使用Glide的解决方案,接下来会发生什么?谷歌推荐它,但我就是不能让它工作。以下是我正在实施的内容: implementation "com.github.bumptech.glide:glide:4.3.1" Implementation "com.github.bumptech.glide:o

我在网上尝试了各种解决方案,试图解决GlideApp的问题,但没有成功。我是否可以使用另一种方法从Firebase存储中检索图像并将其放入
ImageView
而不是glide?我担心如果一开始就很难找到使用Glide的解决方案,接下来会发生什么?谷歌推荐它,但我就是不能让它工作。以下是我正在实施的内容:

implementation "com.github.bumptech.glide:glide:4.3.1"
Implementation "com.github.bumptech.glide:okhttp3-integration:4.3.1"
kapt "com.github.bumptech.glide:compiler:4.3.1"1
这是我的片段代码:

val storageRef = data.getReference()
val pathReference = storageRef.child(user?.uid.toString() + "/images/coverphoto")
GlideApp.with(context)
        .load(pathReference)
        .into();
最初使用Glide应该不会这么困难

我应该提到的是,这是一个kotlin项目,我正在尝试访问一个片段中的图像

以备不时之需:

repositories {
    maven {
        url "https://dl.bintray.com/kotlin/exposed"
    }
    mavenCentral()
    maven { url 'https://maven.google.com' }
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'org.jetbrains.anko:anko-common:0.9'
    implementation 'com.beust:klaxon:3.0.1'
    implementation "com.android.support:recyclerview-v7:27.1.1"
    testImplementation 'junit:junit:4.12'
    implementation "com.github.bumptech.glide:glide:4.3.1"
    implementation "com.github.bumptech.glide:okhttp3-integration:4.3.1"
    kapt "com.github.bumptech.glide:compiler:4.3.1"
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'
****第二次更新****

这是我的ful gradle.build文件:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.ntx_deisgns.cyberchatter.cyberchatter"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        customDebugType {
            debuggable true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    maven {
        url "https://dl.bintray.com/kotlin/exposed"
    }
    mavenCentral()
    maven { url 'https://maven.google.com' }
}
dependencies {
//    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'org.jetbrains.anko:anko-common:0.9'
    implementation 'com.beust:klaxon:3.0.1'
    implementation "com.android.support:recyclerview-v7:27.1.1"
    testImplementation 'junit:junit:4.12'
    implementation 'com.github.bumptech.glide:annotations:4.7.1'
    kapt 'com.github.bumptech.glide:compiler:4.7.1'
    implementation "com.github.bumptech.glide:okhttp3-integration:4.6.1"
    implementation 'com.github.bumptech.glide:annotations:4.7.1'
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
在你的
应用程序
模块的任何地方添加此类,它都会工作:

import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.module.AppGlideModule

@GlideModule
class RequiredAppGlideModule : AppGlideModule()
别忘了glide编译器:

implementation 'com.github.bumptech.glide:annotations:4.7.1'
kapt 'com.github.bumptech.glide:compiler:4.7.1'
implementation "com.github.bumptech.glide:okhttp3-integration:4.6.1"
implementation 'com.github.bumptech.glide:annotations:4.7.1'
确保你也这样做

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
我已通过以下方式解决:

  • 单击菜单“构建”
  • 单击“生成模块”

GlideApp类将自动生成

顺便说一句,我是Android studio 3.1.4I将Glide模块添加到我的应用程序中,并调用文件CcAppGlideModule.kt并将代码直接粘贴到其中。然后我将
import com.ntx_deisgns.cyberchatter.cyberchatter.app.RequiredAppGlideModule
导入到我的片段活动中。我还用上面的代码更新了实现和插件,但仍然得到了未解决的引用错误。我也做了一个干净的项目以防万一。仍然不起作用。我想知道这是否与您的依赖关系以
结尾有关“1
。从技术上讲,您必须添加
@GlideModule
,添加具有
kapt
作用域的编译器,并应用
kotlin kapt
,它应该可以工作。它对我们有用。O_OI使用完整的build.gradle文件更新我的原始问题。当我添加您的依赖项时,我删除了该行末尾的
“1
。我还尝试删除其他依赖项,以查看它们是否干扰了Glide。我还执行了一次使缓存无效并重新启动的操作。这些操作似乎都不起作用。我猜我键入了错误或复制了错误的内容。我不再有未解决的引用错误。