Reputation: 1825
I am going to generate signed apk from android studio and i am trying to decrease .apk file size.So from somewhere i got solution to use Progaurd and for that i have to make change in build.gradle file. The change is the make "minifyEnabled true" instead of "minifyEnabled false". here is build.gradle file code
apply plugin: 'com.android.application'
1android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.rahu.createsomething"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
Now the Question is When i Make "minifyEnabled true" i decrease my file size for 1.47 GB to 0.97 MB. But when i run that apk file it shows error message "Unfortunately Close application".
And when generate apk with the "minifyEnable false" then it generate 1.47 GB .apk file and it works fine. But i want 0.97 MB apk so how can i generate it?
here is my error logcat message
07-08 23:18:21.983 29845-29845/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.AssertionError
at com.abc.android.publish.i.b.a.bf.<init>(Unknown Source)
at com.abc.android.publish.i.b.a.as.a(Unknown Source)
at com.abc.android.publish.i.k.a(Unknown Source)
at com.abc.android.publish.i.b.a.q.<init>(Unknown Source)
at com.abc.android.publish.i.b.a.p.a(Unknown Source)
at com.abc.android.publish.i.b.a.p.a(Unknown Source)
at com.abc.android.publish.i.b.a.p.a(Unknown Source)
at com.abc.android.publish.i.k.a(Unknown Source)
at com.abc.android.publish.i.k.a(Unknown Source)
at com.abc.android.publish.i.k.a(Unknown Source)
at com.abc.android.publish.i.k.a(Unknown Source)
at com.abc.android.publish.i.k.a(Unknown Source)
at com.abc.android.publish.af.a(Unknown Source)
at com.abc.android.publish.q.a(Unknown Source)
at com.abc.android.publish.q.a(Unknown Source)
at com.rahu.createsomething.CreateSomething.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5283)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
at android.app.ActivityThread.access$700(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5283)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Upvotes: 0
Views: 575
Reputation: 3430
Can you put detailed stack trace...I guess the issue is due to proguard optimization.
Sometimes if you use external library/jars proguard causes issues.
Also if you are calling code (the classes referenced in the code are not referenced anywhere else) through reflection and that particular class has been removed by the proguard tool,you might face an exception at runtime.
There are various ways of configuring proguard-http://developer.android.com/tools/help/proguard.html#configuring
Upvotes: 2