For Developers‎ > ‎Design Documents‎ > ‎

Java Resources on Android

Overview

Chrome for Android uses certain resources in Java code (e.g. Android layouts and associated strings or images).  These resources are stored according to Android's resource directory structure within a Java root folder.
  • content/public/android/java/res - Java resources available within content and anything that depends on content
  • chrome/android/java/res - Java resources available within chrome and anything that depends on chrome
  • ui/android/java/res - Java resources available within ui and anything that depends on ui
Java code can reference these resources in the normal way using a generated R class, being sure to qualify it with the correct package name.
// Use a resource from content
setImageResource(org.chromium.content.R.drawable.globe_favicon);
 
// Use a resource from chrome
setContentView(org.chromium.chrome.R.layout.month_picker);

How resources are packaged

While compiling the Java code in content, an R.java file is generated based on the Java resources in content.  This R.java contains non-final constants and is used only while compiling content (and any non-APK target that depends on content) but is not included in the content jar.
When building an APK target, such as content_shell_apk, resources are merged from content, any other dependencies, and from content shell itself.  These merged resources are processed and included in the APK.  Based on these resources, a new R.java is generated with the correct resource -> ID mappings.  This R.java is copied into the R packages needed by each dependency (e.g. org.chromium.content.R and org.chromium.content_shell.R), and all these copies are included in the APK.
This process closely follows Android's handling of resources in library projects, where content and chrome are the "libraries", though we don't use the SDK to compile our "libraries".  Hence some of the same caveats apply.  In particular, two resources with the same ID cannot coexist.  The resource highest in the dependency chain (e.g. in content shell) will override the others (e.g. in content).

Supporting resources in gyp

To add resources to another Java root folder, add the variables has_java_resources, R_package, and R_package_relpath to the gyp target that builds that Java code.  For example:
{
  'target_name': 'content_java',
  'type': 'none',
  'dependencies': [ ... ],
  'variables': {
    'package_name': 'content',
    'java_in_dir': '../content/public/android/java',
 
    # Support Java resources in content
    'has_java_resources': 1,
    'R_package': 'org.chromium.content',
    'R_package_relpath': 'org/chromium/content',
  },
  'includes': [ '../build/java.gypi' ],
},

转载于:https://www.cnblogs.com/huangguanyuan/p/9985017.html

Android chromium 1相关推荐

  1. Android Chromium WebView学习

    参考文章: 整体描述 Android Chromium WebView学习启动篇 Chromium Chromium和WebKit的智能指针实现原理分析 Chromium多线程通信的Closure机制 ...

  2. android chromium内核,Chromium内核版马上到,Edge安卓测试版提供新旧浏览器同步选项...

    拼 命 加 载 中 ... 在此前的Ignite 2019大会上,微软已经公布其新的Edge浏览器的正式上市日期,基于Chromium内核的Edge浏览器将会在2020年1月15日发行,并且似乎通过系 ...

  3. Android Chromium WebView Crash

    锤子坚果3 : Android 7.1.2 魅族E3 : Android 7.1.1 华为P9Plus: Android 6.0 Webview Crash: 06-19 17:03:15.819 2 ...

  4. Android与Chromium源码搜索工具

    Android&&Chromium源码搜索

  5. 编译chrome for android,Chrome for Android 编译了两天终于在师傅指导下搞定

    最好代码从git来,或者copy一个打包到文件,否则各种权限会弄得你死去或来的... 流程,假设已经弄到了全部源码, echo "{ 'GYP_DEFINES' : 'OS=android' ...

  6. 《老罗的Android之旅》专栏目录

    Android学习启动篇 在Ubuntu上下载.编译和安装Android最新源代码 在Ubuntu上下载.编译和安装Android最新内核源代码(Linux Kernel) 如何单独编译Android ...

  7. 最新版Microsoft Edge——Chromium内核

    2015年4月30日,微软在旧金山举行的Build 2015开发者大会上宣布,其最新操作系统--Windows 10内置代号为"Project Spartan"的新浏览器被正式命名 ...

  8. android封装浏览器,android利用WebView实现浏览器的封装

    android提供了封装浏览器的接口,可以让开发者利用自己的view显示网页内容.今天又实现研究了一下,利用WebView显示浏览器内容,还可以利用 WebViewClient显示自己需要的内容. 效 ...

  9. android 浏览器

    Android 4.0 Browser增加了表单自动填充功能,比较了一下UC.QQ.Opera.海豚浏览器等,都没有提供此项功能.问了很多人,也没人用过,所以就上网收集了相关资料. 先看看维基百科关于 ...

最新文章

  1. MySql基础入门-mysql体系结构
  2. 07_Android操作sqllite数据库(包括2中方式操作数据的方式),单元测试,BaseAdapter的使用,自定义view的综合使用案例
  3. @Test的作用以及Testcase和TestSuite的用法
  4. 饿了么商家电脑版_饿了么企业版荣膺“2020中国十大影响力人力资源品牌”大奖...
  5. 注入点批量收集工具_原来微信群也是能够批量管理的,学到了
  6. java jdk 的环境变量_Java JDK14(Java 14)在Windows上安装与环境变量配置
  7. python class用法理解_Python小世界:彻底搞懂Python一切皆对象!
  8. orm设置bool型 python_Python SQLAlchemy入门教程
  9. Linux系统安装phpMyAdmin
  10. 2016 - 1 -17 GCD学习总结
  11. java 链表插入排序,insertion Sort List (链表的插入排序) leecode java
  12. 安装Java反编译工具Luyten(Windows例)
  13. jpg转pdf转换器注册码
  14. 福州太冷?那就快来这些地方!不仅有威廉王子的蜜月圣地,也有贝克汉姆的度假天堂!全部免签or落地签...
  15. 自考行政管理计算机应用基础好考吗,通过自考《计算机应用基础》之经验谈
  16. Python语法——列表、元组、集合、字典
  17. creator物理引擎 /RPG运动类型 /坦克
  18. 【设计模式】之 Prototype 原型模式
  19. JAVA -Xms与-Xmx区别
  20. 最小二乘,最大似然,最大后验,查准率与查全率

热门文章

  1. H264 NALU 使用PS封装 RTP发送
  2. jquery.validate不用submit而用js提交的例子
  3. dede使用方法----如何自定义字段
  4. ewebeditor下利用ckplayer增加html5 (mp4)全平台的支持
  5. 【C语言学习趣事】_GCC源代码分析_2_assert.h
  6. CSS3 Animation(下)
  7. 为保障处理器平稳运行请“三知”cpu
  8. 记录一次提交开源JAR包到中央仓库的过程
  9. 重新定义SpringCloud-SpringCloud Eureka笔记- Eureka的核心类(二)
  10. [CF 392 Div.1 D]Three Arrays