简体   繁体   English

Gradle 构建:找不到资源 android:style/TextAppearance.Material

[英]Gradle build: resource android:style/TextAppearance.Material not found

I just installed AndroidStudio and imported an old Eclipse ADT project (API level 18).我刚刚安装了 AndroidStudio 并导入了一个旧的 Eclipse ADT 项目(API 级别 18)。 However, when trying to build this project in AndroidStudio, I get the following errors:但是,当尝试在 AndroidStudio 中构建此项目时,出现以下错误:

resource android:style/TextAppearance.Material not found.   
resource android:style/TextAppearance.Material.Body1 not found. 
resource android:style/TextAppearance.Material.Body2 not found. 
resource android:style/TextAppearance.Material.Button not found.    
resource android:style/TextAppearance.Material.Caption not found.   
resource android:style/TextAppearance.Material.Display1 not found.  
resource android:style/TextAppearance.Material.Display2 not found.  
resource android:style/TextAppearance.Material.Display3 not found.  
resource android:style/TextAppearance.Material.Display4 not found.  
resource android:style/TextAppearance.Material.Headline not found.  
resource android:style/TextAppearance.Material.Inverse not found.   
resource android:style/TextAppearance.Material.Large not found. 
resource android:style/TextAppearance.Material.Large.Inverse not found. 
resource android:style/TextAppearance.Material.Widget.PopupMenu.Large not found.    
resource android:style/TextAppearance.Material.Widget.PopupMenu.Small not found.    
resource android:style/TextAppearance.Material.Medium not found.    
resource android:style/TextAppearance.Material.Medium.Inverse not found.    
resource android:style/TextAppearance.Material.Menu not found.  
resource android:style/TextAppearance.Material.SearchResult.Subtitle not found. 
resource android:style/TextAppearance.Material.SearchResult.Title not found.    

How can I fix this error?我该如何解决这个错误? Which further information shall I provide?我应该提供哪些进一步的信息?

This is the import protocol, in case it helps:这是导入协议,以防万一:

ECLIPSE ANDROID PROJECT IMPORT SUMMARY
======================================

Manifest Merging:
-----------------
Your project uses libraries that provide manifests, and your Eclipse
project did not explicitly turn on manifest merging. In Android Gradle
projects, manifests are always merged (meaning that contents from your
libraries' manifests will be merged into the app manifest. If you had
manually copied contents from library manifests into your app manifest
you may need to remove these for the app to build correctly.

Ignored Files:
--------------
The following files were *not* copied into the new Gradle project; you
should evaluate whether these are still needed in your project and if
so manually move them:

* .gitignore
* ic_launcher-web.png
* proguard-project.txt

Replaced Jars with Dependencies:
--------------------------------
The importer recognized the following .jar files as third party
libraries and replaced them with Gradle dependencies instead. This has
the advantage that more explicit version information is known, and the
libraries can be updated automatically. However, it is possible that
the .jar file in your project was of an older version than the
dependency we picked, which could render the project not compileable.
You can disable the jar replacement in the import wizard and try again:

android-support-v4.jar => com.android.support:support-v4:18.0.0

Replaced Libraries with Dependencies:
-------------------------------------
The importer recognized the following library projects as third party
libraries and replaced them with Gradle dependencies instead. This has
the advantage that more explicit version information is known, and the
libraries can be updated automatically. However, it is possible that
the source files in your project were of an older version than the
dependency we picked, which could render the project not compileable.
You can disable the library replacement in the import wizard and try
again:

google-play-services_lib => [com.google.android.gms:play-services:+]

Moved Files:
------------
Android Gradle projects use a different directory structure than ADT
Eclipse projects. Here's how the projects were restructured:

* AndroidManifest.xml => app\src\main\AndroidManifest.xml
* assets\ => app\src\main\assets
* libs\commons-net-3.3.jar => app\libs\commons-net-3.3.jar
* res\ => app\src\main\res\
* src\ => app\src\main\java\

Next Steps:
-----------
You can now build the project. The Gradle project needs network
connectivity to download dependencies.

Bugs:
-----
If for some reason your project does not build, and you determine that
it is due to a bug or limitation of the Eclipse to Gradle importer,
please file a bug at http://b.android.com with category
Component-Tools.

(This import summary is for your information only, and can be deleted
after import once you are satisfied with the results.)

Your compile SDK version MUST match the support library .您的编译 SDK 版本必须支持库匹配。 so here is an example with latest version.所以这是一个最新版本的例子。 Do something similar with yours or update to the latest version ( recommended ) like below:做一些与你类似的事情或更新到最新版本(推荐),如下所示:

1.In your Build.gradle change: 1.在您的Build.gradle更改中:

implementation 'com.android.support:appcompat-v7:28.0.0'

2.Change compileSdkVersion and buildToolsVersion to: 2. 将 compileSdkVersion 和 buildToolsVersion 更改为:

compileSdkVersion 28
buildToolsVersion "28.0.3"

3.Update Project gradle file: 3.更新项目gradle文件:

classpath 'com.android.tools.build:gradle:3.4.1'

And i suggest you to update all your dependencies in your project in the latest version, i would help you more if you provide us gradle files.我建议您将项目中的所有依赖项更新为最新版本,如果您向我们提供 gradle 文件,我会为您提供更多帮助。 Hope this help you.希望这对你有帮助。

You can also try and clean the project in android studio.您也可以尝试在 android studio 中清理项目。 Sometimes that helps.有时这有帮助。

Build -> Rebuild Project

Make sure you have this in your dependencies:确保您的依赖项中有这个:

  • if you're using androidx如果您使用的是 androidx

implementation 'com.google.android.material:material:1.0.0'

  • else别的

implementation 'com.android.support:design:28.0.0'

Also, check your application's gradle file if it includes google() under repositories section:此外,检查您的应用程序的 gradle 文件是否在存储库部分下包含google()

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

See https://material.io/develop/android/docs/getting-started/ for more details.有关更多详细信息,请参阅https://material.io/develop/android/docs/getting-started/

看看这个,可能是支持库没有被导入的问题

First u must add require dependency to builde.gradle (module):首先你必须向builde.gradle (module) 添加 require 依赖:

implementation 'com.google.android.material:material:1.1.0'

next, change AppStyle in style.xml to:接下来,将style.xml AppStyle 更改为:

style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar"

I hope that solves your problem.我希望这能解决你的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到资源android:style / TextAppearance.Material - resource android:style/TextAppearance.Material not found 错误:找不到资源android:style / TextAppearance.Material - error: resource android:style/TextAppearance.Material not found 如何修复错误:找不到资源android:style / TextAppearance.Material? - How to fix the error: resource android:style/TextAppearance.Material not found? Eclipse中的错误-检索项目的父项时出错:找不到与给定名称'android:TextAppearance.Material'相匹配的资源 - Error in Eclipse- Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material' 错误:(1)检索项目的父项时出错:找不到与给定名称“ android:TextAppearance.Material”匹配的资源 - Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material' 添加 dataBinding 标签时找不到资源 android:style/TextAppearance.Material.Notification - resource android:style/TextAppearance.Material.Notification not found on adding dataBinding tag React Native:错误:找不到资源android:style/TextAppearance.Material.Widget.Button.Borderless.Colored - React Native: error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found 错误:资源 android:未找到样式/TextAppearance.Material.Widget.Button.Borderless.Colored - Error:resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found 找不到与给定名称“ android:TextAppearance.Material.Widget.Button.Borderless.Colored”匹配的资源 - No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored' 找不到与给定名称'android:TextAppearance.Material.Widget.Button.Colored匹配的资源 - No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM