firebase / firebase/firebase-android-sdk

[Crashlytics] cyclic dependency between gradle tasks becuase of injectCrashlyticsBuildIdsRelease depends on CMakeBuild

オープン
#6,167 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
api: crashlytics type: feature request
主要言語
Java
スター
2.6k
フォーク
710
平均マージ
3日 1時間
マージ済み PR(30日)
34

説明

I couldn't add comment to the already closed issue https://github.com/firebase/firebase-android-sdk/issues/5354 thus opened new one.

Original description

Environment
Android Studio version: Iguana 2023.2.1
Firebase Component: Crashlytics Gradle Plugin
Component version: 2.9.9 (But started in 2.9.5)
The problem
Cyclic dependency between gradle tasks after trying to upgrade Crashlytics Gradle Plugin to 2.9.9.
In our setup we first build java/kotlin code, obfuscate it using R8, then use the R8 outputs to obfuscate JNI headers. This makes the buildCMake task depend on building java/kotlin code and R8.

After updating to 2.9.9 the injectCrashlyticsBuildIdsRelease task kicks in which seems to be necessary to mergeReleaseResources but at the same time depends on outputs from the native build which is the opposite order we have in our code. This causes cyclic dependency between gradle tasks. See output from the console:
```
:app:buildCMakeRelWithDebInfo[armeabi-v7a]
\--- :app:configureCMakeRelWithDebInfo[armeabi-v7a]
\--- :libom_generated:generateReleaseJniObfuscation
+--- :libom_generated:generateReleaseJniHeaders
| \--- :app:compileReleaseJavaWithJavac
| +--- :app:compileReleaseKotlin
| | +--- :app:dataBindingGenBaseClassesRelease
| | | +--- :app:mergeReleaseResources
| | | | \--- :app:injectCrashlyticsBuildIdsRelease
| | | | \--- :app:stripReleaseDebugSymbols
| | | | \--- :app:mergeReleaseNativeLibs
| | | | \--- :app:buildCMakeRelWithDebInfo[armeabi-v7a] (*)
| | | \--- :app:parseReleaseLocalResources
| | | \--- :app:packageReleaseResources
| | | \--- :app:injectCrashlyticsBuildIdsRelease (*)
| | +--- :app:kaptReleaseKotlin
| | | \--- :app:kaptGenerateStubsReleaseKotlin
| | | +--- :app:dataBindingGenBaseClassesRelease (*)
| | | +--- :app:kspReleaseKotlin
| | | | +--- :app:generateReleaseSources
| | | | | \--- :app:injectCrashlyticsBuildIdsRelease (*)
| | | | \--- :app:processReleaseResources
| | | | +--- :app:mapReleaseSourceSetPaths
| | | | | \--- :app:injectCrashlyticsBuildIdsRelease (*)
| | | | +--- :app:mergeReleaseResources (*)
| | | | \--- :app:parseReleaseLocalResources (*)
| | | \--- :app:processReleaseResources (*)
| | +--- :app:kspReleaseKotlin (*)
| | \--- :app:processReleaseResources (*)
| +--- :app:dataBindingGenBaseClassesRelease (*)
| +--- :app:generateReleaseSources (*)
| +--- :app:kaptReleaseKotlin (*)
| +--- :app:kspReleaseKotlin (*)
| \--- :app:processReleaseResources (*)
\--- :libom_generated:generateReleaseProguardMapping
\--- :app:compileReleaseJavaWithJavac (*)
```

In the mentioned issue https://github.com/firebase/firebase-android-sdk/issues/5354 there was a suggestion to generate the R8 mapping upfront and provide that mapping to R8 using the `-applymapping` rule.
We started investigating this option. We used KSP to generate the preliminary mapping file. However we faced an issue where JNI headers are generated by the java compiler (`javac -h`). This still establish the task order where native code can only be compiled after `javac/kotlinc`.

We are currently investigating if we could utilize the KSP to generate the JNI headers as well. However I think you should really consider the idea of keeping the build ids in assets rather than as resources.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、報告された Android Studio と Crashlytics plugin のバージョンを使用して、injectCrashlyticsBuildIdsRelease、mergeReleaseResources、stripReleaseDebugSymbols、buildCMakeRelWithDebInfo が関与するタスクグラフを再現します。Crashlytics Gradle Plugin のリソースおよびネイティブビルドの依存関係を追跡します。完了条件は、release タスクグラフにサイクルがなく、build IDs とネイティブ出力が引き続き正しく完了することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
android, java, kotlin
領域
build-system, mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。