报错:

The layout "activity_main" in layout has no declaration in the base layout folder; this can lead to crashes when the resource is queried in a configuration that does not match this qualifier.

详情:
If a resource is only defined in folders with qualifiers like -land or -en, and there is no default declaration in the base folder (layout or values etc), then the app will crash if that resource is accessed on a device where the device is in a configuration missing the given qualifier.  As a special case, drawables do not have to be specified in the base folder; if there is a match in a density folder (such as drawable-mdpi) that image will be used and scaled. Note however that if you only specify a drawable in a folder like drawable-en-hdpi, the app will crash in non-English locales.  There may be scenarios where you have a resource, such as a -fr drawable, which is only referenced from some other resource with the same qualifiers (such as a -fr style), which itself has safe fallbacks. However, this still makes it possible for somebody to accidentally reference the drawable and crash, so it is safer to create a default dummy fallback in the base folder. Alternatively, you can suppress the issue by adding tools:ignore="MissingDefaultResource" on the element.  (This scenario frequently happens with string translations, where you might delete code and the corresponding resources, but forget to delete a translation. There is a dedicated issue id for that scenario, with the id ExtraTranslation.)  Issue id: MissingDefaultResource

翻译:
如果资源仅在具有-land或-en等限定符的文件夹中定义,并且基本文件夹(布局或值等)中没有默认声明,则如果在设备所在的设备上访问该资源,则应用程序将崩溃在配置中缺少给定的限定符。

作为特殊情况,不必在基础文件夹中指定drawable;如果密度文件夹(例如drawable-mdpi)中存在匹配,则将使用和缩放图像。但请注意,如果您只在drawable-en-hdpi等文件夹中指定drawable,则应用程序将在非英语语言环境中崩溃。

在某些情况下,您可能会拥有一个资源,例如-fr drawable,它仅从具有相同限定符的某些其他资源(例如-fr样式)引用,该资源本身具有安全回退。但是,这仍然可以让某人意外地引用drawable和crash,因此在基础文件夹中创建默认的虚拟回退更安全。或者,您可以通过在元素上添加工具:ignore =“MissingDefaultResource”来解决此问题。

(这种情况经常发生在字符串翻译中,您可能会删除代码和相应的资源,但忘记删除翻译。该方案有一个专用的问题ID,ID为ExtraTranslation。)

解决方法:
添加

tools:ignore="MissingDefaultResource"

不知道会不会有后遗症,后续若有解决方法来此编辑~望有大佬指示。

Android The layout "activity_main" in layout has no declaration in the base layout folder的更多相关文章

  1. Android studio新建文件出现setContentView(R.layout.activity_main);中的R标红错误解决方法

    今天打开Android studio突然出现了setContentView(R.layout.activity_main);中的R标红错误,这已经不是第一次出现这个错误了,真心的觉得Android s ...

  2. setContentView(R.layout.activity_main)无法正常引用

    今天在写Android代码的过程中,编译器一直报错,错误出在这一行代码: setContentView(R.layout.activity_main) 提示信息是: activity_main can ...

  3. android动画(3)layout动画,layoutChanged动画及算定义它,ListViewActivity的Layout动画(代码和xm配置两种实现l)

    1.layout切换动画 代码: 本示例是fragment切换.在它的oncreateView中 public class LayoutAnimationFrgmt extends Fragment ...

  4. Android View体系(八)从源码解析View的layout和draw流程

    前言 上一篇文章我们讲了View的measure的流程,接下来我们讲下View的layout和draw流程,如果你理解了View的measure的流程,那这篇文章自然就不在话下了. 1.View的la ...

  5. intellij idea android错误: Missing styles. Is the correct theme chosen for this layout?

    Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layou ...

  6. Android Studio 打开activity_main.xml不能正常显示

    操作系统:Windows 10 x64 IDE:Android Studio 3.2.1 解决方法:http://www.jcodecraeer.com/a/anzhuokaifa/Android_S ...

  7. Android错误之--activity_main cannot be resolved or is not a field

    一般在copy别人的项目中会easy出现本错误,截图例如以下:

  8. 导入别人的Android项目,提示 /Libs/gen already exists but is not a source folder. Convert to a source folder or rename it

    解决方法: 遇到这个问题的解决方法: 1. 右键点击工程,选择 "Properties" 2. 选择左边的 "Java Build Path" 3. 打开 &q ...

  9. Android入门(五)UI-单位与尺寸、ListView

    原文链接:http://www.orlion.ga/453/ 一.单位与尺寸 布局文件中一共有以下单位供选择:px,pt,dp,sp px:是像素,屏幕中可见的最小元素单位. pt:是磅,1磅等于1/ ...

随机推荐

  1. Presto 函数开发

    0. 写在前面 Presto Functions 并不能像 Hive UDF 一样动态加载,需要根据 Function 的类型,实现 Presto 内部定义的不同接口,在 Presto 服务启动时进行 ...

  2. Eclipse普通java Project文件路径问题

    Eclipse普通java Project文件路径问题 项目的结构如图 读取src里某个包下的文件,代码如下 BufferedReader br=new BufferedReader(new File ...

  3. vue学习(十一) v-for使用的注意事项:2.2.0+之后的版本里,当在组件中使用v-for时,key是必须的,它是用来表示唯一身份的

    //html <div id="app"> <div> <label>id <input type="text" v- ...

  4. 数据库(十三):MySQL内置方法

    进击のpython ***** 数据库--MySQL内置方法 目录 数据库--MySQL内置方法 视图 增加 修改 删除 触发器 创建 使用 删除 存储过程 无参 有参 事务 代码实现 视图 视图是一 ...

  5. python3 httpConnection——post请求

    #coding=utf-8 import http.clientimport urllib.parse #与服务器建立链接url = 'code.ali.cn:80' conn = http.clie ...

  6. Kaggle 入门题-泰坦尼克号灾难存活预测

    这个题目的背景概况来讲就是基于泰坦尼克号这个事件,然后大量的人员不幸淹没在这个海难中,也有少部分人员在这次事件之中存活,然后这个问题提供了一些人员的信息如姓名.年龄.性别.票价,所在客舱等等一些信息, ...

  7. 火车进栈(进出栈的模拟,dfs爆搜)

    这里有n列火车将要进站再出站,但是,每列火车只有1节,那就是车头. 这n列火车按1到n的顺序从东方左转进站,这个车站是南北方向的,它虽然无限长,只可惜是一个死胡同,而且站台只有一条股道,火车只能倒着从 ...

  8. 你一个 F12 能秒我?

    参考文章 思路决定成败:F12给了我黑色的眼睛我却用它来挖洞 前言 了解大佬的思路才知道自己现在学的到底有多浅. 还没有到点,我就已经进入状态了,生而为人,我很抱歉. F12 的骚操作 Element ...

  9. 菜鸟教程的 mysql-connector 基础

    安装驱动 python -m pip install mysql-connector 导包 import mysql.connector mydb = mysql.connector.connect( ...

  10. PHP preg_quote() 函数

    preg_last_error 函数用于转义正则表达式字符.高佣联盟 www.cgewang.com 语法 string preg_quote ( string $str [, string $del ...