当前位置: 首页 > news >正文

Android.mk 中覆盖应用包名

项目场景:

一般来讲应用包名都是配置在 AndroidManifest.xml 中的,但遇到特殊情况,需要修改源码中应用包名

通常都会先去改 AndroidManifest.xml package 但改为后编译发现一顿错误,原因是 java 类中已经指定了 R 文件包名,

几百个都去替换那岂不是一堆文件需要 add,所以想找找有没有快捷方法,还真被我找到了。

解决方案:

通过配置 LOCAL_AAPT_FLAGS := rename-manifest-package "com.android.camera" 就可以

毕竟在 AS 中通过 gradle 配置 applicationId 就可以修改包名,想来 mk 中也是有的,不常用而已。

一开始发现 mk 中可以修改应用的版本号,那么猜测是不是也可以修改包名。

LOCAL_AAPT_FLAGS := --version-name "$(version_name_package)"
LOCAL_AAPT_FLAGS := --version-code "$(version_code_package)"

通过以上配置可以修改应用版本号,我就顺手配了个 LOCAL_AAPT_FLAGS := --package “com.android.camera”

编译小试一下,报错提示如下

aapt2 link [options] -o arg --manifest arg files…
Options:
-o arg Output path.
–manifest arg Path to the Android manifest to build.
-I arg Adds an Android APK to link against.
-A arg An assets directory to include in the APK. These are unprocessed.
-R arg Compilation unit to link, using overlay semantics.
The last conflicting resource given takes precedence.
–package-id arg Specify the package ID to use for this app. Must be greater or equal to
0x7f and can’t be used with --static-lib or --shared-lib.
–java arg Directory in which to generate R.java.
–proguard arg Output file for generated Proguard rules.
–proguard-main-dex arg Output file for generated Proguard rules for the main dex.
–proguard-conditional-keep-rules Generate conditional Proguard keep rules.
–proguard-minimal-keep-rules Generate a minimal set of Proguard keep rules.
–no-auto-version Disables automatic style and layout SDK versioning.
–no-version-vectors Disables automatic versioning of vector drawables. Use this only
when building with vector drawable support library.
–no-version-transitions Disables automatic versioning of transition resources. Use this only
when building with transition support library.
–no-resource-deduping Disables automatic deduping of resources with
identical values across compatible configurations.
–no-resource-removal Disables automatic removal of resources without
defaults. Use this only when building runtime resource overlay packages.
–enable-sparse-encoding This decreases APK size at the cost of resource retrieval performance.
-x Legacy flag that specifies to use the package identifier 0x01.
-z Require localization of strings marked ‘suggested’.
-c arg Comma separated list of configurations to include. The default
is all configurations.
–preferred-density arg Selects the closest matching density and strips out all others.
–product arg Comma separated list of product names to keep
–output-to-dir Outputs the APK contents to a directory specified by -o.
–no-xml-namespaces Removes XML namespace prefix and URI information
from AndroidManifest.xml and XML binaries in res/*.
–min-sdk-version arg Default minimum SDK version to use for AndroidManifest.xml.
–target-sdk-version arg Default target SDK version to use for AndroidManifest.xml.
–version-code arg Version code (integer) to inject into the AndroidManifest.xml if none is
present.
–version-code-major arg Version code major (integer) to inject into the AndroidManifest.xml if none is
present.
–version-name arg Version name to inject into the AndroidManifest.xml if none is present.
–revision-code arg Revision code (integer) to inject into the AndroidManifest.xml if none is
present.
–replace-version If --version-code, --version-name, and/or --revision-code are specified, these
values will replace any value already in the manifest. By
default, nothing is changed if the manifest already defines
these attributes.
–compile-sdk-version-code arg Version code (integer) to inject into the AndroidManifest.xml if none is
present.
–compile-sdk-version-name arg Version name to inject into the AndroidManifest.xml if none is present.
–shared-lib Generates a shared Android runtime library.
–static-lib Generate a static Android library.
–proto-format Generates compiled resources in Protobuf format.
Suitable as input to the bundle tool for generating an App Bundle.
–no-static-lib-packages Merge all library resources under the app’s package.
–non-final-ids Generates R.java without the final modifier. This is implied when
–static-lib is specified.
–no-proguard-location-reference Keep proguard rules files from having a reference to the source file
–stable-ids arg File containing a list of name to ID mapping.
–emit-ids arg Emit a file at the given path with a list of name to ID mappings,
suitable for use with --stable-ids.
–private-symbols arg Package name to use when generating R.java for private symbols.
If not specified, public and private symbols will use the application’s
package name.
–custom-package arg Custom Java package under which to generate R.java.
–extra-packages arg Generate the same R.java but with different package names.
–add-javadoc-annotation arg Adds a JavaDoc annotation to all generated Java classes.
–output-text-symbols arg Generates a text file containing the resource symbols of the R class in
the specified folder.
–allow-reserved-package-id Allows the use of a reserved package ID. This should on be used for
packages with a pre-O min-sdk

–auto-add-overlay Allows the addition of new resources in overlays without
tags.
–override-styles-instead-of-overlaying Causes styles defined in -R resources to replace previous definitions
instead of merging into them

–rename-manifest-package arg Renames the package in AndroidManifest.xml.
–rename-resources-package arg Renames the package in resources table
–rename-instrumentation-target-package arg Changes the name of the target package for instrumentation. Most useful
when used in conjunction with --rename-manifest-package.
–rename-overlay-target-package arg Changes the name of the target package for overlay. Most useful
when used in conjunction with --rename-manifest-package.
-0 arg File suffix not to compress.
–no-compress Do not compress any resources.
–keep-raw-values Preserve raw attribute values in xml files.
–no-compress-regex arg Do not compress extensions matching the regular expression. Remember to
use the ‘$’ symbol for end of line. Uses a case-sensitive ECMAScriptregular expression grammar.
–warn-manifest-validation Treat manifest validation errors as warnings.
–split arg Split resources matching a set of configs out to a Split APK.
Syntax: path/to/output.apk:[,[…]].
On Windows, use a semicolon ‘;’ separator instead.
–exclude-configs arg Excludes values of resources whose configs contain the specified qualifiers.
–debug-mode Inserts android:debuggable=“true” in to the application node of the
manifest, making the application debuggable even on production devices.
–strict-visibility Do not allow overlays with different visibility levels.
–exclude-sources Do not serialize source file information when generating resources in
Protobuf format.
–trace-folder arg Generate systrace json trace fragment to specified folder.
–merge-only Only merge the resources, without verifying resource references. This flag
should only be used together with the --static-lib flag.
-v Enables verbose logging.
-h Displays this help menu

可以看到完整的使用提示 ,在其中就可以找到 --rename-manifest-package arg Renames the package in AndroidManifest.xml.

参考文章

Android应用编译时自动生成版本号

相关文章:

Android.mk 中覆盖应用包名

项目场景: 一般来讲应用包名都是配置在 AndroidManifest.xml 中的,但遇到特殊情况,需要修改源码中应用包名 通常都会先去改 AndroidManifest.xml package 但改为后编译发现一顿错误,原因是 java 类中已经指定了 R 文件包名&…...

如何最有效地使用ChatGPT:提问技巧与策略

前言 在如今信息技术高速发展的时代,像ChatGPT这样的大型自然语言处理模型为我们提供了一个强大的工具,以获取各种信息和答案。然而,要充分利用这一工具,您需要掌握一些提问技巧与策略,以确保获得最准确和有用的回答。…...

【JAVA学习笔记】40 - 抽象类、模版设计模式(抽象类的使用)

项目代码 https://github.com/yinhai1114/Java_Learning_Code/tree/main/IDEA_Chapter10/src/com/yinhai/abstract_ 一、抽象类的引入 很多时候在创建类的时候有一个父类,比如animal类,他的子类会有各种方法,为了复用需要进行方法的重写&…...

如何通过在线培训考试系统进行远程教育

随着互联网技术的不断发展,远程教育正在成为一种新型的学习方式,它使学生能够在任何地点、任何时间通过在线培训考试系统接受教育。 利用在线培训考试系统进行远程教育具有很大的灵活性。学生可以根据自己的时间和需求自由选择课程,无需受制…...

2021-arXiv-The Power of Scale for Parameter-Efficient Prompt Tuning

2021-arXiv-The Power of Scale for Parameter-Efficient Prompt Tuning Paper: https://arxiv.org/abs/2104.08691 Code: https://github.com/google-research/ text-to-text-transfer-transformer/ blob/main/released_checkpoints.md# lm-adapted-t511lm100k 在这项工作中&…...

计算机视觉与深度学习 | 非线性优化理论:图优化、高斯牛顿法和列文伯格-马夸尔特算法

===================================================== github:https://github.com/MichaelBeechan CSDN:https://blog.csdn.net/u011344545 ===================================================== 计算机视觉与深度学习 | SLAM国内外研究现状 计算机视觉与深度学习 | 视…...

一文说尽零售数据分析指标体系

零售的本质业务模式是通过在各种渠道上吸引客户来购买我们的商品来实现盈利,其实就是客户-渠道-商品,也就是我们常说的“人、场、货”,除此之外还有供应链、财务等起到重要的辅助作用。因此如果要构建起系统化的零售数据分析指标体系&#xf…...

AT2659一款卫星导航低噪声放大器芯片(LNA)

产品介绍 AT2659 是一款专门针对中国 BDS(北斗卫星导航系统),美国的 GPS,俄罗斯的 GLONASS 和欧盟的 GALILEO 导航系统应用而设计的高增益、低噪声系数射频放大器。 AT2659 具有 23dB 高增益和 0.71dB 的低噪声系数。芯片支持 …...

GoLong的学习之路(二)语法之基本数据类型

书接上回:我在GoLong的学习之路(一)中在常量最后说了iota的作用。今天这里我在介绍一下我学习Go语言中基本数据类型。 文章目录 Go中的基本数据类型整型特殊整型数字字面语法 浮点型复数布尔值字符串字符串转义符多行字符字符串的常用操作&am…...

网关概念及java项目中用使用网关场景

网关(Gateway)是一个在网络系统中起到入口和出口的作用的组件或服务。它位于客户端和服务器之间,负责处理进出网络的流量,实现一些重要的功能,如路由、安全认证、协议转换等。 网关在网络架构中扮演了多种角色&#x…...

网页禁止右键 禁止F12 JavaScript禁止F12 禁止右键菜单 包含 js、Jquery、Vue

网页禁止右键 禁止F12 Jquery禁止F12 禁止右键菜单 包含 Jquery、Vue 网页禁止右键 禁止F12 JavaScript禁止F12 禁止右键菜单 jsJavaScript 中Jquery 中Vue 中 这样设置通常是出于安全性或保护内容的目的,不想让别人看到源代码等信息 网页禁止右键 禁止F12 JavaScr…...

Linux系统编程07

线程 为什么有了进程还需要线程 进程切换的时候会花费很大的代价 (1)上下文切换,CPU寄存器需要切换 (2)虚拟地址和物理地址的映射需要切换 进程间通信麻烦 线程是轻量级的进程 (1)线程是一个正…...

html web前端 登录,短信验证码登录

html web前端 登录,短信验证码登录 1,手机号码格式校验 2,按钮点击60秒倒计时,按钮限制点击 3,验证码/或密码长度校验(被注释,公司发的验证码长度不一致,不一定是6位) 4…...

(免费领源码)php#Thinkphp#MYSQL校园二手交易app 99211-计算机毕业设计项目选题推荐

目 录 摘要 Abstract 1 绪论 1.1 研究背景 1.2国内外研究现状 1.3论文结构与章节安排 2 校园二手物品交易app系统分析 2.1 可行性分析 2.2 系统流程分析 2.2.1 数据流程 3.3.2 业务流程 2.3 系统功能分析 2.3.1 功能性分析 2.3.2 非功能性分析 2.4 系统用例分析…...

用Python做数据分析之数据筛选及分类汇总

1、按条件筛选(与,或,非) 为数据筛选,使用与,或,非三个条件配合大于,小于和等于对数据进行筛选,并进行计数和求和。与 excel 中的筛选功能和 countifs 和 sumifs 功能相似…...

RabbitMQ高级篇 笔记

这是一些高级的内容。 RabbitMQ还是运行在网络上的,倘若遇到了网络故障,mq自己挂了,出异常了,都会造成最终状态不一致的问题。这就是可靠性问题。 可靠性:一个消息发送出去之后,至少被消费1次。 要解决这3个…...

javaEE -9(7000字详解TCP/IP协议)

一: IP 地址 IP地址(Internet Protocol Address)是指互联网协议地址,又译为网际协议地址。 IP地址是IP协议提供的一种统一的地址格式,它为互联网上的每一个网络和每一台主机分配一个逻辑地址,以此来屏蔽物…...

在mybatis的xml中使用枚举来做判断条件

1.枚举类 import com.baomidou.mybatisplus.annotation.IEnum; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import com.shinkeer.common.utils.StringUtils;import java.util.HashMap; import java.util.Map;…...

scala集合的partition方法使用

在Scala中,partition 方法用于将集合(例如 List、Array ,Set等)中的元素根据给定的条件分成两个部分,并返回一个元组,其中包含两个新的集合,第一个包含满足条件的元素,另一个包含不满…...

18 Transformer 的动态流程

博客配套视频链接: https://space.bilibili.com/383551518?spm_id_from333.1007.0.0 b 站直接看 配套 github 链接:https://github.com/nickchen121/Pre-training-language-model 配套博客链接:https://www.cnblogs.com/nickchen121/p/15105048.html 机…...

Qt/C++开发监控GB28181系统/取流协议/同时支持udp/tcp被动/tcp主动

一、前言说明 在2011版本的gb28181协议中,拉取视频流只要求udp方式,从2016开始要求新增支持tcp被动和tcp主动两种方式,udp理论上会丢包的,所以实际使用过程可能会出现画面花屏的情况,而tcp肯定不丢包,起码…...

Go 语言接口详解

Go 语言接口详解 核心概念 接口定义 在 Go 语言中,接口是一种抽象类型,它定义了一组方法的集合: // 定义接口 type Shape interface {Area() float64Perimeter() float64 } 接口实现 Go 接口的实现是隐式的: // 矩形结构体…...

LLM基础1_语言模型如何处理文本

基于GitHub项目:https://github.com/datawhalechina/llms-from-scratch-cn 工具介绍 tiktoken:OpenAI开发的专业"分词器" torch:Facebook开发的强力计算引擎,相当于超级计算器 理解词嵌入:给词语画"…...

Android Bitmap治理全解析:从加载优化到泄漏防控的全生命周期管理

引言 Bitmap(位图)是Android应用内存占用的“头号杀手”。一张1080P(1920x1080)的图片以ARGB_8888格式加载时,内存占用高达8MB(192010804字节)。据统计,超过60%的应用OOM崩溃与Bitm…...

在QWebEngineView上实现鼠标、触摸等事件捕获的解决方案

这个问题我看其他博主也写了,要么要会员、要么写的乱七八糟。这里我整理一下,把问题说清楚并且给出代码,拿去用就行,照着葫芦画瓢。 问题 在继承QWebEngineView后,重写mousePressEvent或event函数无法捕获鼠标按下事…...

基于SpringBoot在线拍卖系统的设计和实现

摘 要 随着社会的发展,社会的各行各业都在利用信息化时代的优势。计算机的优势和普及使得各种信息系统的开发成为必需。 在线拍卖系统,主要的模块包括管理员;首页、个人中心、用户管理、商品类型管理、拍卖商品管理、历史竞拍管理、竞拍订单…...

LLMs 系列实操科普(1)

写在前面: 本期内容我们继续 Andrej Karpathy 的《How I use LLMs》讲座内容,原视频时长 ~130 分钟,以实操演示主流的一些 LLMs 的使用,由于涉及到实操,实际上并不适合以文字整理,但还是决定尽量整理一份笔…...

Vite中定义@软链接

在webpack中可以直接通过符号表示src路径,但是vite中默认不可以。 如何实现: vite中提供了resolve.alias:通过别名在指向一个具体的路径 在vite.config.js中 import { join } from pathexport default defineConfig({plugins: [vue()],//…...

django blank 与 null的区别

1.blank blank控制表单验证时是否允许字段为空 2.null null控制数据库层面是否为空 但是,要注意以下几点: Django的表单验证与null无关:null参数控制的是数据库层面字段是否可以为NULL,而blank参数控制的是Django表单验证时字…...

libfmt: 现代C++的格式化工具库介绍与酷炫功能

libfmt: 现代C的格式化工具库介绍与酷炫功能 libfmt 是一个开源的C格式化库,提供了高效、安全的文本格式化功能,是C20中引入的std::format的基础实现。它比传统的printf和iostream更安全、更灵活、性能更好。 基本介绍 主要特点 类型安全&#xff1a…...