gpt4 book ai didi

android - 迁移到Gradle 4.5.1(android buildtool 3.0.1)并抛出ClassNotFoundException

转载 作者:行者123 更新时间:2023-12-03 04:23:24 30 4
gpt4 key购买 nike

我正在将项目迁移到最新的Gradle版本。构建成功,但是启动应用程序时出现ClassNotFoundException。
主要方法代码:

    public static void main(String[] args) {
Bridge app = new Bridge();
GatewayServer server = new GatewayServer(app);
System.out.println("Python Bridge Running. Ctrl+C to stop.");
server.start();
}

输出为:
Exception in thread "main" java.lang.NoClassDefFoundError: py4j/GatewayServer
at com.sdk.python.bridge.Bridge.main(Bridge.java:20)
Caused by: java.lang.ClassNotFoundException: py4j.GatewayServer
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more

这是Gradle的一些依赖树:
Project :python-bridge
------------------------------------------------------------

compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
\--- project :api
+--- project :core
| +--- org.jetbrains:annotations-java5:15.0
| +--- org.apache.commons:commons-lang3:3.4
| +--- com.fasterxml.jackson.core:jackson-databind:2.7.2
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.7.0 -> 2.7.1
| | \--- com.fasterxml.jackson.core:jackson-core:2.7.2
| +--- com.fasterxml.jackson.core:jackson-core:2.7.2
| \--- com.fasterxml.jackson.core:jackson-annotations:2.7.1
+--- net.iharder:base64:2.3.9
+--- com.squareup.retrofit2:retrofit:2.1.0
| \--- com.squareup.okhttp3:okhttp:3.3.0
| \--- com.squareup.okio:okio:1.8.0
+--- com.squareup.retrofit2:converter-jackson:2.1.0
| +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
| \--- com.fasterxml.jackson.core:jackson-databind:2.7.2 (*)
+--- com.squareup.retrofit2:adapter-rxjava:2.1.0
| +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
| \--- io.reactivex:rxjava:1.1.5
\--- org.apache.commons:commons-lang3:3.4

compileClasspath - Compile classpath for source set 'main'.
+--- project :api
| +--- project :core
| | \--- org.jetbrains:annotations-java5:15.0
| +--- net.iharder:base64:2.3.9
| +--- com.squareup.retrofit2:retrofit:2.1.0
| | \--- com.squareup.okhttp3:okhttp:3.3.0
| | \--- com.squareup.okio:okio:1.8.0
| +--- com.squareup.retrofit2:converter-jackson:2.1.0
| | +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
| | \--- com.fasterxml.jackson.core:jackson-databind:2.7.2
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.7.0
| | \--- com.fasterxml.jackson.core:jackson-core:2.7.2
| \--- com.squareup.retrofit2:adapter-rxjava:2.1.0
| +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
| \--- io.reactivex:rxjava:1.1.5
\--- net.sf.py4j:py4j:0.10.6

default - Configuration for default artifacts.
+--- project :api
| +--- project :core
| | +--- org.jetbrains:annotations-java5:15.0
| | +--- org.apache.commons:commons-lang3:3.4
| | +--- com.fasterxml.jackson.core:jackson-databind:2.7.2
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.7.0 -> 2.7.1
| | | \--- com.fasterxml.jackson.core:jackson-core:2.7.2
| | +--- com.fasterxml.jackson.core:jackson-core:2.7.2
| | \--- com.fasterxml.jackson.core:jackson-annotations:2.7.1
| +--- net.iharder:base64:2.3.9
| +--- com.squareup.retrofit2:retrofit:2.1.0
| | \--- com.squareup.okhttp3:okhttp:3.3.0
| | \--- com.squareup.okio:okio:1.8.0
| +--- com.squareup.retrofit2:converter-jackson:2.1.0
| | +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
| | \--- com.fasterxml.jackson.core:jackson-databind:2.7.2 (*)
| +--- com.squareup.retrofit2:adapter-rxjava:2.1.0
| | +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
| | \--- io.reactivex:rxjava:1.1.5
| \--- org.apache.commons:commons-lang3:3.4
\--- net.sf.py4j:py4j:0.10.6

implementation - Implementation only dependencies for source set 'main'. (n)
\--- net.sf.py4j:py4j:0.10.6 (n)

runtime - Runtime dependencies for source set 'main' (deprecated, use 'runtimeOnly ' instead).
\--- project :api
+--- project :core
| +--- org.jetbrains:annotations-java5:15.0
| +--- org.apache.commons:commons-lang3:3.4
| +--- com.fasterxml.jackson.core:jackson-databind:2.7.2
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.7.0 -> 2.7.1
| | \--- com.fasterxml.jackson.core:jackson-core:2.7.2
| +--- com.fasterxml.jackson.core:jackson-core:2.7.2
| \--- com.fasterxml.jackson.core:jackson-annotations:2.7.1
+--- net.iharder:base64:2.3.9
+--- com.squareup.retrofit2:retrofit:2.1.0
| \--- com.squareup.okhttp3:okhttp:3.3.0
| \--- com.squareup.okio:okio:1.8.0
+--- com.squareup.retrofit2:converter-jackson:2.1.0
| +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
| \--- com.fasterxml.jackson.core:jackson-databind:2.7.2 (*)
+--- com.squareup.retrofit2:adapter-rxjava:2.1.0
| +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
| \--- io.reactivex:rxjava:1.1.5
\--- org.apache.commons:commons-lang3:3.4

runtimeClasspath - Runtime classpath of source set 'main'.
+--- project :api
| +--- project :core
| | +--- org.jetbrains:annotations-java5:15.0
| | +--- org.apache.commons:commons-lang3:3.4
| | +--- com.fasterxml.jackson.core:jackson-databind:2.7.2
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.7.0 -> 2.7.1
| | | \--- com.fasterxml.jackson.core:jackson-core:2.7.2
| | +--- com.fasterxml.jackson.core:jackson-core:2.7.2
| | \--- com.fasterxml.jackson.core:jackson-annotations:2.7.1
| +--- net.iharder:base64:2.3.9
| +--- com.squareup.retrofit2:retrofit:2.1.0
| | \--- com.squareup.okhttp3:okhttp:3.3.0
| | \--- com.squareup.okio:okio:1.8.0
| +--- com.squareup.retrofit2:converter-jackson:2.1.0
| | +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
| | \--- com.fasterxml.jackson.core:jackson-databind:2.7.2 (*)
| +--- com.squareup.retrofit2:adapter-rxjava:2.1.0
| | +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
| | \--- io.reactivex:rxjava:1.1.5
| \--- org.apache.commons:commons-lang3:3.4
\--- net.sf.py4j:py4j:0.10.6

软件包net.sf.py4j:py4j:0.10.6应该包含GatewayServer类。
知道这里发生了什么吗?

谢谢。

最佳答案

问题出在本地.gradle文件中。将它们删除并重新导入后,它就像一个魅力。

关于android - 迁移到Gradle 4.5.1(android buildtool 3.0.1)并抛出ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48714615/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com