我给我的gradle添加了收缩选项,然而以下错误总是发生:
:app:shrinkDefaultConfigDebugMultiDexComponents FAILED
Error:Execution failed for task
:app:shrinkDefaultConfigDebugMultiDexComponents'.
java.io.IOException: The output jar [[mypath]/componentClasses.jar] must be specified after an input jar, or it will be empty.
这是我的gradle config:
debug{
project.archivesBaseName = "zcctest131"
signingConfig signingConfigs.myConfig
minifyEnabled true
shrinkResources true
}
和我还启用了多重索引选项:
multiDexEnabled = true
编译'com.android.support:multidex:1.0.1'
通过检查生成的组件。flags文件,其路径为app/build/intermediates/multi-dex/defaultConfig/debug/components.jar
,我发现第一行变成:
outjars /Users/zcc/app/build/intermediates/multi-dex/defaultConfig/debug/componentClasses.jar
:
injars /Users/zcc/app/build/intermediates/multi-dex/anZhi/release/allclasses.jar
缺失,导致IOException
。
proguard源代码如下:
/**
* Reads the input jars (or directories).
*/
private void readInput() throws IOException
{
if (configuration.verbose)
{
System.out.println("Reading jars...");
}
// Check if we have at least some program jars.
if (configuration.programJars == null)
{
throw new IOException("The input is empty. You have to specify one or more '-injars' options.");
}
// Read the input program jars.
readInput("Reading program ",
configuration.programJars,
createDataEntryClassPoolFiller(false));
…http://proguard.sourceforge.net/quality/compatibility/code/proguard/ProGuard.html
我该如何解决这个问题?非常感谢。
正确的方法是将proguard规则文件添加到构建类型中,而不是添加到Flavors块中。