我是新开发的Android应用程序,我正在尝试运行应用程序但是我收到此错误
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at app.unityudx.io.new_app.process.UnityApplication.onCreate(UnityApplication.java:59)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org.slf4j.helpers.SubstituteLoggerFactory
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:86)
at app.unityudx.io.new_app.process.UnityApplication.onCreate(UnityApplication.java:59)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
我研究过,互联网上的人说这个类不在Classpath中,但是当我在graddle中添加implementation 'org.slf4j:slf4j-android:1.7.25'
这个错误时
Program type already present: org.slf4j.impl.StaticMDCBinder
Android Studio是3.1.2
似乎其他lib包含lib。你需要找出哪一个并添加:排除。
在我的情况下它是:
implementation (group: 'io.jafka', name: 'jeos', version: '0.9.14') {
exclude module: 'slf4j-log4j12'
}