在我的情况下,我使用的是GifImageView,它适用于某些Android版本(例如5.1),但某些版本不适合android 4.4 kitkat和android 4.04。
我的清单: `
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:name="android.support.multidex.MultiDexApplication"
android:largeHeap="true"
android:isGame="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ViewCardsActivity"
android:label="@string/cards"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity android:name=".TwoPlayerCardJitsuGame"
android:label="Card Jitsu Game"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity android:name=".MultiPlayerCardJitsuGame"
android:label="Card Jitsu Game"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity android:name=".HowToPlay"
android:label="How To Play"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity android:name=".Conquests"
android:label="Conquests"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity android:name=".Shop"
android:label="Market"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity android:name=".PackOpening"
android:label="Pack Opening"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity android:name=".SnowBattle"
android:label="Snow Battle"
android:screenOrientation="userLandscape"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity android:name=".SinglePlayerCardJitsuGame"
android:label="Card Jitsu Game"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize"/>
</application>
`
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.something.ismail.cardjitsu"
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
versionCode 3
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-ads:11.0.0'
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support:design:25.3.1'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.14'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
}
崩溃前的日志:
08-26 02:33:26.491 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve interface method 22294: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
08-26 02:33:26.491 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
08-26 02:33:26.491 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve interface method 22296: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
08-26 02:33:26.491 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve interface method 22300: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
08-26 02:33:26.501 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 673: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
08-26 02:33:26.501 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 695: Landroid/content/res/TypedArray;.getType (I)I
08-26 02:33:26.521 10241-10241/com.something.ismail.cardjitsu W/Coins =: 0
08-26 02:33:26.531 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 588: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
08-26 02:33:26.831 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4661: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
08-26 02:33:26.911 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4564: Landroid/content/ContextWrapper;.createCredentialProtectedStorageContext ()Landroid/content/Context;
08-26 02:33:26.911 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4565: Landroid/content/ContextWrapper;.createDeviceProtectedStorageContext ()Landroid/content/Context;
08-26 02:33:26.911 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4564: Landroid/content/ContextWrapper;.createCredentialProtectedStorageContext ()Landroid/content/Context;
08-26 02:33:26.911 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4565: Landroid/content/ContextWrapper;.createDeviceProtectedStorageContext ()Landroid/content/Context;
08-26 02:33:26.911 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4544: Landroid/content/Context;.isCredentialProtectedStorage ()Z
08-26 02:33:26.911 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 5203: Landroid/os/UserManager;.isUserUnlocked ()Z
08-26 02:33:26.911 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4545: Landroid/content/Context;.isDeviceProtectedStorage ()Z
08-26 02:33:26.911 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4545: Landroid/content/Context;.isDeviceProtectedStorage ()Z
08-26 02:33:26.921 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve static method 5238: Landroid/system/Os;.readlink (Ljava/lang/String;)Ljava/lang/String;
08-26 02:33:26.921 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve static method 5239: Landroid/system/Os;.stat (Ljava/lang/String;)Landroid/system/StructStat;
08-26 02:33:26.921 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve static method 5240: Landroid/system/Os;.symlink (Ljava/lang/String;Ljava/lang/String;)V
08-26 02:33:26.931 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4513: Landroid/content/Context;.createDeviceProtectedStorageContext ()Landroid/content/Context;
08-26 02:33:26.931 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4513: Landroid/content/Context;.createDeviceProtectedStorageContext ()Landroid/content/Context;
08-26 02:33:26.931 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4540: Landroid/content/Context;.getSystemService (Ljava/lang/Class;)Ljava/lang/Object;
08-26 02:33:26.941 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve static field 2281 (SUPPORTED_64_BIT_ABIS) in Landroid/os/Build;
08-26 02:33:26.941 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve static field 2281 (SUPPORTED_64_BIT_ABIS) in Landroid/os/Build;
08-26 02:33:26.941 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve static field 2280 (SUPPORTED_32_BIT_ABIS) in Landroid/os/Build;
08-26 02:33:26.941 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve static field 2282 (SUPPORTED_ABIS) in Landroid/os/Build;
08-26 02:33:26.961 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 2414: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
08-26 02:33:26.981 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve static method 3116: Landroid/security/NetworkSecurityPolicy;.getInstance ()Landroid/security/NetworkSecurityPolicy;
08-26 02:33:26.981 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 2419: Landroid/content/pm/PackageManager;.isInstantApp (Ljava/lang/String;)Z
08-26 02:33:26.981 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 2418: Landroid/content/pm/PackageManager;.isInstantApp ()Z
08-26 02:33:27.011 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 4011: Landroid/webkit/WebSettings;.setMixedContentMode (I)V
08-26 02:33:27.051 10241-10286/com.something.ismail.cardjitsu W/chromium: [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
08-26 02:33:27.131 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/webkit/PermissionRequest;)
08-26 02:33:27.131 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 3987: Landroid/webkit/WebChromeClient;.onPermissionRequest (Landroid/webkit/PermissionRequest;)V
08-26 02:33:27.131 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 3987: Landroid/webkit/WebChromeClient;.onPermissionRequest (Landroid/webkit/PermissionRequest;)V
08-26 02:33:27.131 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 3980: Landroid/webkit/PermissionRequest;.getResources ()[Ljava/lang/String;
08-26 02:33:27.151 10241-10241/com.something.ismail.cardjitsu W/AllCards: 468
08-26 02:33:27.241 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 636: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-26 02:33:27.241 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 638: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-26 02:33:27.401 10241-10241/com.something.ismail.cardjitsu E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
08-26 02:33:27.401 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve instanceof 175 (Landroid/graphics/drawable/RippleDrawable;) in Landroid/support/v7/widget/AppCompatImageHelper;
08-26 02:33:27.411 10241-10241/com.something.ismail.cardjitsu W/dalvikvm: VFY: unable to resolve virtual method 435: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;`
The crash Logs :
`08-26 02:52:01.531 10241-10241/com.something.ismail.cardjitsu E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.something.ismail.cardjitsu, PID: 10241
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.something.ismail.cardjitsu/com.something.ismail.cardjitsu.PackOpening}: android.view.InflateException: Binary XML file line #185: Error inflating class pl.droidsonroids.gif.GifImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2404)
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)
Caused by: android.view.InflateException: Binary XML file line #185: Error inflating class pl.droidsonroids.gif.GifImageView
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.something.ismail.cardjitsu.PackOpening.onCreate(PackOpening.java:48)
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)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.something.ismail.cardjitsu.PackOpening.onCreate(PackOpening.java:48)
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)
Caused by: java.lang.VerifyError: pl/droidsonroids/gif/GifInfoHandle
at pl.droidsonroids.gif.GifDrawable.<init>(GifDrawable.java:158)
at pl.droidsonroids.gif.GifDrawable.<init>(GifDrawable.java:93)
at pl.droidsonroids.gif.GifViewUtils.setResource(GifViewUtils.java:52)
at pl.droidsonroids.gif.GifViewUtils$GifImageViewAttributes.getResourceId(GifViewUtils.java:137)
at pl.droidsonroids.gif.GifViewUtils$GifImageViewAttributes.<init>(GifViewUtils.java:123)
at pl.droidsonroids.gif.GifViewUtils.initImageView(GifViewUtils.java:30)
at pl.droidsonroids.gif.GifImageView.<init>(GifImageView.java:41)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.something.ismail.cardjitsu.PackOpening.onCreate(PackOpening.java:48)
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)
我尝试了Multidex,但是仍然出现错误。另外,我不知道Multidex是否正常工作。我的问题并不新鲜,但是以前问过这个问题的人都没有得到答案。
答案 0 :(得分:0)
我猜测该库必须使用某些仅适用于Android 5.0+的功能,例如涟漪可绘制...
这可能就是为什么它可以在5.0以上版本的设备上运行而不能在5.0以下版本的设备上运行的原因
编辑:再次浏览日志后,似乎该库正在使用在Android 5.0以下版本不可用的构造函数...
Caused by: `java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:423)`