Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instant Run doesn't work with proguard

I am researching the "instant run" feature in Android Studio. But it looks like it doesn't work with proguard. Is there anybody know why and how to get them work together?

My environment: Android Studio 2.0 Beta 4

My top level build.gradle

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0-beta4'
    }
}

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        mavenCentral()
        jcenter()
    }
}

The build.gradle for module:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 23
    }
    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.1.1'
}

I can see some following "instatn run" tasks in gradle console with the above setting. And there is a yellow thunderbolt appear with the run button.

:TestIR:transformClassesWithInstantRunVerifierForDebug
:TestIR:transformClassesWithInstantRunForDebug
:TestIR:transformClasses_enhancedWithInstant+reloadDexForDebug
:TestIR:generateDebugInstantRunAppInfo
:TestIR:transformClassesWithInstantRunSlicerForDebug
Dexing C:\git\android\TestIR\build\intermediates\transforms\instantRunSlicer\debug\folders\1\5\slice_1 took 328
Dexing C:\git\android\TestIR\build\intermediates\transforms\instantRunSlicer\debug\folders\1\5\slice_0 took 340
Dexing C:\git\android\TestIR\build\intermediates\transforms\instantRunSlicer\debug\folders\1\5\slice_2 took 331
Dexing C:\git\android\TestIR\build\intermediates\transforms\instantRunSlicer\debug\folders\1\5\slice_5 took 321
Dexing C:\git\android\TestIR\build\intermediates\transforms\instantRunSlicer\debug\folders\1\5\slice_3 took 456

But if I set "minifyEnabled" to true, there is no "instant run" task in Gradle console any more, either the yellow thunderbolt button.

Is there anyway to get them work together?

like image 536
Sean Shi Avatar asked Feb 16 '16 21:02

Sean Shi


1 Answers

According to this official Android developer page, Android Studio disables ProGuard when using Instant Run.enter image description here

like image 115
Pravin Divraniya Avatar answered Oct 03 '22 20:10

Pravin Divraniya