错误:生成APK时,任务':app:transformClassesAndResourcesWithProguardForRelease'的执行失败 [英] Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease' while generating APK
问题描述
我已经生成了一个Android应用程序的APK(作为尝试),但我没有任何问题,该APK已正确生成.
现在,我想在生成APK时混淆代码,因此我在build.gradle
文件的release
块上使用了以下行.
minifyEnabled true
问题在于,现在它引发了以下错误:
错误:任务':app:transformClassesAndResourcesWithProguardForRelease'的执行失败. java.io.IOException:请首先更正以上警告.
有很多警告.更确切地说,是1018条警告.
其中大多数是这样的:
警告:com.itextpdf.text.pdf.security.PdfPKCS7:找不到引用的类org.spongycastle.asn1.tsp.MessageImprint
或
警告:com.github.mikephil.charting.data.realm.base.RealmBaseDataSet:找不到引用的类io.realm.Sort
总是相同的错误.找不到引用类的类.
我正在使用 MPAndroidChart
,所以我认为是这样相关(由于警告中显示的软件包名称),但我无法更正这些警告.
作为证明,我尝试使用以下方法保留课程:
-keep public class com.itextpdf.text.pdf.**
在我的proguard-rules.pro
文件上,但是我仍然有相同的警告.
我在build.gradle
文件上的release
部分是:
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
我在混淆代码时会丢失某些东西吗?
提前谢谢!
最后,我发现MPAndroidChart
具有 文档 ,其中介绍了如何配置Proguard.
具有以下配置:
-keep class com.github.mikephil.charting.** { *; }
-dontwarn io.realm.**
我能够创建没有任何警告的模糊APK.
此外,我注意到itextpdf
是我过去使用的库,但是现在我不需要它,因此我只需要从gradle文件的依赖项中删除它,警告也就消失了. /p>
I have generated an APK of my Android application (as a try) and I did not have any problem, the APK has been generated correctly.
Now, I want to obfuscate my code while generating the APK so I used the following line on my release
block on build.gradle
file.
minifyEnabled true
The problem is that now it throws me the following error:
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. java.io.IOException: Please correct the above warnings first.
with a lot of warnings. To be more exact, 1018 warnings.
Most of them are like:
Warning:com.itextpdf.text.pdf.security.PdfPKCS7: can't find referenced class org.spongycastle.asn1.tsp.MessageImprint
or
Warning:com.github.mikephil.charting.data.realm.base.RealmBaseDataSet: can't find referenced class io.realm.Sort
Always is the same error. A class that cannot find a referenced class.
I am using MPAndroidChart
so I think it is something related (because of the name of the packages that appears on the warnings) but I am not able to correct those warnings.
EDIT: As a prove, I have tried keeping the classes using:
-keep public class com.itextpdf.text.pdf.**
on my proguard-rules.pro
file but I still have the same warnings.
My release
section on build.gradle
file is:
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Am I missing something while obfuscating my code?
Thanks in advance!
Finally, I have found that MPAndroidChart
has a document in which tells you how to configure Proguard.
With the following configuration:
-keep class com.github.mikephil.charting.** { *; }
-dontwarn io.realm.**
I was able to create the obfuscate APK without any warnings.
Also, I have noticed that itextpdf
was a library that I used on the past but I did not need it nowadays so I just have to delete it from the dependencies on my gradle file and the warnings also have dissapeared.
这篇关于错误:生成APK时,任务':app:transformClassesAndResourcesWithProguardForRelease'的执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!