Proguard [ java.lang.IllegalArgumentException: Overflow of unsigned short value ]

房东的猫 提交于 2021-02-19 01:29:19

问题


Gradle ver : 3.4.1
JDK ver : 1.8
Proguard ver : 5.3.3
Android gradle plugin 2.3.+
I am getting exception in build due to proguard. I have tried proguard 5.3.2 also but with no success.

Here is my release config

release {
        debuggable false
        android.buildTypes.release.proguardFiles = []
        proguardFile 'proguard-android.txt'
        //minifyEnabled
        shrinkResources true
        signingConfig = signingConfigs.release
    }

Following is the exeption

Caused by: java.lang.IllegalArgumentException: Overflow of unsigned short value [95001]
at proguard.classfile.io.RuntimeDataOutput.writeUnsignedShort(RuntimeDataOutput.java:213)
at proguard.classfile.io.ProgramClassWriter$AttributeBodyWriter.visitLineNumberInfo(ProgramClassWriter.java:565)
at proguard.classfile.attribute.LineNumberTableAttribute.lineNumbersAccept(LineNumberTableAttribute.java:171)

PS: I can build with android gradle plugin 2.2.+ that is using lower version of proguard I think.


回答1:


This issue (PGD-681) was fixed in Proguard v6.0.

However, Android Plugin for Gradle v3.1.0 is still using Proguard v5.3.3. You can check it running ./gradlew buildEnvironment:

classpath
+--- com.android.tools.build:gradle:3.1.0
|    \--- com.android.tools.build:gradle-core:3.1.0
...
|         +--- net.sf.proguard:proguard-gradle:5.3.3
|         |    \--- net.sf.proguard:proguard-base:5.3.3

So you have to manually include the latest version of Proguard:

classpath('com.android.tools.build:gradle:3.1.2') {
    exclude module: 'proguard-gradle'
}
classpath('net.sf.proguard:proguard-gradle:6.0.3') {
    force = true
}



回答2:


Manually set proguard version to 5.2.1

classpath('com.android.tools.build:gradle:2.3.0') {
    exclude module: 'proguard-gradle'
}
classpath('net.sf.proguard:proguard-gradle:5.2.1') {
    force = true
}

Reference



来源:https://stackoverflow.com/questions/46200033/proguard-java-lang-illegalargumentexception-overflow-of-unsigned-short-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!