java.lang.NoClassDefFoundError:解析失败:Lcom / bumptech / glide / Glide;运行时错误

时间:2017-08-03 11:47:05

标签: android android-glide

我正在使用最新的Glide Android库。在编译时没有错误,但是当应用程序安装在设备上时,它在运行时显示此错误:

  

java.lang.NoClassDefFoundError:解析失败:   LCOM / bumptech /滑翔/滑翔;

我在loadMap() { this.Geolocation.getCurrentPosition().then((position) => { let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); let mapOptions = { center: latLng, zoom: 15, MyLocationEnabled: true, setMyLocationButtonEnabled: true, zoomControl: false, disableDefaultUI: true, mapTypeId: google.maps.MapTypeId.ROADMAP, } this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions); this.addMarker(); }, (err) => { console.log(err); }); } 官方Github页面中列出了以下模块:

Glide

仍然存在错误。

Glide Github Link

Build.gradle:

compile 'com.github.bumptech.glide:glide:4.0.0' compile 'com.android.support:support-v4:25.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'

编辑:我认为问题出在其他地方,因为使用Picasso而不是Glide会抛出与apply plugin: 'com.android.application' apply plugin: 'realm-android' android { dexOptions { javaMaxHeapSize "4g" preDexLibraries = false } compileSdkVersion 25 buildToolsVersion "25.0.1" defaultConfig { applicationId "com.esmartify" minSdkVersion 21 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true multiDexEnabled true } buildTypes { release { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' minifyEnabled false } } } dependencies { compile fileTree(include: '*.jar', dir: 'libs') compile 'com.android.support:multidex:1.0.1' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:design:25.3.1' compile 'com.android.support:support-vector-drawable:25.3.1' compile 'com.android.support:cardview-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:support-v4:25.3.1' compile 'com.google.android.gms:play-services:11.0.2' compile 'com.firebase:geofire-android:2.1.1' compile 'com.firebaseui:firebase-ui-auth:2.0.1' compile 'com.facebook.android:facebook-android-sdk:4.22.1' compile 'com.google.firebase:firebase-auth:11.0.1' compile 'com.google.firebase:firebase-crash:11.0.1' compile 'com.google.firebase:firebase-messaging:10.0.1' compile 'com.android.volley:volley:1.0.0' compile 'com.google.android.gms:play-services-maps:11.0.2' testCompile 'junit:junit:4.12' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' debugCompile 'com.facebook.stetho:stetho:1.5.0' debugCompile 'com.uphyca:stetho_realm:2.1.0' } apply plugin: 'com.google.gms.google-services' 相同的错误

4 个答案:

答案 0 :(得分:0)

检查您在mavenCentral()文件中添加了build.gradle

repositories {
  mavenCentral()
}

答案 1 :(得分:0)

尝试将以下行添加到proguard-rules.pro;

-keep class com.bumptech.** {*;}
-keepclassmembers class com.bumptech.** {*;}

答案 2 :(得分:0)

好像你已经在你的项目中有这个滑行版或类,因为你没有得到类def错误。尝试使用jdgui检查所有依赖jar类。

答案 3 :(得分:0)

我也遇到了同样的问题,添加了transitive = true字段做了诀窍

compile ('com.github.bumptech.glide:glide:4.4.0@aar') {
    transitive = true
}