从 Firebase 存储中获取图像。 GlideApp 未解决的引用
get image from Firebase storage. GlideApp unresolved reference
我几乎尝试了网络上的所有解决方案来尝试解决 GlideApp
但没有成功。我可以使用另一种方法从 Firebase 存储中检索图像并将其放入 ImageView
而不是滑动吗?我担心如果一开始就很难找到使用 Glide 的解决方案,那么接下来会发生什么? Google 推荐它,但我无法让它工作。这是我正在实施的:
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'
****第二次更新****
这是我的完整 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'
将此 class 任意位置 添加到您的 app
模块中,它将起作用:
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'
我已经解决了:
- 单击菜单生成
- 点击制作模块
而GlideAppClass会自动生成
我几乎尝试了网络上的所有解决方案来尝试解决 GlideApp
但没有成功。我可以使用另一种方法从 Firebase 存储中检索图像并将其放入 ImageView
而不是滑动吗?我担心如果一开始就很难找到使用 Glide 的解决方案,那么接下来会发生什么? Google 推荐它,但我无法让它工作。这是我正在实施的:
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'
****第二次更新****
这是我的完整 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'
将此 class 任意位置 添加到您的 app
模块中,它将起作用:
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'
我已经解决了:
- 单击菜单生成
- 点击制作模块
而GlideAppClass会自动生成