在发布(dexguard)但不在调试中构建时出现致命异常
Fatal exception when building on release (dexguard) but not in debug
我发现这是 4.4 设备的常见问题。我已经阅读了很多关于 abc_ic_ab_back_material.xml 的其他线程,我已经能够在调试中解决问题,但在发布时却没有。有人可以帮忙吗?这里例外:
FATAL EXCEPTION: main
Process: com.tools.picturedraw, PID: 8136
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tools.picturedraw/com.blrapp.blrcommon.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access0(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
at android.content.res.Resources.loadDrawable(Resources.java:2096)
at android.content.res.Resources.getDrawable(Resources.java:700)
at android.support.v4.content.ContextCompat.getDrawable(:354)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:193)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:181)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(:689)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:186)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(:77)
at android.support.v7.app.AppCompatDelegateImplBase.(:83)
at android.support.v7.app.AppCompatDelegateImplV7.(:146)
at android.support.v7.app.AppCompatDelegateImplV11.(:28)
at android.support.v7.app.AppCompatDelegateImplV14.(:41)
at android.support.v7.app.AppCompatDelegate.create(:193)
at android.support.v7.app.AppCompatDelegate.create(:173)
at android.support.v7.app.AppCompatActivity.getDelegate(:511)
at android.support.v7.app.AppCompatActivity.onCreate(:71)
at com.blrapp.blrcommon.MainActivity.onCreate(:136)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access0(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
at android.content.res.Resources.loadDrawable(Resources.java:2092)
at android.content.res.Resources.getDrawable(Resources.java:700)
at android.support.v4.content.ContextCompat.getDrawable(:354)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:193)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:181)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(:689)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:186)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(:77)
at android.support.v7.app.AppCompatDelegateImplBase.(:83)
at android.support.v7.app.AppCompatDelegateImplV7.(:146)
at android.support.v7.app.AppCompatDelegateImplV11.(:28)
at android.support.v7.app.AppCompatDelegateImplV14.(:41)
at android.support.v7.app.AppCompatDelegate.create(:193)
at android.support.v7.app.AppCompatDelegate.create(:173)
at android.support.v7.app.AppCompatActivity.getDelegate(:511)
at android.support.v7.app.AppCompatActivity.onCreate(:71)
at com.blrapp.blrcommon.MainActivity.onCreate(:136)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access0(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
我的 app/gradle 文件:
buildscript {
repositories {
mavenCentral()
flatDir { dirs '/Users/hexdump/Developing/Android/tools/dexguard/lib/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath ':dexguard:'
}
}
apply plugin: 'com.android.application'
apply plugin: 'dexguard'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "com.tools.picturedraw"
minSdkVersion 11
targetSdkVersion 23
vectorDrawables.useSupportLibrary = true
versionCode 384
versionName "3.84"
signingConfigs
{
release
{
def console = System.console();
if (console == null) {
print("Please execute release compilations from console. Use ./comiple.sh")
} else {
def password = System.console().readPassword("\n Enter keystore password: ")
storeFile file("../mykey.keystore")
storePassword = new String(password)
keyAlias "general"
keyPassword new String(password)
}
}
}
}
buildTypes
{
release
{
//Use command line to compile in release
//minifyEnabled false
proguardFile getDefaultDexGuardFile('dexguard-release.pro')
//proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
signingConfig signingConfigs.release
}
debug
{
proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
//proguardFile 'dexguard-project.txt'
//proguardFile 'proguard-project.txt'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':adnetworks')
compile project(':coretools')
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:gridlayout-v7:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.pnikosis:materialish-progress:1.2'
}
提前致谢。
您只需要更改支持库依赖项的版本即可。将 23.2.1
更改为 23.4.0
:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':adnetworks')
compile project(':coretools')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:gridlayout-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.pnikosis:materialish-progress:1.2'
}
编辑:
If you are having any support library dependency in any of your
modules("adnetworks" or "coretools"). Please change their versions to
the latest version as i have suggested.
我遇到了同样的问题并通过将库版本更新到最新版本解决了。!!
实际上,接受的答案在大多数情况下没有帮助,因为它确实是一个 DexGuard 问题。经过大量的研究和调试,我终于得到了正确的答案,我在
发布并解释了它
我发现这是 4.4 设备的常见问题。我已经阅读了很多关于 abc_ic_ab_back_material.xml 的其他线程,我已经能够在调试中解决问题,但在发布时却没有。有人可以帮忙吗?这里例外:
FATAL EXCEPTION: main Process: com.tools.picturedraw, PID: 8136 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tools.picturedraw/com.blrapp.blrcommon.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) at android.app.ActivityThread.access0(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) 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:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method) Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013 at android.content.res.Resources.loadDrawable(Resources.java:2096) at android.content.res.Resources.getDrawable(Resources.java:700) at android.support.v4.content.ContextCompat.getDrawable(:354) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:193) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:181) at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(:689) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:186) at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(:77) at android.support.v7.app.AppCompatDelegateImplBase.(:83) at android.support.v7.app.AppCompatDelegateImplV7.(:146) at android.support.v7.app.AppCompatDelegateImplV11.(:28) at android.support.v7.app.AppCompatDelegateImplV14.(:41) at android.support.v7.app.AppCompatDelegate.create(:193) at android.support.v7.app.AppCompatDelegate.create(:173) at android.support.v7.app.AppCompatActivity.getDelegate(:511) at android.support.v7.app.AppCompatActivity.onCreate(:71) at com.blrapp.blrcommon.MainActivity.onCreate(:136) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) at android.app.ActivityThread.access0(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) 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:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method) Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933) at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877) at android.content.res.Resources.loadDrawable(Resources.java:2092) at android.content.res.Resources.getDrawable(Resources.java:700) at android.support.v4.content.ContextCompat.getDrawable(:354) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:193) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:181) at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(:689) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(:186) at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(:77) at android.support.v7.app.AppCompatDelegateImplBase.(:83) at android.support.v7.app.AppCompatDelegateImplV7.(:146) at android.support.v7.app.AppCompatDelegateImplV11.(:28) at android.support.v7.app.AppCompatDelegateImplV14.(:41) at android.support.v7.app.AppCompatDelegate.create(:193) at android.support.v7.app.AppCompatDelegate.create(:173) at android.support.v7.app.AppCompatActivity.getDelegate(:511) at android.support.v7.app.AppCompatActivity.onCreate(:71) at com.blrapp.blrcommon.MainActivity.onCreate(:136) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) at android.app.ActivityThread.access0(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) 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:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method)
我的 app/gradle 文件:
buildscript {
repositories {
mavenCentral()
flatDir { dirs '/Users/hexdump/Developing/Android/tools/dexguard/lib/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath ':dexguard:'
}
}
apply plugin: 'com.android.application'
apply plugin: 'dexguard'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "com.tools.picturedraw"
minSdkVersion 11
targetSdkVersion 23
vectorDrawables.useSupportLibrary = true
versionCode 384
versionName "3.84"
signingConfigs
{
release
{
def console = System.console();
if (console == null) {
print("Please execute release compilations from console. Use ./comiple.sh")
} else {
def password = System.console().readPassword("\n Enter keystore password: ")
storeFile file("../mykey.keystore")
storePassword = new String(password)
keyAlias "general"
keyPassword new String(password)
}
}
}
}
buildTypes
{
release
{
//Use command line to compile in release
//minifyEnabled false
proguardFile getDefaultDexGuardFile('dexguard-release.pro')
//proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
signingConfig signingConfigs.release
}
debug
{
proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
//proguardFile 'dexguard-project.txt'
//proguardFile 'proguard-project.txt'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':adnetworks')
compile project(':coretools')
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:gridlayout-v7:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.pnikosis:materialish-progress:1.2'
}
提前致谢。
您只需要更改支持库依赖项的版本即可。将 23.2.1
更改为 23.4.0
:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':adnetworks')
compile project(':coretools')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:gridlayout-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.pnikosis:materialish-progress:1.2'
}
编辑:
If you are having any support library dependency in any of your modules("adnetworks" or "coretools"). Please change their versions to the latest version as i have suggested.
我遇到了同样的问题并通过将库版本更新到最新版本解决了。!!
实际上,接受的答案在大多数情况下没有帮助,因为它确实是一个 DexGuard 问题。经过大量的研究和调试,我终于得到了正确的答案,我在