android – Instant Run不适用于proguard

前端之家收集整理的这篇文章主要介绍了android – Instant Run不适用于proguard前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在研究 Android Studio中的“即时运行”功能.但看起来它与proguard不兼容.有没有人知道为什么以及如何让他们一起工作?

我的环境:Android Studio 2.0 Beta 4

我的顶级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()
    }
}

模块的build.gradle:

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

我可以通过上面的设置在gradle控制台中看到一些“instatn run”任务.运行按钮出现黄色霹雳.

: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

但是如果我将“minifyEnabled”设置为true,则Gradle控制台中不再有“即时运行”任务,要么是黄色霹雳按钮.

无论如何让他们一起工作?

解决方法

根据 this官方Android开发者页面,Android Studio在使用Instant Run. 时会禁用ProGuard
原文链接:https://www.f2er.com/android/314585.html

猜你在找的Android相关文章