On the Commercial paper tutorial there is an application on java, it works well. Now, I try to implement with Android Studio as a tuto.
I modified some lines to launch on an emulator and followed the pom.xml as possible to get the dependencies. But an error occurred with org.hyperledger.fabric, when I use Issue.java or AddToWallet.java class (Complete error at the end, for Issue app) :
Issue invoke Gateway.Builder builder = Gateway.createBuilder();
pass by GatewayImpl.java and DefaultCommitHandlers.java:70
On class DefaultCommitHandlers there are Peer, where error start :
import org.hyperledger.fabric.sdk.Peer
;
private static final EnumSet<Peer.PeerRole> EVENT_SOURCE_ROLES = EnumSet.of(Peer.PeerRole.EVENT_SOURCE);
What does it mean? How can I correct this?
Complete error:
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$1.onClick(MainActivity.java:29)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(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]]```
This dependency should provide it:
implementation "org.hyperledger.fabric:fabric-gateway-java:2.1.0"
And if the class is not known at runtime, disable obfuscation - or write a proper configuration for it.