【问题标题】:Android Studio Not Working while building App using AppCompat v23 and API21使用 AppCompat v23 和 API21 构建应用程序时 Android Studio 不工作
【发布时间】:2015-11-13 04:03:48
【问题描述】:

我使用的是 Android 1.3 版本和 SDK for 5.0.1 我已将其废弃,因为每当我构建项目时都会引发错误。

谁能详细说说怎么做..

错误:

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

【问题讨论】:

标签: android gradle android-gradle-plugin android-support-library android-appcompat


【解决方案1】:

您正在使用 appcompat(和其他支持库)v23
您必须使用 API 23 编译您的项目。

将您的 build.gradle 更改为 compileSdkVersion23

【讨论】:

    【解决方案2】:

    您必须将您的 SDK 更新到 API 23(如果您使用 23 进行编译)。
    compileSdkVersion, 和支持库版本应该相同。下面的代码表明这些与dependencies中的第3行和第2行相同。

    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'
    }
    

    【讨论】:

    • 请不要在更多帖子中复制粘贴您的答案。在这种情况下,如果原始问题中没有报告 build.gradle 的最后一行,您怎么知道?正如您可以阅读 gradle stacktrace 一样,作者使用的是 appcompat23。是的,支持库 v23 必须与 api23 匹配,因此您必须使用 api 23 进行编译。
    • 是的,当 gabriele 告诉我我改变它时,我明白了。猜猜它运行良好
    猜你喜欢
    • 2015-11-12
    • 2016-06-11
    • 1970-01-01
    • 2018-04-09
    • 1970-01-01
    • 2015-11-26
    • 2016-02-10
    • 1970-01-01
    • 2019-07-25
    相关资源
    最近更新 更多