android - Glide 库 java.lang.NoClassDefFoundError

标签 android gradle kotlin android-glide

我正在使用 Glide Library 从可绘制资源文件中加载图像,但我遇到了 NoClassDefFoundError。我在堆栈中尝试了很多方法,但我未能解决问题。我实现的 Activity 是 Fragment。这是代码.. .

class F12 : Fragment() {
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {

     val myImageViewLayout : View = inflater!!.inflate(R.layout.f12, container, false)
      val imageView = myImageViewLayout.findViewById<ImageView>(R.id.preview12)

    Glide
            .with(context)
            .load(R.drawable.a12)
            .into(imageView)

    return myImageViewLayout

}
 override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
    val shareButton =view!!.findViewById<Button>(R.id.b12)
    val wallButton = view.findViewById<Button>(R.id.wb12)
    val adRequest = AdRequest.Builder().build()

    shareButton.setOnClickListener {

        val shareIntent = Intent()
        shareIntent.action = Intent.ACTION_SEND
        shareIntent.putExtra(Intent.EXTRA_TEXT, "ከመሸ ፍቅራችን ደራ…ወደኋላ አንመልሰዉ ነገር ሆነብን….ቀልዳችን የምር ሲሆን፣ቅዠት ያልነዉ  እዉን ሲሆን ሲጨላልም አየነዉ")
        shareIntent.type = "text/plain"
        startActivity(Intent.createChooser(shareIntent, "ሼር ያድርጉ..."))
  }
   }

这是 gradle.app 模块..
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android 
  {
compileSdkVersion 26
buildToolsVersion "26.0.3"
defaultConfig {
   applicationId "com.afc.amhariclovequotes"
   minSdkVersion 14
   targetSdkVersion 26
   versionCode 1
   versionName "1.0"
   multiDexEnabled true
 }
buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
 dexOptions {      
    javaMaxHeapSize "4g"
}
 }
 dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support:mediarouter-v7:26.0.0'
compile 'com.android.support:design:26.0.0'
compile 'com.google.firebase:firebase-ads:11.6.0'
compile 'com.google.firebase:firebase-crash:11.6.0'
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.github.bumptech.glide:glide:4.4.0@aar'
kapt 'com.github.bumptech.glide:compiler:4.4.0'
testCompile 'junit:junit:4.12'    
 }
 repositories {
 mavenCentral()
 }
 apply plugin: 'com.google.gms.google-services'

这是有关代码的 Android 监视器提示...
FATAL EXCEPTION: main
Process: com.afc_quotes.first_amharic_love_quotes, PID: 24273
java.lang.NoClassDefFoundError: com.bumptech.glide.load.resource.gif.GifBitmapProvider
at com.bumptech.glide.load.resource.gif.ByteBufferGifDecoder.<init>(ByteBufferGifDecoder.java:68)
at com.bumptech.glide.load.resource.gif.ByteBufferGifDecoder.<init>(ByteBufferGifDecoder.java:54)
at com.bumptech.glide.Glide.<init>(Glide.java:327)
at com.bumptech.glide.GlideBuilder.build(GlideBuilder.java:445)
at com.bumptech.glide.Glide.initializeGlide(Glide.java:257)
at com.bumptech.glide.Glide.initializeGlide(Glide.java:212)
at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:176)
at com.bumptech.glide.Glide.get(Glide.java:160)
at com.bumptech.glide.Glide.getRetriever(Glide.java:612)
at com.bumptech.glide.Glide.with(Glide.java:638)
**at com.afc.amhariclovequotes.F12.onCreateView(F12.kt:50)**
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2337)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2199)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:651)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1236)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1084)
at android.support.v4.view.ViewPager$3.run(ViewPager.java:267)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

最佳答案

尝试设置依赖transitive :

implementaion ("com.bumptech.glide:glide:4.4.0@aar") {
    transitive = true
}

关于android - Glide 库 java.lang.NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48048455/

相关文章:

android - 在 LGPL 模式下编译时的 FFmpeg 功能

java - 让 OpenGL-ES 模板缓冲区工作

java - 将 HAPI-FHIR 依赖项添加到 gradle Android 项目中

kotlin - 为什么我收到错误 : Variable expect in kotlin?

android - Kotlin 迁移后 Crashlytics 报告错误的行号

Android图片回调数据为空

java - 当我的应用程序崩溃时,如何向我发送错误数据?

android - 启动应用程序后在 Android Studio 中 Hook

java - Gradle 和用于 Android 构建的 Maven 存储库的悲伤

android - java.lang.ClassNotFoundException : com. intellij.junit5.JUnit5IdeaTestRunner 在 kotlin 中使用 spek