Android 6.0 gradle 打release包 混淆问题

最近是适配Android 6.0 的时候遇到一个打包的问题
就是在打release包混淆的时候, 一直编译报错, 
错误信息如下:

Warning:com.google.android.gms.internal.zzac: can't find referenced class android.net.http.AndroidHttpClient
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.HttpEntity
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.HttpResponse
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.StatusLine
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.client.HttpClient
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.client.methods.HttpGet
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.conn.ClientConnectionManager
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.params.BasicHttpParams
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.client.methods.HttpGet
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.impl.client.DefaultHttpClient
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.params.BasicHttpParams

Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.HttpEntity 

所找不到一些  apache 的http 相关的类,
但是 一开始一直以为是我们的混淆文件写错了
后面google 了一下, 发现在 Android 6.0 下
Android默认没有使用 apache 的http
使用的是 HttpURLConnection 来代替, 

而且如果只是单纯的加上 上面的还是不够的 ,  gradle build 还要升级到 1.3.1 才可以

ndroid {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    useLibrary 'org.apache.http.legacy'
    ...
}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

使用上面的配置就ok了 

产考了一下内容:


http://stackoverflow.com/questions/32596858/proguard-and-error
https://stackoverflow.com/questions/30856785/how-to-add-apache-http-api-legacy-as-compile-time-dependency-to-build-grade-fo


你可能感兴趣的:(android,gradle)