You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crash in release build after updating to AGP 8.9.2 + Hilt 2.56.2: @HiltViewModel constructor stripped #4739
After updating both AGP to 8.9.2 and Hilt to 2.56.2, my app crashes in release builds due to a NoSuchMethodException when trying to create a @hiltviewmodel instance. The constructor appears to be stripped by R8.
Interestingly, this crash does not occur if I update only Hilt to 2.56.2, I found that this commit removed the keep rule:
-keepnames @dagger.hilt.android.lifecycle.HiltViewModel class * extends androidx.lifecycle.ViewModel
When I re-added this rule manually to my proguard-rules.pro, the crash was resolved.
Caused by: java.lang.NoSuchMethodException: <init> []
Caused by: java.lang.RuntimeException: Cannot create an instance of class x.x.x.MyViewModel
at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.create(SourceFile:18)
Steps to Reproduce:
Use Hilt 2.56.1 + AGP 8.9.2
Create a simple @hiltviewmodel class with an injected constructor
changed the title [-]Crash in release build after updating to AGP 8.9.2 + Hilt 2.56.1: @HiltViewModel constructor stripped[/-][+]Crash in release build after updating to AGP 8.9.2 + Hilt 2.56.2: @HiltViewModel constructor stripped[/+]on May 27, 2025
Interestingly, this crash does not occur if I update only Hilt to 2.56.2
Just to clarify, are you saying that you can make this crash occur just by upgrading AGP to 8.9.2? Or is it only the combination of upgrading Hilt and AGP that causes the crash? Also, what is the previous version of AGP you are using?
Activity
[-]Crash in release build after updating to AGP 8.9.2 + Hilt 2.56.1: @HiltViewModel constructor stripped[/-][+]Crash in release build after updating to AGP 8.9.2 + Hilt 2.56.2: @HiltViewModel constructor stripped[/+]Chang-Eric commentedon Jun 10, 2025
Just to clarify, are you saying that you can make this crash occur just by upgrading AGP to 8.9.2? Or is it only the combination of upgrading Hilt and AGP that causes the crash? Also, what is the previous version of AGP you are using?
530l commentedon Jan 2, 2026
Use Hilt 2.57.1 +KSP + AGP 8.9.1 也会出现,增加了-keepnames @dagger.hilt.android.lifecycle.HiltViewModel class * extends androidx.lifecycle.ViewModel 混淆规则就不崩溃了