【错误记录】Tinker 热修复示例运行报错 ( Execution failed for task ‘:app:tinkerProcessD‘ . tinkerId is not set!!! )

简介: 【错误记录】Tinker 热修复示例运行报错 ( Execution failed for task ‘:app:tinkerProcessD‘ . tinkerId is not set!!! )

文章目录

一、报错信息

二、问题分析

三、解决方案

1、解决方案 1

2、解决方案 2





一、报错信息


运行 tinker 官方示例 https://github.com/Tencent/tinker/tree/dev/tinker-sample-android , 编译时 , 报如下错误 ;



FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:tinkerProcessDebugManifest'.
> tinkerId is not set!!!
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
9 actionable tasks: 9 executed

image.png




二、问题分析


需要阅读 Gradle 脚本 , 分析报错原因 ;



仔细阅读 build.gradle 构建脚本 , 配置 TINKER_ID 的代码如下 ,


buildConfigField "String", "TINKER_ID", "\"${getTinkerIdValue()}\""


通过 getTinkerIdValue 方法 , 获取 TINKER_ID , 在 getTinkerIdValue 方法中会查询是否有 TINKER_ID 属性 , 或者调用 gitSha 方法获取 TINKER_ID 参数 ;


def getTinkerIdValue() {
    return hasProperty("TINKER_ID") ? TINKER_ID : gitSha()
}
def gitSha() {
    try {
        String gitRev = 'git rev-parse --short HEAD'.execute(null, project.rootDir).text.trim()
        if (gitRev == null) {
            throw new GradleException("can't get git rev, you should add git to system path or just input test value, such as 'testTinkerId'")
        }
        return gitRev
    } catch (Exception e) {
        throw new GradleException("can't get git rev, you should add git to system path or just input test value, such as 'testTinkerId'")
    }
}


因此这里有两种方式设置 TINKER_ID ,


在 gradle.properties 配置中 , 设置 TINKER_ID 参数 ;

gitSha 方法返回非空字符串 ;





三、解决方案




1、解决方案 1


在 gradle.properties 配置中 , 设置 TINKER_ID 参数 ,


TINKER_ID=1.0
TINKER_ENABLE=true




2、解决方案 2


修改 https://github.com/Tencent/tinker/blob/dev/tinker-sample-android/app/build.gradle 构建脚本代码 , 使 gitSha 方法返回非空字符串 ;


def gitSha() {
    try {
        String gitRev = "1.0"
        if (gitRev == null) {
            throw new GradleException("can't get git rev, you should add git to system path or just input test value, such as 'testTinkerId'")
        }
        return gitRev
    } catch (Exception e) {
        throw new GradleException("can't get git rev, you should add git to system path or just input test value, such as 'testTinkerId'")
    }
}


目录
相关文章
|
2月前
|
存储 Android开发 数据安全/隐私保护
Thanox安卓系统增加工具下载,管理、阻止、限制后台每个APP运行情况
Thanox是一款Android系统管理工具,专注于权限、后台启动及运行管理。支持应用冻结、系统优化、UI自定义和模块管理,基于Xposed框架开发,安全可靠且开源免费,兼容Android 6.0及以上版本。
144 4
|
11月前
|
Java 数据库连接
nacos2.0.3报错No Datasource Set
nacos2.0.3报错No Datasource Set com.mysql.cj.exceptions.CJException: Public Key Retrieval is not allowed
nacos2.0.3报错No Datasource Set
|
4月前
|
测试技术 Linux 网络安全
【App Services】App Service报错远程证书无效 - "The remote certificate is invalid according to the validation procedure"
在开发环境中,新部署的应用(App Service)无法与 Salesforce 的远程端点建立 SSL/TLS 连接,报错显示证书无效。经分析,防火墙启用了 SSL Inspection,插入了私有 CA 签发的中间证书,导致 App Service 无法验证。解决方案包括禁用 SSL Inspection、设置 `WEBSITE_LOAD_ROOT_CERTIFICATES` 环境变量或临时禁用代码中的 SSL 验证(仅限测试环境)。
150 8
|
11月前
|
JSON 小程序 JavaScript
uni-app开发微信小程序的报错[渲染层错误]排查及解决
uni-app开发微信小程序的报错[渲染层错误]排查及解决
2411 7
|
7月前
|
机器学习/深度学习 存储 人工智能
MNN-LLM App:在手机上离线运行大模型,阿里巴巴开源基于 MNN-LLM 框架开发的手机 AI 助手应用
MNN-LLM App 是阿里巴巴基于 MNN-LLM 框架开发的 Android 应用,支持多模态交互、多种主流模型选择、离线运行及性能优化。
4836 22
MNN-LLM App:在手机上离线运行大模型,阿里巴巴开源基于 MNN-LLM 框架开发的手机 AI 助手应用
|
7月前
|
JavaScript API
【Azure Function】Function App门户上的Test/Run返回错误:Failed to fetch
Running your function in portal requires the app to explicitly accept requests from https://portal.azure.cn. This is known as cross-origin resource sharing (CORS).Configure CORS to add https://portal.azure.cn to allowed origins.
151 7
|
7月前
|
应用服务中间件 Go Android开发
通过外部链接启动 Flutter App(详细介绍及示例)
本文介绍了通过外部链接启动 Flutter App 的两种方式:`firebase_dynamic_links` 和 `app_links`。前者由 Firebase 提供,支持生成分享链接并自动处理未安装应用时的跳转(如跳转到应用商店),但已于2025年8月停止服务;后者则需开发者自行处理未安装应用时的重定向逻辑。文中详细说明了两者的配置步骤、代码实现及注意事项,推荐使用 `app_links` 进行新项目开发。
253 2
|
9月前
|
网络协议 容器
【Container App】部署Contianer App 遇见 Failed to deploy new revision: The Ingress's TargetPort or ExposedPort must be specified for TCP apps.
Failed to deploy new revision: The Ingress's TargetPort or ExposedPort must be specified for TCP apps.
133 27
|
9月前
|
Java Maven Spring
【SpringBug】lombok插件失效,但是没有报错信息,@Data不能生成get和set方法
解决写了@Data注解,但是在测试文件中生成的反编译target文件Us二Info中没有get和set方法
765 16
|
10月前
|
JSON Java 关系型数据库
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
在Java中,使用mybatis-plus更新实体类对象到mysql,其中一个字段对应数据库中json数据类型,更新时报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
1049 4
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.