检索项目的父项时出错 - Android Studio

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24462128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:12:52  来源:igfitidea点击:

Error retrieving parent for item - Android Studio

androidandroid-studio

提问by orrett3

After downloading the New L SDK and 20 SDK when trying to refresh, build, or clean my project i get a

在尝试刷新、构建或清理我的项目时下载 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'.

Here is my build.gradle

这是我的 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:+'
}

I feel like ive tried just about everything, I'm not sure what else to try. Any help would be appreciated.

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

I just upgraded to the new Android Studio Beta (0.8.0) from 0.6.0 Canary

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

回答by orrett3

Turns out that I had to make the target and compile version to L which meant that I could not run my app on older SDKs. If you want your app to run on SDK 19 and lower you have to set your compile and target version to 19 and your min SDK to whatever version you need.

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

Next you have to adjust your imports to the version that is compatible with the SDKs that you have chosen to compile for. For example if you want to use the v7 support library on sdk 19 you must import it like this: compile compile 'com.android.support:appcompat-v7:20.+'

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

回答by Zafer

just try this:

试试这个:

    android {
        compileSdkVersion 20
        buildToolsVersion '19.1.0'

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

and if you have another module in your project, check manifest files in those modules too.

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

回答by vovahost

If you get similar errors in Eclipsewhen trying to use compatibility libraries with resources (for example: v7 support library)then:
Right-clickthe library project folder (for example: android-support-v7-appcompat)
Select Properties
In the category panel on the left side of the dialog, select Android
In the Project Build Targetcheck the same platform version as in your project

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

回答by Jeroen

Just set your compileVersion to 19 and make sure you are not using the latest compatibility libraries (stick to version 19.1.0). That does the trick for me.

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

回答by INSITE MOBILE

In Android Studio, nothing above worked unless I compiled and targeted the same version (23 in this case...) and added the specific Google reference to compile Google APIs. which fixed all 99 errors after importing and updating from Eclipse:

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

compileSdkVersion 'Google Inc.:Google APIs:23'