java.lang.nosuchmethoderror in Androidx在混淆的应用中

发布于 2025-02-13 07:56:20 字数 1799 浏览 0 评论 0原文

我有一个非常奇怪的错误,我需要专家的目光来挖掘这个问题。

在Play Store中发布我的应用程序时,我在第一次安装应用程序后才在几个设备上发生了一些崩溃的崩溃,这些崩溃似乎仅在几个设备上发生。

Fatal Exception: java.lang.NoSuchMethodError: No static method f(Landroid/content/Context;)Landroidx/core/app/n; in class Landroidx/core/app/n; or its super classes (declaration of 'androidx.core.app.n' appears in base.apk)
   at com.example.app.core.di.AppModule$Companion.provideNotificationManager(AppModule.kt:88)
   ...

fn的使用表明,应用程序与R8和Proguard规则相混淆。

崩溃发生的源代码看起来像这样:

@Provides
    fun provideNotificationManager(context: Context): NotificationManagerCompat =
        NotificationManagerCompat.from(context)

notificationmanagercompat.from(context)来自androidx.core.core.app.notification managercompat。该课程在构建时间期间被混淆。

我们使用1.8.0 androidx.core:core-ktx依赖项的版本。

此版本的发行说明> NotificationCompat 。

proguard-rules.pro中没有添加有关Androidx的内容。

这些行添加在 build.gradle 中,

release {
        shrinkResources true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  • 为什么我们可以得到nosuchmethoderror例外,而当我对APK进行反复编译时可以找到此方法?
  • 为什么我们可以得到nosuchmethoderror例外,而错误消息则说“'androidx.core.app.n'的声明出现在base.apk中”
  • 为什么此错误并不发生在所有设备上(它们是其中许多设备)?
  • 为什么只有在应用程序的首次安装后才发生此错误(基于我们获得的日志)?
  • 这与涉及静态方法的事实有关吗?
  • 我们是否需要在Proguard文件中添加一个规则以保留所有类Androidx

谢谢,

I've got a really weird error and I need an expert's eye to dig more into this issue.

In releasing my application in play store, I got some crashes in Crashlytics that seems to happen only on a few devices, right after a first installation of the application.

Fatal Exception: java.lang.NoSuchMethodError: No static method f(Landroid/content/Context;)Landroidx/core/app/n; in class Landroidx/core/app/n; or its super classes (declaration of 'androidx.core.app.n' appears in base.apk)
   at com.example.app.core.di.AppModule$Companion.provideNotificationManager(AppModule.kt:88)
   ...

The use of f and n shows that app is obfuscated with r8 and a proguard rule.

The source code where the crash is happening looks like this:

@Provides
    fun provideNotificationManager(context: Context): NotificationManagerCompat =
        NotificationManagerCompat.from(context)

NotificationManagerCompat.from(context) comes from androidx.core.app.NotificationManagerCompat. This class is obfuscated during build time.

We are using version 1.8.0 of androidx.core:core-ktx dependency.

Release note of this version does mention changes made on NotificationCompat.

Nothing about androidx has been added in proguard-rules.pro.

These lines are added in build.gradle

release {
        shrinkResources true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  • Why can we got a NoSuchMethodError exception whereas this method can be found when I decompile the apk?
  • Why can we got a NoSuchMethodError exception whereas error message says that "declaration of 'androidx.core.app.n' appears in base.apk"?
  • Why this error does not occurs on all devices (and they are many of them)?
  • Why this error is happening only after a first installation of the application (based on logs we got)?
  • Is this related to the fact that it concerns a static method ?
  • Do we need to add a rule in proguard file to keep all classes of androidx?

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文