Notbad Notbad - 3 months ago 21
Android Question

Fatal exception when building on release (dexguard) but not in debug

I have seen this is a common problem with devices on 4.4. I have read a bunch of other threads about the abc_ic_ab_back_material.xml and I have been able to solve the problem in debug but not in release. Could anyone help here?. Here the exception:


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.access$800(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.access$800(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.access$800(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) 


My app/gradle file:

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'
}


Thanks in advance.

Answer

You just need to change the version of support library dependencies. Change 23.2.1 to 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'
}

EDIT:

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.

I was facing the same problem and solved by updating the version of libraries to the latest ones.!!