我正在尝试构建应用程序的发布版本并获取 apk。作为回应,我收到一条消息
Generate Signed APK
Errors while building APK. You can find the errors in the 'Messages' view.
在日志中这样写
错误:任务 ':app:transformClassesAndResourcesWithProguardForRelease' 执行失败。任务失败,查看日志了解详情
好吧,它指的是用于处理网络的库
Warning:library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.params.HttpParams
Warning:library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.protocol.HttpRequestExecutor
Warning:library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.protocol.HttpContext
Warning:library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.ConnectionReuseStrategy
Warning:library class org.apache.http.impl.client.DefaultHttpClient depends on program class org.apache.http.protocol.BasicHttpProcessor
Warning:there were 74 unresolved references to classes or interfaces.
Warning:there were 127 instances of library classes depending on program classes.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
事件簿
13:43:52 Gradle build finished with 1 error(s) and 169 warning(s) in 13s 295ms
13:43:52 Build APK: Errors while building APK. You can find the errors in the 'Messages' view.
您已为发布版本启用混淆器。很可能您的 proguard.pro 文件配置不正确。
这里关于proguard
这是各种流行库的规则集合
在你的情况下,也许这组会有所帮助:
在文件 build.gradle 中更改
minifyEnabled true为minifyEnabled false并且它有效。