1

我注意到gradle assembleRelease在过时的 ProGuard 版本上运行调用,从 shell 输出中可以看出:

$ gradle assembleRelease
Relying on packaging to define the extension of the main artifact has been \
  deprecated and is scheduled to be removed in Gradle 2.0
:Foobar:preBuild UP-TO-DATE
:Foobar:preReleaseBuild UP-TO-DATE
:Foobar:preDebugBuild UP-TO-DATE
:Foobar:prepareComAndroidSupportAppcompatV71900Library UP-TO-DATE
:Foobar:prepareComGoogleAndroidGmsPlayServices3136Library UP-TO-DATE
:Foobar:prepareReleaseDependencies
:Foobar:compileReleaseAidl UP-TO-DATE
:Foobar:compileReleaseRenderscript UP-TO-DATE
:Foobar:generateReleaseBuildConfig UP-TO-DATE
:Foobar:mergeReleaseAssets UP-TO-DATE
:Foobar:mergeReleaseResources UP-TO-DATE
:Foobar:processReleaseManifest UP-TO-DATE
:Foobar:processReleaseResources UP-TO-DATE
:Foobar:generateReleaseSources UP-TO-DATE
:Foobar:compileRelease UP-TO-DATE
:Foobar:proguardRelease
ProGuard, version 4.9
The output seems up to date
:Foobar:dexRelease UP-TO-DATE
:Foobar:processReleaseJavaRes UP-TO-DATE
:Foobar:packageRelease UP-TO-DATE
:Foobar:assembleRelease UP-TO-DATE

BUILD SUCCESSFUL

Total time: 15.703 secs

我在我的使用以下配置build.gradle

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

apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
    }

    buildTypes {
        release {
            runProguard true
            proguardFile 'proguard-project.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:19.0.0'
    compile 'com.android.support:support-v4:19.0.0'
    compile 'com.google.android.gms:play-services:3.1.36'
}

如何将 gradle 指向可能从PATH例如/usr/local/bin/proguard?

另一种解决方案是引用所需的版本,如下所示:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
        classpath 'net.sf.proguard:proguard-gradle:4.10'
    }
}
...

你的设置是什么?

4

1 回答 1

2

官方Proguard文档显示了如何在build.gradle. 看这里

根据 Proguard 手册,您可以执行以下操作以指向 proguard 二进制文件,

buildscript {
    repositories {
        flatDir dirs: '/usr/local/java/proguard/lib'
    }
    dependencies {
        classpath ':proguard'
    }
}

我认为这可能会导致 android SDK 附带的 proguard 版本出现问题。还没试过!!

于 2013-11-04T22:41:14.090 回答