Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 1.0.2 "minifyEnabled true" crashes the signed release apk

Upgrading to Android Studio 1.0.2 causes the signed release apk file to crash as soon as the application is launched(debug apk works fine).

Setting the **minifiyEnabled to false ** fixes the crash in the signed release apk files.

The buildTypes section of the build.gradle(Module:app) file looks like below

   buildTypes {
        release {
            minifyEnabled  false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

The line getDefaultProguardFile seems to be the suspect since the android studio shows underlines the getDefaultProguardFile and when hovered over it shows warning Cannot resolve symbol getDefaultProguardFile.

The following is the build.gradle(project) file

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

The following is the build.gradle(app) file contents

apply plugin: 'android'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 17
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled  false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:6.1.+'

}

Update 1:

There are some warning in the gradle build
Executing tasks: [:app:assembleRelease]

Configuration on demand is an incubating feature.
:app:preBuild
:app:preReleaseBuild
:app:checkReleaseManifest
:app:preDebugBuild
:app:prepareComAndroidSupportAppcompatV72103Library
:app:prepareComAndroidSupportSupportV42103Library
:app:prepareComGoogleAndroidGmsPlayServices6171Library
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets
:app:generateReleaseResValues
:app:generateReleaseResources
:app:mergeReleaseResources
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-xhdpi/abc_ab_share_pack_holo_light.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/src/main/res/drawable/bell_48_48.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-hdpi/abc_spinner_mtrl_am_alpha.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-hdpi/abc_ab_share_pack_holo_dark.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-hdpi/abc_ab_share_pack_holo_light.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-xhdpi/abc_ab_share_pack_holo_dark.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-mdpi/abc_ab_share_pack_holo_dark.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited

:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:compileReleaseJava
Note: /home/hhk/src/android_project/govinda_suprabhatam_alarm/app/src/main/java/com/suprabhatam/alarm/MainActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

:app:lintVitalRelease
:app:compileReleaseNdk
:app:preDexRelease
:app:dexRelease
:app:processReleaseJavaRes UP-TO-DATE
:app:validateExternalOverrideSigning
:app:packageRelease
:app:zipalignRelease
:app:assembleRelease

BUILD SUCCESSFUL

Total time: 41.768 secs

The relevant error message of adb logcat is below

D/dalvikvm(  326): threadid=1: interp stack at 0x41c23000
E/AndroidRuntime(32767): FATAL EXCEPTION: main
E/AndroidRuntime(32767): java.lang.NullPointerException
E/AndroidRuntime(32767):    at com.suprabhatam.alarm.MainActivity.onCreateOptionsMenu(Unknown Source)
E/AndroidRuntime(32767):    at android.app.Activity.onCreatePanelMenu(Activity.java:2508)
E/AndroidRuntime(32767):    at android.support.v4.app.o.onCreatePanelMenu(Unknown Source)
E/AndroidRuntime(32767):    at android.support.v7.app.e.a(Unknown Source)
E/AndroidRuntime(32767):    at android.support.v7.app.g.a(Unknown Source)
E/AndroidRuntime(32767):    at android.support.v7.app.ActionBarActivityDelegateBase.b(Unknown Source)
E/AndroidRuntime(32767):    at android.support.v7.app.ActionBarActivityDelegateBase.d(Unknown Source)
E/AndroidRuntime(32767):    at android.support.v7.app.ActionBarActivityDelegateBase.a(Unknown Source)
E/AndroidRuntime(32767):    at android.support.v7.app.h.run(Unknown Source)
E/AndroidRuntime(32767):    at android.os.Handler.handleCallback(Handler.java:800)
E/AndroidRuntime(32767):    at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(32767):    at android.os.Looper.loop(Looper.java:194)
E/AndroidRuntime(32767):    at android.app.ActivityThread.main(ActivityThread.java:5391)
E/AndroidRuntime(32767):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(32767):    at java.lang.reflect.Method.invoke(Method.java:525)
E/AndroidRuntime(32767):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
E/AndroidRuntime(32767):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
E/AndroidRuntime(32767):    at dalvik.system.NativeStart.main(Native Method)
V/Provider/Settings(  554):  from settings cache , name = dropbox:data_app_crash , value = null
D/dalvikvm(  554): create interp thread : stack size=128KB

....
....
D/PowerManagerService(  554): updateScreenStateLocked: mDisplayReady=true, newScreenState=2, mWakefulness=1, mWakeLockSummary=0x1, mUserActivitySummary=0x1, mBootCompleted=true
D/PowerManagerService(  554): handleSandman: canDream=true, mWakefulness=Awake
V/Provider/Settings(  554):  from settings cache , name = anr_show_background , value = null
V/ActivityManager(  554): Broadcast: Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } ordered=false userid=0 callerApp=ProcessRecord{41c6a9c0 554:system/1000}
D/AES     (  554): ExceptionLog: notify aed
D/AES     (  554):     process : com.suprabhatam.alarm
D/AES     (  554):      module : com.suprabhatam.alarm v1 (1.0)
D/AES     (  554): 
D/AES     (  554):       cause : data_app_crash
D/AES     (  554):       pid : 32767
D/AEE/LIBAEE(  554): shell: raise_exp(2, 32767, -1361051648, com.suprabhatam.alarm, 0x0x61e05008, 0x0x0)

....
....
D/AEE/AED (  122): p 4 poll events 1 revents 0
D/AEE/AED (  122): not know revents:0
D/dalvikvm(32767): DexOpt: --- END 'ads714289260.jar' (success) ---
D/dalvikvm(32767): DEX prep '/data/data/com.suprabhatam.alarm/cache/ads714289260.jar': unzip in 1ms, rewrite 87ms
V/WindowManager(  554): Changing focus from Window{421f4cd0 u0 com.suprabhatam.alarm/com.suprabhatam.alarm.MainActivity} to Window{427208a0 u0 Application Error: com.suprabhatam.alarm}
I/WindowManager(  554): Gaining focus: Window{427208a0 u0 Application Error: com.suprabhatam.alarm}
D/dalvikvm(32767): create interp thread : stack size=128KB

....
....
I/BufferQueue(  129): [unnamed-129-849](this:0x4153dc80,api:0) setSynchronousMode: enabled=1
I/BufferQueue(  129): [unnamed-129-849](this:0x4153dc80,api:0) setDefaultBufferSize: w=1, h=1
I/BufferQueue(  129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:0) setConsumerName: Application Error: com.suprabhatam.alarm
D/KeyguardViewMediator(  554): setHidden false
D/KeyguardUpdateMonitor(  554): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor(  554): handleKeyguardVisibilityChanged(1)
D/KeyguardViewMediator(  554): handleMessage enter msg name=SET_HIDDEN
D/KeyguardViewMediator(  554): handleMessage exit msg name=SET_HIDDEN
I/BufferQueue(  129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:0) setDefaultBufferSize: w=480, h=220
I/BufferQueue(  129): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41542040,api:0) consumerDisconnect
I/BufferQueue(  129): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41542040,api:0) ~BufferQueue
I/GraphicBuffer(  129): free buffer (w:480 h:854 f:1) handle(0x43662f78)
D/KeyguardViewMediator(  554): setHidden false
D/KeyguardUpdateMonitor(  554): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor(  554): handleKeyguardVisibilityChanged(1)
D/KeyguardViewMediator(  554): handleMessage enter msg name=SET_HIDDEN
D/KeyguardViewMediator(  554): handleMessage exit msg name=SET_HIDDEN
I/BufferQueue(  129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:0) connect: api=2
I/BufferQueue(  129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:2) setSynchronousMode: enabled=1
I/BufferQueue(  129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:2) new GraphicBuffer needed
D/BufferQueue(  129):     [OLD] gb:NULL
I/GraphicBuffer(  129): allocate buffer (w:480 h:220 f:1) handle(0x414f7050) err(0)
I/BufferQueue(  129):     [NEW] gb=0x41523678, handle=0x414f7050, w=480, h=220, s=480, fmt=1
D/GraphicBuffer(  554): create handle(0x636639d0) (w:480, h:220, f:1)
D/KeyguardViewMediator(  554): setHidden false
D/KeyguardUpdateMonitor(  554): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor(  554): handleKeyguardVisibilityChanged(1)
D/KeyguardViewMediator(  554): handleMessage enter msg name=SET_HIDDEN
D/KeyguardViewMediator(  554): handleMessage exit msg name=SET_HIDDEN
I/SurfaceTexture(  129): [Application Error: com.suprabhatam.alarm](this:0x41521b80,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)]

....
....
V/webcore (24597): webkitDraw NEW_PICTURE_MSG_ID
V/webview (24597): NEW_PICTURE_MSG_ID
D/webkit/webview(24597): setNewPicture::start
D/webkit/webview(24597): setNewPicture::processing 111
D/KeyguardViewMediator(  554): setHidden false
D/KeyguardUpdateMonitor(  554): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor(  554): handleKeyguardVisibilityChanged(1)
D/KeyguardViewMediator(  554): handleMessage enter msg name=SET_HIDDEN
D/KeyguardViewMediator(  554): handleMessage exit msg name=SET_HIDDEN
W/ActivityManager(  554): Activity pause timeout for ActivityRecord{41c6b7a8 u0 com.suprabhatam.alarm/.MainActivity}
V/ActivityManager(  554): Enqueueing pending finish: ActivityRecord{41c6b7a8 u0 com.suprabhatam.alarm/.MainActivity}

....
....
I/alpha   (  804): AppContentView == draw  +++1.0
I/BufferQueue(  129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:2) new GraphicBuffer needed
D/BufferQueue(  129):     [OLD] gb:NULL
I/GraphicBuffer(  129): allocate buffer (w:480 h:220 f:1) handle(0x41543e88) err(0)
I/BufferQueue(  129):     [NEW] gb=0x43661a98, handle=0x41543e88, w=480, h=220, s=480, fmt=1
D/GraphicBuffer(  554): create handle(0x65525ad8) (w:480, h:220, f:1)
I/alpha   (  804): AppContentView == draw  +++1.0
I/zdx2    (  804): ----------------Workspace.updateChildrenLayersEnabled----true
I/zdx2    (  804): ----------------Workspace.updateChildrenLayersEnabled----true
I/SurfaceTexture(  129): [Application Error: com.suprabhatam.alarm](this:0x41521b80,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)]
D/SurfaceTexture(  129):     GraphicBuffer: gb=0x43661a98 handle=0x41543e88
D/SurfaceTexture(  129):     EGLImage: dpy=0x1, img=0x1000000b
I/alpha   (  804): AppContentView == draw  +++1.0
D/MsensorDaemon(  333): Msensor deamon statr!!!!!!!!!!!!
D/MsensorDaemon(  333): open demon attr err = No such file or directory
I/alpha   (  804): AppContentView == draw  +++1.0
I/alpha   (  804): AppContentView == draw  +++1.0

....
....
D/SignalClusterViewGemini(  647): apply(). mIsAirplaneMode is false
D/NetworkControllerGemini(  647): PhoneStateListener:onDataActivity, sim0 after.
I/BufferQueue(  129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:2) new GraphicBuffer needed
D/BufferQueue(  129):     [OLD] gb:NULL
I/GraphicBuffer(  129): allocate buffer (w:480 h:220 f:1) handle(0x43661bf0) err(0)
I/BufferQueue(  129):     [NEW] gb=0x41526478, handle=0x43661bf0, w=480, h=220, s=480, fmt=1
D/GraphicBuffer(  554): create handle(0x6294fd48) (w:480, h:220, f:1)
I/SurfaceTextureClient(  554): [STC::queueBuffer] (this:0x639270a0) fps:1.66, dur:1201.78, max:974.38, min:227.40
I/BufferQueue(  129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:2) [queue] fps:1.66, dur:1201.87, max:974.35, min:227.53
I/SurfaceTexture(  129): [Application Error: com.suprabhatam.alarm](this:0x41521b80,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)]

The MainActivity::onCreateOptionMenu method is defined as

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);

    MenuItem item = (MenuItem) menu.findItem(R.id.action_share);
    ShareActionProvider shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    Intent shareIntent = new Intent(Intent.ACTION_SEND)
            .putExtra(Intent.EXTRA_TEXT, "text")
            .setType("text/plain");

    shareAction.setShareIntent(shareIntent);

    return true;
}
like image 589
Talespin_Kit Avatar asked Jan 28 '15 18:01

Talespin_Kit


1 Answers

Add the following rules to your proguard-rules.pro file.

-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class android.support.v7.app.** { *; }
-keep interface android.support.v7.app.** { *; }

If the file doesn't exist, you can create it under app/proguard-rules.pro. Note that the file may not show up if you have Android Studio set to the "Android" view. You may need to temporarily switch to the "Project" view to find it.

like image 85
James McCracken Avatar answered Sep 28 '22 04:09

James McCracken