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

生成签名APK时触发ProGuardTransform.transform运行时异常求助

Troubleshooting ProGuardTransform RuntimeException When Building Signed APK

Hey there, let's break down the java.lang.RuntimeException you're hitting in the ProGuardTransform.transform method while generating your signed APK. This error usually stems from ProGuard version conflicts, missing/misconfigured rules, or incompatible dependencies. Let's go through actionable fixes based on your Gradle setup:

1. Fix ProGuard Version Compatibility

You're forcing a specific ProGuard version (net.sf.proguard:proguard-gradle:5.3.3) in your buildscript, but the Android Gradle Plugin (AGP) already ships with a compatible ProGuard version tailored to its release. Forcing an external version often causes mismatches.

Fix: Remove this forced resolution block entirely:

// Delete this section from buildscript > configurations.all
resolutionStrategy {
    force 'net.sf.proguard:proguard-gradle:5.3.3'
}

Let AGP manage the ProGuard version automatically—it'll pick the one that works best with your compileSdk and AGP version.

2. Resolve RxJava Version Conflict

Your dependencies include both RxJava 1 (io.reactivex:rxjava:1.2.0) and RxJava 2 (io.reactivex.rxjava2:rxjava:2.1.12). Having both versions coexisting can confuse ProGuard during the shrinking/obfuscation process.

Fix: Pick one RxJava version and remove the other. Since you're using RxAndroid 2 (io.reactivex.rxjava2:rxandroid:2.0.2), stick with RxJava 2:

// Remove this line from dependencies
// compile 'io.reactivex:rxjava:1.2.0'

3. Update Kotlin & Data Binding Compiler Compatibility

Your Kotlin version (1.2.10) is outdated and may not play nicely with the data binding compiler version (3.2.0-alpha10) you're using. Mismatched versions here can break the build pipeline before ProGuard even runs.

Fix: Upgrade your Kotlin version to a release compatible with AGP 3.2.x (your data binding compiler version hints at this AGP version). For example:

// In buildscript > ext
kotlinVersion = '1.3.72'

Ensure your project-level build.gradle uses an AGP version that matches the data binding compiler (e.g., com.android.tools.build:gradle:3.2.0-alpha10).

4. Validate ProGuard Rules

With minifyEnabled true and shrinkResources true, missing keep rules for third-party libraries can cause ProGuard to strip critical classes. Add these rules to your proguard-rules.pro file for the libraries you're using:

GreenDao

-keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
    public static java.lang.String TABLENAME;
}
-keep class **$Properties
-dontwarn org.greenrobot.greendao.database.**

Retrofit & RxJava 2

-keep class retrofit2.** { *; }
-keepattributes Signature, Exceptions
-keep class io.reactivex.** { *; }
-keep interface io.reactivex.** { *; }
-keepattributes *Annotation*
-dontwarn io.reactivex.**

Calligraphy

-keep class uk.co.chrisjenx.calligraphy.* { *; }
-keep interface uk.co.chrisjenx.calligraphy.* { *; }

PDF Viewer & Picasso

-keep class com.github.barteksc.pdfviewer.** { *; }
-dontwarn com.github.barteksc.pdfviewer.**
-keep class com.squareup.picasso.** { *; }
-dontwarn com.squareup.picasso.**

5. Get the Full Error Log

The stack trace you provided cuts off before showing ProGuard's actual failure reason (e.g., missing class, duplicate class, invalid rule). Run the assemble command with stack tracing enabled to see the full picture:

./gradlew assembleRelease --stacktrace

This will show exactly what's breaking ProGuard, making it easier to target fixes.

6. Test Incrementally

To isolate the issue:

  • Temporarily set shrinkResources false in your release build type to rule out resource shrinking as the cause.
  • Disable minifyEnabled temporarily—if the build succeeds, the problem is definitely in your ProGuard configuration.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 06:51:12