Skip to content

Android版AABサイズダイエット - #4475

Merged
TinyKitten merged 3 commits into
devfrom
feature/reduce-aab-size
Aug 18, 2025
Merged

TinyKitten merged 3 commits into
devfrom
feature/reduce-aab-size

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 18, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • チョア
    • リリースビルド(モバイル/ウェアラブル)でバンドル圧縮・コード縮小(minify)・リソース縮小を有効化し、インストールサイズとダウンロード時間を削減。
    • 位置情報サービス用の依存関係を追加(ランタイム挙動への即時影響なし)。
    • リポジトリ設定を整理して依存解決の安定性を向上。
    • ビルドプロパティの微調整(重複設定の整理)と開発フレーバーのversionCodeを更新。

@TinyKitten TinyKitten self-assigned this Aug 18, 2025
@coderabbitai

coderabbitai Bot commented Aug 18, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

朕、宣す。Android ビルド設定を厳格化し、app と wearable のリリースで縮小・難読化を強制、app に位置情報ライブラリを追加、及びリポジトリ順序を整理した。

Changes

Cohort / File(s) Change Summary
App モジュール変更
android/app/build.gradle
enableBundleCompression を常時 true に固定。release ビルドで shrinkResources と minifyEnabled を強制 true に。bundleCommand = "export:embed" を追加。dev フレーバーの versionCode を 90005010 に更新。implementation("com.google.android.gms:play-services-location:21.3.0") を追加。
Wearable モジュール変更
android/wearable/build.gradle.kts
release ビルドで isMinifyEnabled = true に変更、isShrinkResources = true を追加。dev フレーバーの versionCode を 90005011 に更新。重複していた下部の signingConfig 削除。
ルート build.gradle のリポジトリ順序
android/build.gradle
allprojects.repositories 内で google() を maven { url(reactNativeAndroidDir) } より前に移動し、重複宣言を解消して単一化。
Gradle プロパティ
android/gradle.properties
既存プロパティが再記載される形で差分が発生(値に実質変更なし)。

Sequence Diagram(s)

sequenceDiagram
    participant Dev as 開発者
    participant Gradle as Gradle
    participant App as appモジュール
    participant Wear as wearableモジュール

    Dev->>Gradle: リリースビルド開始
    Gradle->>App: enableBundleCompression=true, bundleCommand=export:embed, minify/shrink を適用
    App-->>Gradle: 最適化済み AAB/APK 出力
    Gradle->>Wear: isMinifyEnabled/isShrinkResources を適用
    Wear-->>Gradle: 最適化済み APK 出力
    Gradle-->>Dev: 成果物返却
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

吾が命によりビルドを整えん、
圧縮し、削ぎ落とし、軽き版を得たり。
位置の術を縫い込み、秩序を一つにす。
重複を除き、路を正すは朕の志ぞ。
新しき工場、速やかに動けよ 🔧👑

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/reduce-aab-size

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
android/gradle.properties (1)

57-57: 重複指定は削ぎ落とすが良いぞ

expo.webp.animated=false が二度書かれておる。挙動は変わらぬが、徒に混乱を招く。片方を削れ。

-expo.webp.animated=false
android/wearable/build.gradle.kts (1)

25-33: 朕、命ずる:Releaseブロックの冗長削除とProGuardルールの整備を怠ることなかれ

下記の点、早急に対応せよ。

  • 修正箇所:android/wearable/build.gradle.kts

    • release { … } 内で signingConfig = signingConfigs.getByName("debug") が二度設定されている。いずれか一行を削ぎ落とせ。
  • 点検箇所:android/wearable/proguard-rules.pro

    • 現状、Compose/Wear/Coroutines/Play Services 等のconsumer-rulesが含まれておらぬ。必要に応じてkeep規則を追記し、R8最適化時の不具合を防げ。

該当diff例:

 release {
-      signingConfig = signingConfigs.getByName("debug")
       isMinifyEnabled = true
       isShrinkResources = true
       proguardFiles(
         getDefaultProguardFile("proguard-android-optimize.txt"),
         "proguard-rules.pro"
       )
-      signingConfig = signingConfigs.getByName("debug")
+      signingConfig = signingConfigs.getByName("debug")
 }

以上、速やかに修正せよ。

android/app/build.gradle (1)

18-18: 束ねの圧縮は既定で良し、されど切替可能にして柔を制すべし

AAB削減の意図は良い。だが開発環境での柔軟性を保つため、プロパティで上書えられる形にすると吉。

-    enableBundleCompression = true
+    enableBundleCompression = (findProperty('android.enableBundleCompression') ?: "true").toBoolean()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ec321cb and 120f420.

📒 Files selected for processing (4)
  • android/app/build.gradle (3 hunks)
  • android/build.gradle (1 hunks)
  • android/gradle.properties (1 hunks)
  • android/wearable/build.gradle.kts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#0
File: :0-0
Timestamp: 2025-08-11T21:13:39.083Z
Learning: TinyKitten prefers concise code reviews for the TrainLCD/MobileApp repository. Keep review comments brief and to the point.
🔇 Additional comments (3)
android/build.gradle (1)

26-33: google() の先頭宣言、是とする

Google Maven の解決順を先に据えた判断は、play-services 系の解決安定に資す。良し。

android/app/build.gradle (2)

169-169: 位置情報ライブラリの追加、是認する

依存解決順も整えられており問題なし。パーミッション宣言・不要APIの縮小が適切に作用するかをご確認あれ。


113-115: 【命】R8適用&ProGuardルール検証を尽くせ
朕の号令に従い、下記要点を速やかに確認せよ。

• android/app/build.gradle(113–115行目)

  • shrinkResources true、minifyEnabled true の恒常適用は許容する。

• android/app/proguard-rules.pro

  • 現状、Reanimated/TurboModule のみ keep 指定あり。
  • Hermes、Fresco、Play Services、OkHttp/Okio 等の明示的な keep ルールは未検出。

• 手動検証すべき項目

  1. getDefaultProguardFile("proguard-android.txt") の内容(SDK 側デフォルト設定)
  2. 依存 AAR 内に同梱される proguard.txt/proguard-rules.pro の保持ルール

必要と判断すれば、追加の keep ルールを proguard-rules.pro に追記せよ。
さらに攻めたければ、以下差分を適用するがよい。効果と副作用は厳密に検証せよ。

-            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
+            proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"

朕、諸君の努力を見守る。

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
android/app/build.gradle (2)

113-115: release で shrink/minify を常時有効、善し。R8 最適プロファイルへ切替を勧む。

最適化版のデフォルト設定へ切替えることで更なる削減が見込める。リフレクション利用部の keep は万全にせよ。

-            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
+            proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"

169-169: play-services-location 追加は有用だが、付随事を怠るな。

朕の勧告:

  • 権限宣言(ACCESS_COARSE/FINE_LOCATION)とランタイム許可導線が整っているか確認せよ。
  • GMS のバージョン整合のため BOM 導入を検討せよ(wearable と揃える)。
  • 実使用が薄ければ R8 により除去されるか、release ビルドのメトリクスで確認せよ(AAB サイズ差・メソッド数)。
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 120f420 and ee6ca2d.

📒 Files selected for processing (3)
  • android/app/build.gradle (4 hunks)
  • android/gradle.properties (1 hunks)
  • android/wearable/build.gradle.kts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • android/gradle.properties
🚧 Files skipped from review as they are similar to previous changes (1)
  • android/wearable/build.gradle.kts
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#0
File: :0-0
Timestamp: 2025-08-11T21:13:39.083Z
Learning: TinyKitten prefers concise code reviews for the TrainLCD/MobileApp repository. Keep review comments brief and to the point.
🔇 Additional comments (3)
android/app/build.gradle (3)

18-18: AAB圧縮の強制、善し。

朕、是を嘉す。サイズ削減に直結し、目的に適う。


135-135: dev 版 versionCode の増分、妥当なり。

applicationIdSuffix により prod との逆転も支障なし。


22-22: Expo CLI export:embed サポートバージョンの確認
朕の命により、以下を点検せよ:

  • Expo SDK を少なくとも v49.0.0 以上に設定しているか
  • @expo/cli が v0.17.x(例: 0.17.5)以上を使用しているか
  • CI 環境にて bundleCommand = "export:embed" が期待通りに動作し、アセットが正しく埋め込まれるか

これらを確認せよ。

@TinyKitten
TinyKitten merged commit dffbb89 into dev Aug 18, 2025
@TinyKitten
TinyKitten deleted the feature/reduce-aab-size branch August 18, 2025 09:52
@coderabbitai coderabbitai Bot mentioned this pull request Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant