Connecting to Indy Pool from Android Client Using SDK and JavaWrapper

I have an Indy pool set up and can connect to that Indy pool via the Indy-CLI, the Python example and the NodeJS example but can’t connect to it via Android. I’ve started based on the example at (apparently created by a commenter in another thread here about an Android Indy client: Using SDK and JavaWrapper in Android Studio ). I can’t connect it to that same Indy pool from an Android client, even though I’m using the same genesis file as the other working clients. I get the following error when trying to connect to the pool:

java.util.concurrent.ExecutionException: org.hyperledger.indy.sdk.ledger.TimeoutException: Timeout happens for ledger operation.

Do you know where I might find sample Android code that successfully connects to an indy pool?
Do you have any suggestions about how I might debug the connection?

How do your run your indy test-network? Do you use docker? The exception suggests that you can’t communicate with the indy-network instance, but your sdk seems to be running well, because you don’t get nullpointer exceptions.

Assuming your indy-sdk is working, here is a code (libindy 1.90), which works for me:
1 - You have to set up the environment:

    private void setEnvironmentAndLoadLibindyAndroid() throws IndyFacadeException {
            try {
                Os.setenv("EXTERNAL_STORAGE", environmentPath, true);
                File file = new
                if (!file.exists()) {
            } catch (ErrnoException e) {
                throw new IndyFacadeException("could not set android environment", e);


The environment path is:


After you have loaded libindy, you need the genesis transactions and the pool configuration. Here are some methods, which work for me.

2 - Writing default genesis transactions:

 public void writeDefaultGenesisTransactions(String poolIPAdress) throws IndyFacadeException {
            String[] genesisTransactions = getDefaultGenesisTxn(poolIPAdress);
            writeGenesisTransactions(genesisTransactions, DEFAULT_GENESIS_FILE);

public void writeGenesisTransactions(String[] genesisContent, String genesisFileName) throws IndyFacadeException {
        try {
            File genesisFile = new File(indyClientPath + "/" + genesisFileName);
            FileWriter fw = new FileWriter(genesisFile);
            for (String s : genesisContent) {
        } catch (IOException e) {
            throw new IndyFacadeException("could not write default genesis transactions", e);

private String[] getDefaultGenesisTxn(String poolIPAddress) {
        String[] s = new String[]{String.format(
                poolIPAddress, poolIPAddress),
                        poolIPAddress, poolIPAddress),
                        poolIPAddress, poolIPAddress),
                        poolIPAddress, poolIPAddress)};
        return s;

3 - After you have the genesis file, you can create the pool configuration:

public void createDefaultPool() throws IndyFacadeException {
        createPool("myIndyPool", "genesis.txn");


public void createPool(String poolName, String genesisTransactionsFileName) throws IndyFacadeException {
        try {
            PoolJSONParameters.CreatePoolLedgerConfigJSONParameter createPoolLedgerConfigJSONParameter = new PoolJSONParameters.CreatePoolLedgerConfigJSONParameter(
                    indyClientPath + "/" + genesisTransactionsFileName);
            Pool.createPoolLedgerConfig(poolName, createPoolLedgerConfigJSONParameter.toJson()).get();
        } catch (InterruptedException | ExecutionException | IndyException e) {
            throw new IndyFacadeException("could not create pool", e);

Where the indy-client path is:

indyClientPath = environmentPath + "/" + ".indy_client";

Now you can try to open the default pool:

public void openDefaultPool() throws IndyFacadeException {
        openPool(myIndyPool, null);

At this step you should be able to open the (default) pool and e.g. read a verkey from the ledger:

public String readVerKeyForDidFromLedger(String did) throws IndyFacadeException {
        try {
            String key = Did.keyForDid(pool, wallet, did).get();
            return key;
        } catch (InterruptedException | ExecutionException | IndyException e) {
            throw new IndyFacadeException("could not read verkey for did from ledger", e);

The above code is from a recent project of mine, but unfortunately I can’t publish the entire projekt. Please let me know, if you have any further trouble. Wenn Sie weiterhin Probleme haben, kann ich Ihnen ein Beispielprojekt auf github erstellen.

1 Like

Yes. I’ve had success from the other clients using the localhost and specific IP Docker setup at:

I started with Android emulator to locahost pool. Then I thought that the android emulator to localhost might be the problem so I moved the indy pool to an EC2 instance (still successful with the other non-Android clients).

I think that I’ll be able to try out your code tomorrow afternoon before the holiday. There seem to be a few differences in the code you’ve posted versus ap050492’s github and what I’ve tried. Hopefully that will help me connect.

Thanks for that code.

In my app I have also the following network security configuration:

<?xml version="1.0" encoding="utf-8"?>
    <base-config cleartextTrafficPermitted="true" />

The xml lies in

My permissions in the manifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
1 Like

Unfortunately, I’ve gone from bad to worse. I started by adding the following method:

public void openPool(String poolName)  {
    try {
        Pool.openPoolLedger(poolName, null).get();
    } catch (InterruptedException | ExecutionException | IndyException e) {

The application started crashing in the openPool method (not throwing an exception) after I updated the app to 1.9.0. I used the pre-built binaries at and changed app level gradle to:
api 'org.hyperledger:indy:1.9.0'

The following is an excerpt from the crash log:
--------- beginning of crash
2019-12-27 09:07:09.931 6181-6246/com.example.myapplication A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 6246 (Thread-16)

2019-12-27 09:07:09.942 6250-6250/? A/DEBUG: #10 pc 0000ccaf /data/app/com.example.myapplication-2/lib/x86/
2019-12-27 09:07:09.942 6250-6250/? A/DEBUG: #11 pc 00010d72 /data/app/com.example.myapplication-2/lib/x86/

2019-12-27 09:07:09.942 6250-6250/? A/DEBUG: #13 pc 00332bd0 /data/app/com.example.myapplication-2/lib/x86/ (ZN63$LT$indy…utils…logger…LibindyLogger$u20$as$u20$log…Log$GT$3log17h89fe33b32c7fa735E+672)
2019-12-27 09:07:09.942 6250-6250/? A/DEBUG: #14 pc 010fe29a /data/app/com.example.myapplication-2/lib/x86/ (_ZN3log17__private_api_log17h2ef5c01549b81d6fE+138)
2019-12-27 09:07:09.942 6250-6250/? A/DEBUG: #15 pc 004387ef /data/app/com.example.myapplication-2/lib/x86/ (indy_get_current_error+111)
2019-12-27 09:07:09.942 6250-6250/? A/DEBUG: #16 pc 00011069 /data/app/com.example.myapplication-2/lib/x86/ (ffi_call_SYSV+25)
2019-12-27 09:07:09.942 6250-6250/? A/DEBUG: #17 pc 00010ce0 /data/app/com.example.myapplication-2/lib/x86/ (ffi_call+176)
2019-12-27 09:07:09.942 6250-6250/? A/DEBUG: #18 pc 000051e0 /data/app/com.example.myapplication-2/lib/x86/
2019-12-27 09:07:09.942 6250-6250/? A/DEBUG: #19 pc 00007c1f /data/app/com.example.myapplication-2/lib/x86/ (Java_com_sun_jna_Native_invokeInt+63)
2019-12-27 09:07:09.942 6250-6250/? A/DEBUG: #20 pc 005c5792 /data/app/com.example.myapplication-2/oat/x86/base.odex (offset 0x55f000)

Did you use a particular and/or force a particular NDK version? I see that some docs at suggest a particular version of may be necessary for particular libindy versions. And I might have seen that a particular NDK might be required for particular libindy versions as well ( github . com/hyperledger/indy-sdk/pull/1901 ).

I had a similiar problem. As I remember the reason was the logger. I’ll make a sample android-project and upload it to github, so hopefully you will have a full running example.

1 Like

Thanks. It seems that it might be related to your prior post at Indy_get_current_error fails when using maven dependency

Here is a sample android project

The app creates a wallet and a sample pool. It then opens the pool and reads a verKey for the steward did from the ledger. The app consists of an empty activity and and the relevant events are written to logcat, e.g.:

2019-12-27 20:10:05.440 17048-17048/com.example.myapplication D/SampleWalletTest: onCreate: environment set successfully
2019-12-27 20:10:05.456 17048-17048/com.example.myapplication D/SampleWalletTest: onCreate: genesis file created successfully
2019-12-27 20:10:05.502 17048-17048/com.example.myapplication D/SampleWalletTest: onCreate: pool created successfully
2019-12-27 20:10:29.700 17048-17048/com.example.myapplication D/SampleWalletTest: onCreate: wallet opened successfully
2019-12-27 20:10:29.749 17048-17048/com.example.myapplication D/SampleWalletTest: onCreate: Steward-DID is Th7MpTaRZVRYnPiabds81Y
2019-12-27 20:10:29.885 17048-17048/com.example.myapplication D/SampleWalletTest: onCreate: pool opened successfully
2019-12-27 20:10:29.894 17048-17048/com.example.myapplication D/SampleWalletTest: onCreate: read verKey from ledger successfully FYmoFw55GeQH7SRFa37dkx1d2dZ3zUF8ckg7wmL7ofN4
2019-12-27 20:10:29.909 17048-17048/com.example.myapplication D/SampleWalletTest: onCreate: pool closed successfully
2019-12-27 20:10:29.916 17048-17048/com.example.myapplication D/SampleWalletTest: onCreate: wallet closed successfully

The onCreate of the MainActivity contains all the code. See the comments there. If you try on your machine, please dont forget to change the IP for the genesis file. Otherwise you will run into an IndyException.

The java wrapper in 1.90 had a problem with execptions especially in android. According to IS-1252 the problem lies in the logger. Compare also my latest post in:

I solved the problem by changing the logger to the default one. The app has been tested with libindy 1.90 on a samsung galaxy s7 and the latest docker image (27.12.2019). Libindy and the (modfied) java wrapper are included in the github project, so you can use them out of the box.

Please let me know, if you could connect to the pool :slight_smile:

1 Like

I was able to connect to a pool. I commented out line 38 ( indyFacade.deletePool(IndyFacade.DEFAULT_POOL_NAME); ) in https://github. com/jSh4rk/SampleIndyWallet/blob/master/app/src/main/java/com/example/sampleindywallet/
on an initial run on an API 24 emulator. as it produced an error on the initial run (error: java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of '' appears in /system/framework/core-oj.jar) ). But uninstalling and running the app succeeds from environment setup through wallet closing. On an API 27 emulator, it worked fine. The file deletion is trivial and solvable compared to connecting to the Indy pool.

Many thanks for the working sample code.

I have a one question.

I’m trying to connect the Android app to the indy pool, but I see error( Timeout happens for ledger operation)
The test environment installed Ubuntu in the Virtual Box of Windows 10 and then a docker in Ubuntu.
For example, ip of Ubuntu is and ip of the docker is
I know the port was mapped by the option Docker Run -itd 9701-9708:9701-9708.
So when using the Android app, designated the IP to be accessed as Ubuntu’s IP, but could not open the pool.
The Genesis file was also converted to Ubuntu’s ip.
What’s the problem?