Skip to content

Crash on Crashlytics: "NoSuchMethodError: No static method log" #212

Description

@AndroidDeveloperLB

Hello,

I don't know the steps, but I got various crashes of multiple devices on Crashlytics, here , here and here.

Stack trace:

Fatal Exception: java.lang.NoSuchMethodError: No static method log(Ljava/lang/String;Ljava/lang/Object;)V in class Lcc6; or its super classes (declaration of 'cc6' appears in /data/app/~~7sutuCX_rbqgZb45xYktNw==/com.lb.app_manager-sBLswmDsVIOI7hGlp5u1kg==/base.apk!classes4.dex)
       at com.topjohnwu.superuser.internal.CommandSource.serve(ShellInputSource.java:66)
       at com.topjohnwu.superuser.internal.JobTask.run(JobTask.java:95)
       at com.topjohnwu.superuser.internal.ShellImpl.exec0(ShellImpl.java:258)
       at com.topjohnwu.superuser.internal.ShellImpl.execTask(ShellImpl.java:325)
       at com.topjohnwu.superuser.internal.PendingJob.exec0(PendingJob.java:59)
       at com.topjohnwu.superuser.internal.PendingJob.exec(PendingJob.java:70)
...

Sadly the part that points to my code doesn't seem right, as the line number is too large compared to what I see.

This is what I have in gradle:

    implementation("com.github.topjohnwu.libsu:core:6.0.0")

I can't reproduce it.

crash.zip

I think these are the relevant functions:

import androidx.annotation.WorkerThread
import com.topjohnwu.superuser.Shell


object Root {
    fun hasRoot() = Shell.getCachedShell()?.isRoot == true

    @Suppress("SameReturnValue")
    @WorkerThread
    fun getRoot(): Boolean {
        runCatching {
            Shell.getShell().let {
                if (!it.isRoot) {
                    it.close()
                    return false
                }
                return true
            }
        }
        return false
    }
}

I think it might be because of agressive R8, or this proguard rule that I added for security/privacy/performance:

-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
    public static *** i(...);
}

Workaround in proguard rules:

# Prevent R8 from stripping or messing with libsu internals, because of a crash on Log.i: https://github.com/topjohnwu/libsu/issues/212
-keep class com.topjohnwu.superuser.** { *; }
-dontwarn com.topjohnwu.superuser.**

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions