You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter 3集成jitsi_meet_v1添加ProGuard规则后构建报错求助

解决Flutter集成jitsi_meet_v1时ProGuard构建错误及闪退问题

问题场景

  • Flutter 3 + Android环境,集成jitsi_meet_v1: ^5.0.0包
  • 在app/build.gradle中添加ProGuard规则后触发构建错误;移除规则后项目可正常运行,但点击加入房间时会闪退

构建错误信息

+1 ms] FAILURE: Build failed with an exception.
[   +1 ms] * Where:
[        ] Build file '/home/amu/Desktop/projects/apps/jitsi/android/app/build.gradle' line: 28
[        ] * What went wrong:
[        ] A problem occurred evaluating project ':app'.
[        ] > No signature of method: build_9le4dq801rzqeyi0flt458p09.android() is applicable for argument types: (build_9le4dq801rzqeyi0flt458p09$_run_closure2) values:
[build_9le4dq801rzqeyi0flt458p09$_run_closure2@f3f8288]
[        ] * Try:
[        ] > Run with --debug option to get more log output.
[        ] > Run with --scan to get full insights.
[        ] * Exception is:
[        ] org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
[        ]      at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)

当前配置详情

app/build.gradle(关键片段)

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.debug
        
        minifyEnabled true
        useProguard true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

proguard-rules.pro

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }

解决方案

1. 修正build.gradle中的ProGuard配置

构建错误的核心原因是useProguard true在新版Gradle中已被废弃,替换为以下配置:

buildTypes {
    release {
        signingConfig signingConfigs.debug
        minifyEnabled true
        shrinkResources true // 可选,用于优化资源
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
  • 移除useProguard true
  • 改用proguard-android-optimize.txt以获得更高效的混淆优化

2. 补充Jitsi相关ProGuard规则

闪退是因为Jitsi的核心类被混淆,需要在proguard-rules.pro中添加以下规则:

# Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }

# Jitsi Meet 核心类保留
-keep class org.jitsi.meet.** { *; }
-keep class org.jitsi.** { *; }
-keep class org.webrtc.** { *; }
-keep class com.facebook.react.** { *; }
-keep class com.google.firebase.** { *; }
-keep class com.google.android.gms.** { *; }

# 保留Parcelable类的CREATOR字段
-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}
-keepattributes Signature, InnerClasses, EnclosingMethod

3. 重新构建项目

执行以下命令清理并构建:

flutter clean
flutter build apk --release

构建完成后运行APK,验证加入房间功能是否正常。

内容的提问来源于stack exchange,提问作者Zia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 22:08:07