我实际上已经尝试了Web上的每个解决方案来尝试解决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'
答案 0 :(得分:1)
在您的app
模块中的任何地方添加此类,它将起作用:
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.module.AppGlideModule
@GlideModule
class RequiredAppGlideModule : AppGlideModule()
不要忘记滑动编译器:
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'
答案 1 :(得分:0)
我已经解决了:
GlideApp类将自动生成