现在很多库都重新编译了compileSdkVersion 23.但是这个版本不包含apache和一些旧库使用了apache http。对于使用带有23的apache我找到了解决方案,其中说的是将org.apache.http.legacy添加到grudle。
useLibrary 'org.apache.http.legacy'
minifyEnabled true
在' proguard-rules.txt'我只有一个字符串:-dontobfuscate
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
-keep class android.net.http.** { *; }
-dontwarn android.net.http.**
-keep class android.support.v7.** { *; }
-keep class android.support.v4.** { *; }
注意:当禁用proguard( minifyEnabled 设置为 false )时,apk构建并且工作成功。 这是android studio console出错的错误:
:app:proguardRelease
Warning: com.vk.sdk.api.httpClient.VKHttpOperation: can't find referenced method 'org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest)' in program class com.vk.sdk.api.httpClient.VKHttpClient
Warning: org.acra.ErrorReporter: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification
以及更多
Warning: com.mopub.mobileads.VastVideoViewController: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning: com.mopub.mobileads.VastVideoViewController: can't find referenced class org.apache.http.client.methods.HttpGet
Warning: com.mopub.mobileads.factories.HttpClientFactory: can't find referenced class org.apache.http.params.BasicHttpParams
Warning: com.mopub.mobileads.factories.HttpClientFactory: can't find referenced class org.apache.http.params.BasicHttpParams
Warning: com.mopub.mobileads.factories.HttpClientFactory: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.mopub.mobileads.factories.HttpClientFactory: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.mopub.mobileads.factories.HttpClientFactory: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.mopub.mobileads.factories.HttpClientFactory: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.mopub.mobileads.factories.HttpClientFactory: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning: com.mopub.mobileads.util.HttpClients: can't find referenced class org.apache.http.client.HttpClient
Warning: com.mopub.mobileads.util.HttpClients: can't find referenced class org.apache.http.client.HttpClient
Warning: com.mopub.mobileads.util.HttpClients$1: can't find referenced class org.apache.http.client.HttpClient
Warning: com.mopub.mobileads.util.HttpClients$1: can't find referenced class org.apache.http.client.HttpClient
Warning: com.mopub.mobileads.util.HttpClients$1: can't find referenced class org.apache.http.conn.ClientConnectionManager
Warning: com.mopub.mobileads.util.HttpClients$1: can't find referenced class org.apache.http.conn.ClientConnectionManager
Warning: com.mopub.mobileads.util.HttpClients$1: can't find referenced class org.apache.http.client.HttpClient
Warning: com.mopub.mobileads.util.HttpClients$1: can't find referenced class org.apache.http.client.HttpClient
Warning: com.mopub.mobileads.util.vast.VastXmlManagerAggregator: can't find referenced class android.net.http.AndroidHttpClient
答案 0 :(得分:0)
我遇到了同样的问题,并通过以下方式解决了问题:
将Android SDK Build Tools更新为23.0。 1
将MoPub更新为3.13.0
答案 1 :(得分:0)
与google-play-services_lib
有类似的问题。
通过将此行添加到proguard-project.txt中来解决Eclipse:
-libraryjars "<path to sdk>\platforms\android-23\optional\org.apache.http.legacy.jar"
setLatestEventInfo
方法存在同样的问题,它在第23级已被弃用并删除。而这次没有遗留jar。
再说一遍,另一条线:
-libraryjars "<path to sdk>\platforms\android-22\android.jar"
有了这个参考,apache的第一个可能是超级的 - 我现在只需要第一个,因为google-play-services_lib升级到8.2.98版本(虽然最近,仍然引用apache)。