I am working on Glide Library to Load images from the drawable resource file but i encountered NoClassDefFoundError.I've tried so many ways here in stack but i failed to solve the problem.The activity i implemented is Fragment.Here is the Code...
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, "ሼር ያድርጉ..."))
}
}
and here is the gradle.app module..
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'
Here is the Android Monitor Complains about the code...
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)