Android问题集锦之四十七: Error:Execution failed for task ':app:packageRelease'. > Unable to compute hash of

使用jna的jar包时混淆编译遇到了这个问题,就在上面列出了jna相关的警告。在http://stackoverflow.com/questions/31643339/errorexecution-failed-for-task-apppackagerelease-unable-to-compute-hash 找到了答案。
需要在proguard-rules.pro中制定编译规则,将jna相关包的警告忽略。

-keep class com.sun.jna.** { *; }
-dontwarn com.sun.jna.**

注意,如果是以module引入的,需要在主app中的proguard-rules.pro文件中忽略。

原文如下:
All the current answers to this question are just giving the Proguard rules that worked for them, every fix will be different. First off, confirm it’s a Proguard problem by checking that the classes-proguard directory is somewhere in the error message, something like this: Unable to compute hash of /Users/Documents/projectX/app/build/intermediates/classes-proguard/release/classes.jar

This means it’s caused by an earlier Proguard error so you need to scroll up in the Messages window or Gradle Console window and check what warnings or errors you’re getting. Just as an example, in my current project, Square’s Picasso library is causing the error: Warning: com.squareup.picasso.OkHttpDownloader: can’t find referenced class com.squareup.okhttp.OkHttpClient. I just added -dontwarn com.squareup.okhttp.** to ignore the warnings, and the app still worked as normal.

A lot of the Proguard errors will be warnings about some class so just adding -dontwarn for whatever class is causing it in your project often works.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值