更新后安卓工作室中的资源错误:找不到资源

2022-08-31 10:16:12

在最近对 Android Studio 进行更新后,我们在编译以前工作过的项目时遇到问题。起初,我们收到以下错误:

/Users/james/Development/AndroidProjects/myapp/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'.

我将 gradle 文件中的 sdk 构建目标更新到了 23,这使得这个特定问题消失了,但它给我们留下了大量的 apache.http 包错误(具体来说,我们用于 http 内容的大量 apache 包现在在 sdk 23 中消失了)。

我想做的是解决奇怪的资源错误,但不更新到sdk 23。我现在没有时间重写我们的工具库来使用已经发布的apache http组件的任何新实现。有人有什么想法吗?


答案 1

您需要将编译SdkVersion设置为23。

由于API 23 Android删除了已弃用的Apache Http包,因此,如果您将它们用于服务器请求,则需要添加到build.gradle,如以下链接所述:useLibrary 'org.apache.http.legacy'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"
    ...

    //only if you use Apache packages
    useLibrary 'org.apache.http.legacy'
}

答案 2

将 build.gradle 文件中的 appcompat 版本更改回 22.2.1(或您之前使用的任何内容)。


推荐