NoClassDefFoundError is thrown when uniapp calls the native plug-in that contains a third-party SDK

NoClassDefFoundErrorProblem: uniapp throws an exception when calling native plugins that contain third-party SDKs

Because my native plug-in is a *.arr file packaged by myself, using the common-net plug-in, after executing Make Module, it is referenced in the uniapp project, and an exception is thrown when packaging the custom base: NoClassDefFoundError.

Solution

Modify module -> telnet -> build.gradle to compileOnly: implementationI
am referencing
the code before commons-net-3.8.0.jar:

dependencies {
    compileOnly fileTree(include: ['commons-net-3.8.0.jar'], dir: './libs') //引如的第3方插件,将compileOnly修改为implementation
}

After modification:

dependencies {
    implementation fileTree(include: ['commons-net-3.8.0.jar'], dir: './libs')
}

As shown in the figure:
insert image description here
Then re-Make Module, and then import the project.

注意:My plug-in commons-net-3.8.0.jar is introduced in the local lib. In the uniapp project, nativeplugins —> telnet —> package.json dependenciesdoes not add a dependent library, and the personal test is effective.

Reference: NoClassDefFoundError is thrown when uniapp calls the native plug-in that contains a third-party SDK

Other solutions: refer to the Android plug-in development of uniapp, and introduce the NoClassDefFoundError problem of the third-party library

Guess you like

Origin blog.csdn.net/weixin_41767649/article/details/124378765