报错:

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. 初步知道scss 简化css复杂层级

    简介:今天在调试前端样式的时候,el-button组件位置需要调整并且 需要改字体大小 .直接上了一个 font-text:20px; 发现没作用,谷歌调试发现并未作用到组件里的<span> ...

  2. integrator.setTimeout 设置一个超时时间,超过这个时间之后,扫描的 Activity 将会被 finish 。

    integrator.setTimeout 设置一个超时时间,超过这个时间之后,扫描的 Activity 将会被 finish . +++++++++++++++++++ 经查,没有这个功能

  3. 导弹拦截问题 dp c++

    // // Created by snnnow on 2020/4/13. // //每一次拦截只能是降续的导弹 //如果该次不能拦截成功,则拦截次数需要加一 //求每次最大拦截量,以及需要的拦截次数 ...

  4. Django坑_02

    在创建订单的时候会创建一个对应的日期 查询数据库表的时候,查询年的话可以正常实现 但是如果单独查询某一个月的话,可能会出错 在 Django 中月份可能会使用 Django 中定义的时区 将 项目 s ...

  5. PHP uniqid() 函数

    实例 生成一个唯一的 ID: <?phpecho uniqid();?>高佣联盟 www.cgewang.com 定义和用法 uniqid() 函数基于以微秒计的当前时间,生成一个唯一的 ...

  6. luogu P4321 随机漫游 期望dp 二进制 高斯消元

    LINK:随机漫游 非常妙的一道题. 容易想到倒推期望. 设状态 f[i][j]表示到达第i个点 此时已经到达的集合为j能走到全集的期望边数. 只要求出来这个就能O(1)回答询问. \(f[i][j] ...

  7. win10搭建基于docker的odoo开发环境

  8. Python自动化运维 技术与最佳实践PDF高清完整版免费下载|百度云盘|Python基础教程免费电子书

    点击获取提取码:7bl4 一.内容简介 <python自动化运维:技术与最佳实践>一书在中国运维领域将有"划时代"的重要意义:一方面,这是国内第一本从纵.深和实践角度探 ...

  9. 基于Qt实现的TCP端口数据转发服务器

    对于Qt,比较喜欢qt的sdk框架,我也是用于做一些工作中用到的工具软件,基于qt的sdk做起来也比较快: 一.概述 今天要说的这个tcp端口转发服务器,主要是用于将监听端口的数据转发到另外一个服务器 ...

  10. 14、Cahin of Responsibility 责任链 COR设计模式

    1.责任链模式 chain of responsibility 责任链模式 责任链,顾名思义,就是用来处理相关事务责任的一条执行链,执行链上有多个节点,每个节点都有机会(条件匹配)处理请求事务,如果某 ...