【问题标题】:Error retrieving parent for item - Android Studio检索项目的父项时出错 - Android Studio
【发布时间】:2014-06-27 23:34:07
【问题描述】:

在尝试刷新、构建或清理我的项目时下载 New L SDK 和 20 SDK 后,我得到了一个

Error:Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Subtitle'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Menu'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Title'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Title'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Subtitle'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.

这是我的 build.gradle

apply plugin: 'com.android.application'
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}

repositories {
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}


    signingConfigs{
        release {
           ... Stuff Here ...
        }
    }
    buildTypes {
        debug {
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            zipAlign true
            debuggable true
        }
        release {
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            zipAlign true
            signingConfig signingConfigs.release

        }
    }

    dexOptions {
        incremental true
    }
}

android {
    compileSdkVersion 'android-L'
    buildToolsVersion '20.0.0'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 'L'
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    ...
    Some Projects
    ...
    compile 'com.android.support:cardview-v7:+'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.android.support:appcompat-v7:+'
}

我觉得我几乎什么都试过了,我不知道还能尝试什么。 任何帮助将不胜感激。

我刚刚从 0.6.0 Canary 升级到新的 Android Studio Beta (0.8.0)

【问题讨论】:

  • 尝试设置targetSdkVersion 20
  • 事实证明,使用新的 SDK,您必须将目标和编译版本设置为“L”,这也意味着您无法在低于 L 或 20 的 SDK 上运行它。
  • 查看此以获得更多帮助:stackoverflow.com/questions/42144415/…

标签: android android-studio


【解决方案1】:

事实证明,我必须将目标和编译版本设置为 L,这意味着我无法在较旧的 SDK 上运行我的应用程序。如果您希望您的应用在 SDK 19 或更低版本上运行,您必须将编译和目标版本设置为 19,并将最小 SDK 设置为您需要的任何版本。

接下来,您必须将导入调整为与您选择编译的 SDK 兼容的版本。例如,如果你想在 sdk 19 上使用 v7 支持库,你必须像这样导入它: compile compile 'com.android.support:appcompat-v7:20.+'

【讨论】:

    【解决方案2】:

    试试这个:

        android {
            compileSdkVersion 20
            buildToolsVersion '19.1.0'
    
            defaultConfig {
                minSdkVersion 14
                targetSdkVersion 20
            }
        }
        dependencies {
            compile 'com.android.support:appcompat-v7:19.+'
        }
    

    如果您的项目中有另一个模块,请检查这些模块中的清单文件。

    【讨论】:

      【解决方案3】:

      只需将您的 compileVersion 设置为 19 并确保您没有使用最新的兼容性库(坚持使用版本 19.1.0)。这对我有用。

      【讨论】:

        【解决方案4】:

        如果您在 Eclipse 中尝试使用具有资源的兼容性库时遇到类似错误(例如:v7 支持库),那么:
        对-点击库项目文件夹(例如:android-support-v7-appcompat)
        选择属性
        在对话框左侧的类别面板中,选择 Android
        Project Build Target 中检查与您的项目中相同的平台版本

        【讨论】:

          【解决方案5】:

          在 Android Studio 中,除非我编译并定位相同的版本(在本例中为 23...)并添加特定的 Google 引用来编译 Google API,否则上述任何操作都不起作用。从 Eclipse 导入和更新后修复了所有 99 个错误:

          compileSdkVersion 'Google Inc.:Google APIs:23'

          【讨论】:

            猜你喜欢
            • 2017-09-09
            • 2016-03-04
            • 2016-08-15
            • 1970-01-01
            • 2015-02-10
            • 1970-01-01
            • 1970-01-01
            • 2016-02-26
            • 1970-01-01
            相关资源
            最近更新 更多