Android Studio class 在具有 hyperledger fabric 的路径 DexPathList 上找不到
Android Studio class not found on path DexPathList with hyperledger fabric
在Commercial paper tutorial上有一个在java上的应用程序,它运行良好。现在,我尝试用 Android Studio 作为教程来实现。
我修改了一些行以在模拟器上启动,并尽可能按照 pom.xml 获取依赖项。但是当我使用Issue.java或AddToWallet.java时,org.hyperledger.fabric出现错误 class (Issue app 最后报错) :
问题调用Gateway.Builder builder = Gateway.createBuilder();
通过GatewayImpl.java和DefaultCommitHandlers.java :70
在 class DefaultCommitHandlers 上有 Peer,其中错误开始:
import org.hyperledger.fabric.sdk.Peer
;
private static final EnumSet<Peer.PeerRole> EVENT_SOURCE_ROLES = EnumSet.of(Peer.PeerRole.EVENT_SOURCE);
这是什么意思?我该如何纠正?
完全错误:
Process: iti.pap.ch.pap_test, PID: 9364
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/hyperledger/fabric/sdk/Peer$PeerRole;
at org.hyperledger.fabric.gateway.DefaultCommitHandlers.<clinit>(DefaultCommitHandlers.java:70)
at org.hyperledger.fabric.gateway.impl.GatewayImpl$Builder.<init>(GatewayImpl.java:67)
at org.hyperledger.fabric.gateway.Gateway.createBuilder(Gateway.java:87)
at iti.pap.ch.pap_test.Issue.main(Issue.java:41)
at iti.pap.ch.pap_test.MainActivity.onClick(MainActivity.java:29)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access00(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.hyperledger.fabric.sdk.Peer$PeerRole" on path: DexPathList[[zip file "/data/app/iti.pap.ch.pap_test-CLJRfC7j75Bhy3VebuP5kg==/base.apk"],nativeLibraryDirectories=[/data/app/iti.pap.ch.pap_test-CLJRfC7j75Bhy3VebuP5kg==/lib/x86, /system/lib]]```
这个依赖应该提供它:
implementation "org.hyperledger.fabric:fabric-gateway-java:2.1.0"
如果 class 在运行时未知,请禁用混淆 - 或为其编写适当的配置。
在Commercial paper tutorial上有一个在java上的应用程序,它运行良好。现在,我尝试用 Android Studio 作为教程来实现。
我修改了一些行以在模拟器上启动,并尽可能按照 pom.xml 获取依赖项。但是当我使用Issue.java或AddToWallet.java时,org.hyperledger.fabric出现错误 class (Issue app 最后报错) :
问题调用Gateway.Builder builder = Gateway.createBuilder();
通过GatewayImpl.java和DefaultCommitHandlers.java :70
在 class DefaultCommitHandlers 上有 Peer,其中错误开始:
import org.hyperledger.fabric.sdk.Peer
;private static final EnumSet<Peer.PeerRole> EVENT_SOURCE_ROLES = EnumSet.of(Peer.PeerRole.EVENT_SOURCE);
这是什么意思?我该如何纠正?
完全错误:
Process: iti.pap.ch.pap_test, PID: 9364
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/hyperledger/fabric/sdk/Peer$PeerRole;
at org.hyperledger.fabric.gateway.DefaultCommitHandlers.<clinit>(DefaultCommitHandlers.java:70)
at org.hyperledger.fabric.gateway.impl.GatewayImpl$Builder.<init>(GatewayImpl.java:67)
at org.hyperledger.fabric.gateway.Gateway.createBuilder(Gateway.java:87)
at iti.pap.ch.pap_test.Issue.main(Issue.java:41)
at iti.pap.ch.pap_test.MainActivity.onClick(MainActivity.java:29)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access00(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.hyperledger.fabric.sdk.Peer$PeerRole" on path: DexPathList[[zip file "/data/app/iti.pap.ch.pap_test-CLJRfC7j75Bhy3VebuP5kg==/base.apk"],nativeLibraryDirectories=[/data/app/iti.pap.ch.pap_test-CLJRfC7j75Bhy3VebuP5kg==/lib/x86, /system/lib]]```
这个依赖应该提供它:
implementation "org.hyperledger.fabric:fabric-gateway-java:2.1.0"
如果 class 在运行时未知,请禁用混淆 - 或为其编写适当的配置。