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

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

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 撸撸猫 设计师:C马雯娟 返回首页