【错误记录】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.orgBUILD FAILED in 8s 9 actionable tasks: 9 executed
二、問題分析
需要閱讀 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=true2、解決方案 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'")} }總結
以上是生活随笔為你收集整理的【错误记录】Tinker 热修复示例运行报错 ( Execution failed for task ‘:app:tinkerProcessD‘ . tinkerId is not set!!! )的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【错误记录】创建密钥报错 ( Key w
- 下一篇: 【错误记录】NDK 动态库报错 ( dl