Home > Enterprise >  RuntimeException: Stub! calling Android library methods
RuntimeException: Stub! calling Android library methods

Time:12-29

I can access the static fields of this class but the static methods complain. Dependency missing? I don't understand why it should be difficult to just pick up and code.

fun main(){
    println(android.icu.lang.UScript.getName(2))
}

Exception in thread "main" java.lang.RuntimeException: Stub!

https://developer.android.com/reference/android/icu/lang/UScript

Android Studio seems to me to have the SDK sources installed per the top hit here.

The decompiled .class file the stack trace links to looks like:

    public static String getName(int scriptCode) {
        throw new RuntimeException("Stub!");
    }

CodePudding user response:

You need an actual Android runtime such as emulator or device to run Android code. fun main() suggest you're trying to call Android code from a regular JVM program.

The android.jar supplied with the SDK is something you can build but not run your code with. It has the classes and method signatures etc. needed for building. All the implementations are just like that throw new RuntimeException("Stub!"). The real implementations are there in the runtime platform.

  • Related