Glide的公開發(fā)行版可以通過多種方式訪問。
您可以直接從Github下載最新的Jar包。請注意,您可能還需要包含Android v4的支持庫。
如果您使用Gradle,您可以使用Maven Central或者JCenter添加Glide的依賴庫。您還需要在支持庫中包含依賴關系。
repositories {
mavenCentral()
}
dependencies {
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
compile 'com.android.support:support-v4:25.3.1'
}
如果您使用Maven,您還可以在Glide上添加依賴關系。同樣地,您還需要在支持庫中包含依賴關系。
<dependency>
<groupId>com.github.bumptech.glide</groupId>
<artifactId>glide</artifactId>
<version>4.0.0</version>
<type>aar</type>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
</dependency>
根據(jù)您的構建配置,您可能還需要進行一些額外的設置。
如果您使用proguard,您可能需要添加以下行到您的proguard.cfg文件中:
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
Glide的構建配置需要Jack目前還不支持特性。Jack最近被棄用了,Glide要求的特性不太可能被添加。
目前還沒有(截止6/2017)穩(wěn)定發(fā)布的Glide允許您在Android工具鏈中使用Java 8的特性。如果您想使用Java 8并且穩(wěn)定性要求較低,則這里至少有一個支持Java 8的Android gradle插件的Alpha版本。該插件的alpha版本尚未通過Glide測試。有關更多詳細信息,請參閱Android的Java 8支持頁面。
如果您在Kotlin的實現(xiàn)類中使用Glide的注解,則需要在Glide上添加kapt依賴關系,而不是annotationProcessor依賴關系:
dependencies {
kapt 'com.github.bumptech.glide:compiler:4.0.0-RC1'
}
有關詳細信息,請參閱Generated API章節(jié)。