2016-04-20 99 views
0

首先我對我的糟糕英語表示歉意。我的問題是我無法調和的是不同版本的Android上運行兩個代碼,因爲它們是:與HttpClient和SDK v23的兼容性

import org.apache.http.client.HttpClient; (This work with 22) 
    import com.github.paolorotolo.appintro.AppIntro;(This work with 23) 

如果我把我的項目到版本22,它僅適用了HTTPClient,而是改爲23無法識別,但它適用於AppIntro。 附件「build.gradle」和每種情況下的錯誤輸出。我因爲他們是非常適合我的項目,具有諷刺意味的

apply plugin: 'com.android.application' 

    android { 
compileSdkVersion 22 
buildToolsVersion "22.0.1" 

defaultConfig { 
    applicationId "com.example.victo.cqbo_definitive" 
    minSdkVersion 15 
    targetSdkVersion 22 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 
dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:22.2.0' 
    compile 'com.github.paolorotolo:appintro:3.4.0' 
} 


Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'. 
Error:(24) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. 
Error:Execution failed for task ':app:processDebugResources'. 
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\victo\AppData\Local\Android\sdk\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1 

預先感謝您非常多,我希望能幫助我用C液

回答

0

與Android L移動開始與兩個合作,谷歌不再維護Apache HTTP庫。他們專注於URLConnection Java API。

幸運的,它總是可以使用上API23 + Apache的HTTP庫通過把useLibrary 'org.apache.http.legacy'在gradle這個腳本:

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.0" 
    useLibrary 'org.apache.http.legacy' 
    ... 
} 

Android 6.0 Changes - Apache HTTP Client Removal

+0

當我嘗試這樣做,構建失敗,此錯誤: 錯誤:無法找到可選庫:org.apache.http.legacy –

+0

可能是您的SDK的問題。請務必在Android SDK Manager中更新您的構建工具和Android工具。從[這](http://stackoverflow.com/questions/33898857/why-warningunable-to-find-optional-library-org-apache-http-legacy-occurs)。 – doubotis

+0

謝謝,像魅力一樣工作。 –