Android Studio Gradle Build失败-要求提供不存在的SDK版本 [英] Android Studio Gradle Build failing - asking for a sdk version that doesn't exist

查看:428
本文介绍了Android Studio Gradle Build失败-要求提供不存在的SDK版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

24小时前,我的项目构建完美,没有错误.在不更改任何代码的情况下,恢复工作后将不再构建该代码. 现在,检出较早的工作提交会产生相同的错误.

24 hours ago my project built perfectly, no errors. Without changing a single piece of code, it will no longer build when I have resumed work. Checking out to older working commits now produces the same error.

这些是我得到的错误代码:

These are the error codes I get:

Information:Gradle tasks [assemble]
Error:(9, 5) error: resource android:attr/dialogCornerRadius not found.
/home/liam/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0-alpha1.aar/536e4dd78846259cf8bef0fd6a3ea0e6/res/values/values.xml

我认为这是由于发布了Android P以及我的Android Studio自动升级或类似原因造成的.这就可以解释为什么有效的旧提交会遇到同样的错误. 这将是一个非常新的问题,这将解释为什么我现在找不到解决方案.

I think that this has been caused by Android P being released and my Android Studio automatically upgrading or something like that. Which would explain why old commits that worked get this same error. This would be a very new issue, which would explain why I cannot find a solution to it yet.

搜索这些错误代码会导致一个类似的问题,该问题已通过更改gradle构建文件中的SDK版本来解决.我的问题与此不同,因为更改为SDK 28(我很确定28甚至不存在)都会导致android studio表示此程序包不可用/不存在可供下载.

Searching these error codes leads to a similar issue that was resolved by changing the SDK version in the gradle build file. My problem differs from this because changing to SDK 28 (I'm pretty sure 28 doesn't even exist) leads to android studio saying this package isn't available/doesn't exist for download.

如何找到问题Android SDK 3.0错误:(9,5)错误:未找到资源android:attr/colorError

单击第一个提到的错误代码会导致打开一个名为v28/values-v28.xml的文件.

Clicking on the first mentioned error codes leads to a file called v28/values-v28.xml being opened.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Base.Theme.AppCompat" parent="Base.V28.Theme.AppCompat"/>
    <style name="Base.Theme.AppCompat.Light" parent="Base.V28.Theme.AppCompat.Light"/>
    <style name="Base.V28.Theme.AppCompat" parent="Base.V26.Theme.AppCompat">
        <!-- We can use the platform styles on API 28+ -->
        <item name="dialogCornerRadius">?android:attr/dialogCornerRadius</item>
    </style>
    <style name="Base.V28.Theme.AppCompat.Light" parent="Base.V26.Theme.AppCompat.Light">
        <!-- We can use the platform styles on API 28+ -->
        <item name="dialogCornerRadius">?android:attr/dialogCornerRadius</item>
    </style>
</resources>

这是我的gradle文件:

Here are my gradle files:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.timelord.timelord.timelord"
        minSdkVersion 24
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:+'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation files('libs/joda-time-2.9.9.jar')
}

还有

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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


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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

推荐答案

您在build.gradle中具有带+的设计库版本,这意味着它将下载最新版本.因此,请将其设置为26.1.0,它应该可以正常工作.支援28为Alpha版本,并于昨天与新的android P预览版一同发布

You have the design lib version with + in your build.gradle which means it will download the latest version. So please set it to 26.1.0 and it should work. The support 28 is in alpha and was released yesterday with the new android P preview

这篇关于Android Studio Gradle Build失败-要求提供不存在的SDK版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆