java.io.IOException:Can't read [F:\..\android-support-v4.jar] (No such file or directory)

转载请标明出处:http://blog.csdn.net/xx326664162/article/details/48345789 文章出自:薛瑄的博客

你也可以查看我的其他同类文章,也会让你有一定的收货!

操作:

在打包release模式的apk时,出现错误,但在debug中没有错误

错误信息:

Error:Execution failed for task ‘:artandroidclient:transformClassesAndResourcesWithProguardForRelease’.

java.io.IOException: Can’t read [F:\StudioProjects\artandroidclient\artandroidclient\libs\android-support-v4.jar] (No such file or directory)

详解:

The Android Gradle plugin already specifies all input and output for you, so you must not specify -injars, -outjars, or -libraryjars.

Moreover, the file proguard-android.txt in the Android SDK specifies all generic Android settings for you, so you shouldn’t specify them again.

Essentially, your file proguard-rules.txt can be empty, except for any application-specific settings to make sure any reflection continues to work.

如果遇到以下问题可能本质原因也是如此:

  1. Error:Execution failed for task ‘:app:packageRelease’. > Unable to compute hash of /../AndroidStudioProjects/../classes.jar
  2. Cannot make file java.io.IOException: No such file or directory
    第一个问题,由于又重新引用android-support-v4.jar,但是没有这个jar文件,所以出错
    第二个问题,因为在proguard-rules.txt/proguard-project.txt中读到下面这些,又去调用android-support-v4.jar,但是这些内容Android SDK已经帮我们做好了

解决方案:
我注释掉下面的代码在proguard-rules.txt/proguard-project.txt中,错误迎刃而解

 -libraryjars   libs/android-support-v4.jar

但是如果你在proguard-project.txt中,有以下语句也需要注释掉:

-injars      bin/classes
-injars      libs
-outjars     bin/classes-processed.jar

下面这几行代码注释与否,不受影响:

 -dontwarn android.support.v4.**
 -keep class android.support.v4.** { *; }
 -keep interface android.support.v4.app.** { *; }
 -keep public class * extends android.support.v4.**

参考:http://stackoverflow.com/questions/26028171/android-studio-proguard-java-io-ioexception-bin-classes-no-such-file-or-d

关注我的公众号,轻松了解和学习更多技术
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

薛瑄

文章不错,请博主吃包辣条

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值