Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 2 tasks
vsbogd opened this issue Apr 9, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@vsbogd
Copy link
Member

vsbogd commented Apr 9, 2020

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
@vsbogd vsbogd added the bug Something isn't working label Apr 9, 2020
@vsbogd
Copy link
Member Author

vsbogd commented Apr 9, 2020

First task is done by PR #51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant