当前位置: 首页 > 知识库问答 >
问题:

java.lang.ClassNotFoundException:未找到类“com.squareup.picasso.picasso”

韩高峯
2023-03-14
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {

        applicationId 'com.app.myapp'
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 26
        versionName "1.0"
        multiDexEnabled true

    lintOptions {
        abortOnError false
    }
    dexOptions {
        javaMaxHeapSize "4g"
        jumboMode true
    }

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
    compile 'org.glassfish:javax.annotation:10.0-b28'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.google.maps.android:android-maps-utils:0.4'
    compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services:9.0.1'
09-16 03:02:22.336 27190-27190/com.myapp.app E/AndroidRuntime: FATAL EXCEPTION: main
                                                                 Process: com.myapp.app, PID: 27190
                                                                 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/picasso/Picasso;
                                                                     at com.myapp.app.service.CustomSwipeAdapter.instantiateItem(CustomSwipeAdapter.java:97)
                                                                     at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:1006)
                                                                     at android.support.v4.view.ViewPager.populate(ViewPager.java:1154)
                                                                     at android.support.v4.view.ViewPager.populate(ViewPager.java:1088)
                                                                     at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:542)
                                                                     at com.myapp.app.appMainActivity$LoadImage.onPostExecute(appMainActivity.java:811)
                                                                     at com.myapp.app.appMainActivity$LoadImage.onPostExecute(appMainActivity.java:757)
                                                                     at android.os.AsyncTask.finish(AsyncTask.java:636)
                                                                     at android.os.AsyncTask.access$500(AsyncTask.java:177)
                                                                     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                     at android.os.Looper.loop(Looper.java:135)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at java.lang.reflect.Method.invoke(Method.java:372)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                                  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.squareup.picasso.Picasso" on path: DexPathList[[zip file "/data/app/com.myapp.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.app-1/lib/x86, /vendor/lib, /system/lib]]
                                                                     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                     at com.myapp.app.service.CustomSwipeAdapter.instantiateItem(CustomSwipeAdapter.java:97) 
                                                                     at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:1006) 
                                                                     at android.support.v4.view.ViewPager.populate(ViewPager.java:1154) 
                                                                     at android.support.v4.view.ViewPager.populate(ViewPager.java:1088) 
                                                                     at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:542) 
                                                                     at com.myapp.app.appMainActivity$LoadImage.onPostExecute(appMainActivity.java:811) 
                                                                     at com.myapp.app.appMainActivity$LoadImage.onPostExecute(appMainActivity.java:757) 
                                                                     at android.os.AsyncTask.finish(AsyncTask.java:636) 
                                                                     at android.os.AsyncTask.access$500(AsyncTask.java:177) 
                                                                     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653) 
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                     at android.os.Looper.loop(Looper.java:135) 
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                     at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
                                                                    Suppressed: java.lang.ClassNotFoundException: com.squareup.picasso.Picasso
                                                                     at java.lang.Class.classForName(Native Method)
                                                                     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                                     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                                            ... 18 more
                                                                  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

共有1个答案

成浩漫
2023-03-14

您肯定忘记了为您的Multidex添加一个自定义应用程序。

public class CustomApplication extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}

在AndroidManifest.xml中:

<application
    android:name="something.CustomApplication"

编辑:在旁注上...你到底为什么要添加整个Google Play服务?你应该只添加你需要的任何部分。请阅读“选择性地将API编译到可执行文件中”部分。

 类似资料: