2017-06-06 86 views
1

無法解析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' 
    } 

' 
+0

堆棧跟蹤或編譯錯誤在哪裏? – MatPag

+1

我有同樣的問題。我迄今發現的唯一解決方案是將Glide版本降級到** com.github.bumptech.glide:glide:3.8.0 ** – Guildschris

回答

0

有同樣的問題,經過一些挖掘找到了解決辦法
必須使用滑翔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); 
相關問題