Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
327 views
in Technique[技术] by (71.8m points)

gradle - Lsp4j JSON RPC library throwing NoClassDefFoundError exception on Android 21

I'm using the eclipse lsp4j library to connect to a remote language server. My app needs to support API Level 21 systems, and this exception is not thrown on newer android versions. (I tested on API level 30). I'm kind of at a loss on how to possibly fix it.

This is the code I have to connect to the language server:

val launcher = LSPLauncher.createClientLauncher(this, inputStream, outputStream)

And these are the logs I'm getting from the debugger:

I/art: Rejecting re-init on previously-failed class java.lang.Class<org.eclipse.lsp4j.jsonrpc.MessageTracer>
    Rejecting re-init on previously-failed class java.lang.Class<org.eclipse.lsp4j.jsonrpc.MessageTracer>
    Rejecting re-init on previously-failed class java.lang.Class<org.eclipse.lsp4j.jsonrpc.MessageTracer>
    Rejecting re-init on previously-failed class java.lang.Class<org.eclipse.lsp4j.jsonrpc.MessageTracer>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.eclipse.lsp4j.jsonrpc.services.-$$Lambda$ServiceEndpoints$eKMG28mxVS2rcQINSfNNvWiJqVc>
    Rejecting re-init on previously-failed class java.lang.Class<org.eclipse.lsp4j.jsonrpc.services.-$$Lambda$ServiceEndpoints$eKMG28mxVS2rcQINSfNNvWiJqVc>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.eclipse.lsp4j.jsonrpc.services.-$$Lambda$ServiceEndpoints$eKMG28mxVS2rcQINSfNNvWiJqVc>
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.lsp_client, PID: 6699
    java.lang.NoClassDefFoundError: org.eclipse.lsp4j.jsonrpc.services.-$$Lambda$ServiceEndpoints$eKMG28mxVS2rcQINSfNNvWiJqVc
        at org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints.getSupportedMethods(ServiceEndpoints.java:90)
        at org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints.getSupportedMethods(ServiceEndpoints.java:82)
        at org.eclipse.lsp4j.jsonrpc.Launcher$Builder.getSupportedMethods(Launcher.java:404)
        at org.eclipse.lsp4j.jsonrpc.Launcher$Builder.createJsonHandler(Launcher.java:335)
        at org.eclipse.lsp4j.jsonrpc.Launcher$Builder.create(Launcher.java:319)
        at org.eclipse.lsp4j.launch.LSPLauncher.createClientLauncher(LSPLauncher.java:106)
        at com.example.lsp_client.server.LanguageServerSocket.startSession(LanguageServerSocket.kt:68)
...

I'm guessing there is some sort of compatibility issue with the lsp4j library, but I'm not sure where to begin in how to debug that. My Gradle config for context with relevant dependencies:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'org.jetbrains.kotlin.plugin.serialization'
}

android {
    compileSdkVersion 30

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion kotlin_version
    }
}

dependencies {
...
    implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.10.0'
    implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.10.0'
...
}
question from:https://stackoverflow.com/questions/65859469/lsp4j-json-rpc-library-throwing-noclassdeffounderror-exception-on-android-21

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...