4

我正在使用Android 1.3版本和SDK for 5.0.1我減少了它,因爲每當我構建項目時都會拋出錯誤。Android Studio不能在使用AppCompat v23和API21構建應用程序時工作

誰能告訴在細節怎麼辦呢..

錯誤:

Information:Gradle tasks [:app:assembleDebug] 
:app:preBuild UP-TO-DATE 
:app:preDebugBuild UP-TO-DATE 
:app:checkDebugManifest 
:app:preReleaseBuild UP-TO-DATE 
:app:prepareComAndroidSupportAppcompatV72300Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42300Library UP-TO-DATE 
:app:prepareDebugDependencies 
:app:compileDebugAidl UP-TO-DATE 
:app:compileDebugRenderscript UP-TO-DATE 
:app:generateDebugBuildConfig UP-TO-DATE 
:app:generateDebugAssets UP-TO-DATE 
:app:mergeDebugAssets UP-TO-DATE 
:app:generateDebugResValues UP-TO-DATE 
:app:generateDebugResources UP-TO-DATE 
:app:mergeDebugResources UP-TO-DATE 
:app:processDebugManifest UP-TO-DATE 
:app:processDebugResources 
C:\Users\This-PC\AndroidStudioProjects\MyApplication\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.0\res\values-v23\values-v23.xml 
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'. 
Error:(2) 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\This-PC\AppData\Local\Android\Sdk\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1 
Information:BUILD FAILED 
Information:Total time: 1.701 secs 
Information:3 errors 
Information:0 warnings 
Information:See complete output in console 

事件日誌顯示:

10:52:47 PM Platform and Plugin Updates: A new version of Android Studio is available! (show balloon) 
10:52:48 PM Gradle sync started 
10:53:22 PM Gradle sync failed: failed to find target android-22 : C:\Users\This-PC\AppData\Local\Android\Sdk 
      Consult IDE log for more details (Help | Show Log) 
11:06:43 PM Gradle sync started 
11:06:49 PM Gradle sync completed 
11:06:50 PM Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources] 
11:07:03 PM Gradle build finished with 3 error(s) in 13s 912ms 
11:09:47 PM Executing tasks: [:app:assembleDebug] 
11:09:50 PM Gradle build finished with 3 error(s) in 2s 345ms 
11:10:44 PM Throwable: Failed to fetch URL https://dl.google.com/android/repository/addons_list-2.xml, reason: Unknown Host dl.google.com 
11:15:08 PM Error Report: Submitted 
11:15:55 PM Executing tasks: [:app:assembleDebug] 
11:15:57 PM Gradle build finished with 3 error(s) in 1s 992ms 
+0

'10:52:47 PM平臺和插件更新:Android Studio的新版本可用!'你試過更新嗎? V1.3.1可用。 – DigitalNinja

+0

是的,我升級它的android工作室和SDK到API級別23,然後也是同樣的情況再次發生 –

+1

可能重複[Android Studio/Gradle:錯誤檢索父項目:找不到匹配給定名稱的資源](http:// stackoverflow.com/questions/32075498/android-studio-gradle-error-retrieving-parent-for-item-no-resource-found-that) – Fragment

回答

7

您正在使用appcompat(和其他支持庫)v23
你必須用API 23來編譯你的項目。

改變你build.gradlecompileSdkVersion

0

你有你的SDK更新到API 23(如果你用23編譯)。
compileSdkVersion,和支持庫版本應該相同。以下代碼表示這些與第3行和第2行dependencies中的相同。

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.0" 

    defaultConfig { 
     applicationId "com.example.inzi.app" 
     minSdkVersion 9 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:23.0.0' 
} 
+1

請不要複製並粘貼您的答案在更多的職位。在這種情況下,如果在原始問題中沒有報告,您如何知道build.gradle的最後一行? 您可以閱讀gradle stacktrace,作者正在使用appcompat23。 是的,支持庫v23必須匹配api23,所以你必須用api 23編譯。 –

+0

是的,當gabriele告訴我時我改變了它。猜測它運行的很好 –

相關問題