Android打包遇到的那些坑

时间:2022-04-26
本文章向大家介绍Android打包遇到的那些坑,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

说说今天打包遇到的坑,由于线上有个支付的bug需要紧急修复,而我们的项目又没有使用热修复,所以只能通过编译打包等传统流程,还好android上线比较快。

说说我进早上打包遇到的几个问题吧,首先我使用build-->generate signed apk然后输入签名打包,啪,给我报了一个错。

1,debug-stripped.ap_' specified for property 'resourceFile' does not exist.

这什么错,怎么一起没遇到过,马上度娘,找了半天找到一个和我很相似的,意思是android studio升级到2.2之后出现的错误,于是我也尝试了一把下面的方法:

File—>Settings,打开Settings界面,搜索到Instant Run。

,2怎么我的默认就是没选中的啊,于是看第二条,有人说是Debug模式下的混淆开关问题。

好我都把你改了,debug我都false行了吧,形如:

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        minifyEnabled false
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

3,我又重新编译,结果报Android Studio 混淆打包 IOException: Please correct the above warnings first,形如下面的错误

Warning:org.apache.http.impl.conn.tsccm.RouteSpecificPool: can't find referenced class org.apache.commons.logging.LogFactory  
Warning:org.apache.http.impl.conn.tsccm.RouteSpecificPool: can't find referenced class org.apache.commons.logging.Log  
Warning:org.apache.http.impl.conn.tsccm.RouteSpecificPool: can't find referenced class org.apache.commons.logging.LogFactory  
Warning:org.apache.http.impl.conn.tsccm.RouteSpecificPool: can't find referenced class org.apache.commons.logging.Log  
Warning:org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: can't find referenced class org.apache.commons.logging.LogFactory  
Warning:org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: can't find referenced class org.apache.commons.logging.Log  
Warning:org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: can't find referenced class org.apache.commons.logging.LogFactory  
Warning:org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: can't find referenced class org.apache.commons.logging.Log  
Warning:org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1: can't find referenced class org.apache.commons.logging.Log  
Warning:there were 210 unresolved references to classes or interfaces.  
         You may need to add missing library jars or update their versions.  
         If your code works fine without the missing classes, you can suppress  
         the warnings with '-dontwarn' options.  
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)  
Warning:there were 1 unresolved references to library class members.  
         You probably need to update the library versions.  
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)  
:app:proguardRelease FAILED  
Error:Execution failed for task ':app:proguardRelease'.  
> java.io.IOException: Please correct the above warnings first.  

好吧,我打开混淆文件(proguard-rules),首先我看到有人把下面的ignorewarning注释了,我擦,然后关闭,打包成功,不过这里加上下面的一段话

打包报错java.io.IOException: Please correct the above warnings first.
-dontwarn org.apache.http.**