日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

發(fā)布時間:2025/6/17 61 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【错误记录】Tinker 热修复示例运行报错 ( Execution failed for task ‘:app:tinkerProcessD‘ . tinkerId is not set!!! ) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

  • 一、報錯信息
  • 二、問題分析
  • 三、解決方案
    • 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.orgBUILD FAILED in 8s 9 actionable tasks: 9 executed





二、問題分析



需要閱讀 Gradle 腳本 , 分析報錯原因 ;


仔細閱讀 build.gradle 構(gòu)建腳本 , 配置 TINKER_ID 的代碼如下 ,

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

通過 getTinkerIdValue 方法 , 獲取 TINKER_ID , 在 getTinkerIdValue 方法中會查詢是否有 TINKER_ID 屬性 , 或者調(diào)用 gitSha 方法獲取 TINKER_ID 參數(shù) ;

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 參數(shù) ;
  • gitSha 方法返回非空字符串 ;




三、解決方案





1、解決方案 1


在 gradle.properties 配置中 , 設置 TINKER_ID 參數(shù) ,

TINKER_ID=1.0 TINKER_ENABLE=true



2、解決方案 2


修改 https://github.com/Tencent/tinker/blob/dev/tinker-sample-android/app/build.gradle 構(gòu)建腳本代碼 , 使 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'")} }

總結(jié)

以上是生活随笔為你收集整理的【错误记录】Tinker 热修复示例运行报错 ( Execution failed for task ‘:app:tinkerProcessD‘ . tinkerId is not set!!! )的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。