Skip to content

Fix Android configuration to allow connecting to http://ipfs.singularitynet.io on Android 9+ #50

Description

@vsbogd

Since Android 9 cleartext connections are forbidden by default, see: https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted

This causes the following NullPointerException error on demo app start:

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.InputStream.read(byte[])' on a null object reference
        at io.ipfs.api.IPFS.readFully(IPFS.java:763)
        at io.ipfs.api.IPFS.get(IPFS.java:682)
        at io.ipfs.api.IPFS.retrieve(IPFS.java:662)
        at io.ipfs.api.IPFS.retrieveAndParse(IPFS.java:624)
        at io.ipfs.api.IPFS.version(IPFS.java:572)
        at io.ipfs.api.IPFS.<init>(IPFS.java:69)
        at io.ipfs.api.IPFS.<init>(IPFS.java:45)
        at io.singularitynet.sdk.client.ConfigurationDependencyFactory.<init>(ConfigurationDependencyFactory.java:64)
        at io.singularitynet.sdk.client.Sdk.<init>(Sdk.java:63)
        at com.example.singsplit.SnetSdk.<init>(SnetSdk.java:22)
        at com.example.singsplit.MainActivity.openSingularityNETServiceChannel(MainActivity.java:161)
        at com.example.singsplit.MainActivity.access$300(MainActivity.java:71)
        at com.example.singsplit.MainActivity$OpenServiceChannelTask.doInBackground(MainActivity.java:200)
        at android.os.AsyncTask$3.call(AsyncTask.java:378)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

see similar IPFS issue: ipfs-shipyard/java-ipfs-http-client#125

To fix it:

  • add correct network configuration to the Android demo app source code, test it on Android 10
  • add this step to the Gradle plugin README.md

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions