Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
172 views
in Technique[技术] by (71.8m points)

noclassdeffounderror - Android - MultiDexEnable=true causes Picasso to Crash

I've used MultiDexEnable=true command in my gradle file to integrate the cometChat sdk . But Picasso library which was running fine is crashing now giving the following error. Can you please guide towards solution?

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.edesign.astutesol.eyesapp"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
            multiDexEnabled true

    }
    /*repositories {
        maven {
            url 'https://repo1.maven.org/maven2/'
           // url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }
    }*/
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    /*compile('org.apache.httpcomponents:httpmime:4.3.6') {
        exclude module: 'httpclient'
    }
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5'*/
    /*compile 'com.loopj.android:android-async-http:1.4.9'*/
    /*compile 'com.loopj.android:android-async-http:1.4.9-SNAPSHOT'*/
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
    compile 'com.mcxiaoke.volley:library:1.0.15'
    compile 'com.google.android.gms:play-services-appindexing:8.1.0'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.code.gson:gson:2.2.+'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-v13:23.1.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'de.hdodenhof:circleimageview:2.0.0'
}

Log Cat

Process: com.edesign.astutesol.eyesapp, PID: 29018 java.lang.NoClassDefFoundError: com.squareup.picasso.Picasso$1
                                                                               at com.squareup.picasso.Picasso.<clinit>(Picasso.java:109)
                                                                               at com.edesign.astutesol.eyesapp.BaseFragmentActivity.SetDrawer(BaseFragmentActivity.java:81)
                                                                               at com.edesign.astutesol.eyesapp.BaseFragmentActivity.onCreate(BaseFragmentActivity.java:65)
                                                                               at com.edesign.astutesol.eyesapp.MapsActivity.onCreate(MapsActivity.java:152)
                                                                               at android.app.Activity.performCreate(Activity.java:5541)
                                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2368)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2464)
                                                                               at android.app.ActivityThread.access$900(ActivityThread.java:172)
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                               at android.os.Looper.loop(Looper.java:146)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:5653)
                                                                               at java.lang.reflect.Method.invokeNative(Native Method)
                                                                               at java.lang.reflect.Method.invoke(Method.java:515)
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
                                                                               at dalvik.system.NativeStart.main(Native Method)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

make your application class like bellow

public class MyAppClass extends MultiDexApplication{
@Override
    protected void attachBaseContext(Context newBase) {
        MultiDex.install(newBase);
        super.attachBaseContext(newBase);
    }
}

add this library in your dependencies

dependencies {
     compile 'com.android.support:multidex:1.0.1'
    //    your dependencies which you are using.

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...