无法解析glide库中的centercrop占位符错误等android
问题描述:
无法解析glide库android中的centercrop占位符错误等。 也试图使用滑动到一个新的项目,但问题也在那里。 请帮助我这是一切正确或需要添加更多的东西来使用Glide库。无法解析glide库中的centercrop占位符错误等android
项目build.gradel
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
maven {
url "http://repo1.maven.org/maven2"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
APP-build.gradel
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.techweblearn.musicplayer"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 20
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'junit:junit:4.12'
}
'
答
有同样的问题,经过一些挖掘找到了解决办法
必须使用滑翔V4.3.0(更新版本现在在AndroidStudio 3.0.1中有一些小问题):
1.将此添加到您的*build.gradle
repositories {
mavenCentral()
google()
}
2.添加依赖模块级的build.gradle
implementation 'com.github.bumptech.glide:glide:4.3.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.0'
3.添加这些proguard的规则,以你的proguard-rules.pro
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
# for DexGuard only
-keepresourcexmlelements manifest/application/[email protected]=GlideModule
4.添加这个简单的类您的应用程序以生成GlideApp类
package com.example.myapp;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}
5. Cl ean并建立你的项目
6.完成!现在你可以使用GlideApp和centercrop()方法
GlideApp
.with(myFragment)
.load(url)
.centerCrop()
.placeholder(R.drawable.loading_spinner)
.into(myImageView);
堆栈跟踪或编译错误在哪里? – MatPag
我有同样的问题。我迄今发现的唯一解决方案是将Glide版本降级到** com.github.bumptech.glide:glide:3.8.0 ** – Guildschris