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

问题描述 投票:1回答:1

我正在将项目迁移到最新的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类。知道这里发生了什么吗?

谢谢。

android gradle migration
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.