问题
What can cause this error for class DrawableWrapper
from the support lib?
Caused by: java.lang.ClassNotFoundException: Didn't find class
"android.support.v4.graphics.drawable.DrawableWrapper" on path:
DexPathList[[zip file "/data/app/com.example.banyan.tasty-
1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
回答1:
Try updating your support library to 27.1.0.
回答2:
Make sure all of your "com.android.support:*"
dependencies are at the same version.
Looks like one of the support libraries uses something that is missing in the other one.
回答3:
i fixed same error updating version
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
To
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
回答4:
I started getting this exception in Android 5 and Android 4 users after removing com.android.support-v13
from my build.gradle
file:
configurations.all {
exclude group: 'com.android.support', module: 'support-v13'
}
I removed the above exclude
configuration and no longer saw this crash.
回答5:
In my case, I used support library version '27.0.2' for my project. It was working perfectly. However, when I copy & paste the project to different location and I opened in Android studio. That time, android studio added below line in build.gradle (path: MyProject/app/build.gradle)
compile 'com.android.support:support-v4:27.1.1'
Then I got the below exception.
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.graphics.drawable.DrawableWrapper" on path: DexPathList
I removed the line from build.gradle (MyProject/app/build.gradle). Now it is working fine.
回答6:
Try this:
import android.support.v7.graphics.drawable.DrawableWrapper;
回答7:
import android.support.v7.graphics.drawable.DrawableWrapper;
or
import android.support.v4.graphics.drawable.WrappedDrawable;
will help.
Also, when you use Drawable inner = ((WrappedDrawable) drawable).getWrappedDrawable();
, you can add @SuppressLint("RestrictedApi")
above your method.
回答8:
Try:
enable D8
if you using
AS 3.1
来源:https://stackoverflow.com/questions/49026021/classnotfoundexception-android-support-v4-graphics-drawable-drawablewrapper