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

Create Android port #11

Closed
qstokkink opened this issue Dec 5, 2017 · 17 comments
Closed

Create Android port #11

qstokkink opened this issue Dec 5, 2017 · 17 comments
Labels
priority: medium Enhancements, features or exotic bugs

Comments

@qstokkink
Copy link
Collaborator

IPv8 should function as an Android app.

All of the dependencies have been compiled before for the Tribler project, these should/could be reused for the py-to-app compiler.

@qstokkink qstokkink added the priority: medium Enhancements, features or exotic bugs label Dec 5, 2017
@devos50
Copy link
Contributor

devos50 commented Dec 7, 2017

IPv8 is up and running on Android! Note that it gives an error after about 30 seconds (#19 )

Files to create the Python-for-Android distribution: https://github.com/devos50/ipv8-android-service
Android app (import this in Android Studio): https://github.com/devos50/ipv8-android-app

@qstokkink
Copy link
Collaborator Author

@devos50 thanks! I'll check out #19: does the app hard crash on that error or is it just a debug message?

@devos50
Copy link
Contributor

devos50 commented Dec 7, 2017

@qstokkink it's just an error message and the app continues to work.

I also noticed that the following is spammed in logcat:

12-07 10:21:35.092 11966 11995 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.133 11966 11992 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.200 11966 11995 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.211 11966 11995 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.318 11966 11995 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.357 11966 11996 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.383 11966 11996 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.404 11966 11995 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.465 11966 11995 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.475 11966 11995 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.528 11966 11995 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.858 11966 11996 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.951 11966 11995 I IPV8Service: DEBUG:nodeids do not match
12-07 10:21:35.956 11966 11989 I IPV8Service: DEBUG:nodeids do not match

Probably not critical but you might want to take a look at it?

qstokkink added a commit that referenced this issue Dec 7, 2017
qstokkink added a commit that referenced this issue Dec 7, 2017
@qstokkink
Copy link
Collaborator Author

@devos50 nodeids spam fixed in fc7abec, it was trying to decode messages from other communities as TunnelCommunity messages. This probably also fixes #19.

@devos50
Copy link
Contributor

devos50 commented Dec 7, 2017

APK:
ipv8.apk.zip

@qstokkink
Copy link
Collaborator Author

Cool 👍

@qstokkink
Copy link
Collaborator Author

@devos50 I've been sifting through dependencies and compiling today, but I can't get past this step (part of buid.sh):

quinten@quinten-VirtualBox:~/Documents/ipv8-android-service$ bash create_dist.sh 
Create dist
[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Getting Android API version from user argument
[INFO]:    Available Android APIs are (18, 27)
[INFO]:    Requested API target 18 is available, continuing.
[INFO]:    Getting NDK dir from from user argument
[INFO]:    Got NDK version from from user argument
[INFO]:    Using Google NDK 13
[INFO]:    Found virtualenv at /usr/local/bin/virtualenv
[INFO]:    Found the following toolchain versions: ['4.9']
[INFO]:    Picking the latest gcc toolchain, here 4.9
[INFO]:    No existing dists meet the given requirements!
[INFO]:    No dist exists that meets your requirements, so one will be built.
[INFO]:    Found a single valid recipe set: [u'ipv8']
[INFO]:    The selected bootstrap is service_only
[INFO]:    # Creating dist with service_only bootstrap
[INFO]:    Dist will have name IPV8Service and recipes (ipv8)
[INFO]:    Dist will also contain modules (ipv8) installed from pip
[INFO]:    -> running cp -r /usr/local/lib/python2.7/dist-packages/pythonforandroid/bootstraps/service_only/build /home/quinten/.local/share/python-for-android/build/bootstrap_...(and 19 more)
[INFO]:    -> directory context /home/quinten/.local/share/python-for-android/build/bootstrap_builds/service_only
[INFO]:    <- directory context /home/quinten/Documents/ipv8-android-service
[INFO]:    Recipe build order is []
[INFO]:    The requirements (ipv8) were not found as recipes, they will be installed with pip.
[INFO]:    # Downloading recipes 
[INFO]:    # Building all recipes for arch armeabi-v7a
[INFO]:    # Unpacking recipes
[INFO]:    # Prebuilding recipes
[INFO]:    # Building recipes
[INFO]:    # Biglinking object files
[INFO]:    Collating object files from each recipe
Traceback (most recent call last):
  File "/usr/local/bin/p4a", line 11, in <module>
    load_entry_point('python-for-android==0.6.0', 'console_scripts', 'p4a')()
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 975, in main
    ToolchainCL()
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 512, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 149, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 193, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/build.py", line 581, in build_recipes
    biglink(ctx, arch)
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/build.py", line 658, in biglink
    env = arch.get_env()
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/archs.py", line 150, in get_env
    env = super(ArchARMv7_a, self).get_env(with_flags_in_cc)
  File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/archs.py", line 54, in get_env
    self.ctx.python_recipe.version[0:3])
AttributeError: 'NoneType' object has no attribute 'version'

Do you know what's going on?

@devos50
Copy link
Contributor

devos50 commented Dec 8, 2017

@qstokkink I've encountered that error several times myself and I still haven't found the root cause. It might be that a specific recipe is not found, probably one of the recipes I've modified.

Also, please verify that you run the version of Python-for-Android as specified in the reinstall_p4a.sh file: https://github.com/devos50/ipv8-android-service/blob/master/reinstall_p4a.sh

@qstokkink
Copy link
Collaborator Author

@devos50 thanks, that was it: it needed that specific version (it wasn't working with the release or latest master from GitHub)

@devos50
Copy link
Contributor

devos50 commented Dec 8, 2017

Yeah, there is also a netifaces incompatibility when using the latest version.

Also, some Blockchain engineering students just came here and asked whether they can also use the IPv8 Android backend so I'm working on a Jenkins job to build the private.mp3 file: https://jenkins.tribler.org/job/pers/job/Build_IPv8_Android_backend/. Shouldn't be too hard I guess.

@devos50
Copy link
Contributor

devos50 commented Dec 8, 2017

@qstokkink the Jenkins job seems to produce a Python-for-Android distribution. Could you verify that this private.mp3 file works? https://jenkins.tribler.org/job/pers/job/Build_IPv8_Android_backend/4/

@qstokkink
Copy link
Collaborator Author

@devos50 I'm still trying to get https://github.com/devos50/ipv8-android-app to work.. 😢

@qstokkink
Copy link
Collaborator Author

Alright, I'm calling it a day. I'll try getting the app up and running again tomorrow.

@qstokkink
Copy link
Collaborator Author

qstokkink commented Dec 11, 2017

I got the build working, I needed the following changes in the build.gradle:

model {
    android {
        defaultConfig {
            minSdkVersion.apiLevel 21 // 18 -> 21
        }
        ndk {
            platformVersion = 21 // 18 -> 21
            CFlags.add("-isystem" + file("/home/quinten/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi")) // new
            CFlags.add("-I" + file("/home/quinten/Android/Sdk/ndk-bundle/sysroot/usr/include")) // new
        }
    }
}

And of course Android Studio 2.3.3

@qstokkink
Copy link
Collaborator Author

@devos50 with the new mp3:

12-12 15:43:22.610 6544-6598/? I/IPV8Service: /data/user/0/org.internetofmoney.android/files/lib/python2.7/site-packages/twisted/conch/ssh/common.py:18: RuntimeWarning: PyCrypto not installed, but continuing anyways!
12-12 15:43:22.610 6544-6598/? I/IPV8Service:   RuntimeWarning)
12-12 15:43:22.667 6544-6598/? I/IPV8Service: Traceback (most recent call last):
12-12 15:43:22.667 6544-6598/? I/IPV8Service:   File "ipv8.py", line 31, in <module>
12-12 15:43:22.668 6544-6598/? I/IPV8Service:     IPV8Service().run()
12-12 15:43:22.668 6544-6598/? I/IPV8Service:   File "ipv8.py", line 21, in run
12-12 15:43:22.668 6544-6598/? I/IPV8Service:     from twisted.plugins.ipv8_plugin import Options, service_maker
12-12 15:43:22.668 6544-6598/? I/IPV8Service:   File "/data/user/0/org.internetofmoney.android/files/lib/python2.7/site-packages/twisted/plugins/ipv8_plugin.py", line 11, in <module>
12-12 15:43:22.668 6544-6598/? I/IPV8Service:     from twisted.conch import manhole_tap
12-12 15:43:22.668 6544-6598/? I/IPV8Service:   File "/data/user/0/org.internetofmoney.android/files/lib/python2.7/site-packages/twisted/conch/manhole_tap.py", line 18, in <module>
12-12 15:43:22.668 6544-6598/? I/IPV8Service:     from twisted.conch import manhole, manhole_ssh, telnet
12-12 15:43:22.668 6544-6598/? I/IPV8Service:   File "/data/user/0/org.internetofmoney.android/files/lib/python2.7/site-packages/twisted/conch/manhole_ssh.py", line 14, in <module>
12-12 15:43:22.668 6544-6598/? I/IPV8Service:     from twisted.conch.ssh import factory, keys, session
12-12 15:43:22.668 6544-6598/? I/IPV8Service:   File "/data/user/0/org.internetofmoney.android/files/lib/python2.7/site-packages/twisted/conch/ssh/factory.py", line 16, in <module>
12-12 15:43:22.668 6544-6598/? I/IPV8Service:     import transport, userauth, connection
12-12 15:43:22.668 6544-6598/? I/IPV8Service:   File "/data/user/0/org.internetofmoney.android/files/lib/python2.7/site-packages/twisted/conch/ssh/transport.py", line 22, in <module>
12-12 15:43:22.668 6544-6598/? I/IPV8Service:     from Crypto import Util
12-12 15:43:22.668 6544-6598/? I/IPV8Service: ImportError: No module named Crypto

@qstokkink
Copy link
Collaborator Author

afbeelding

I extracted the private.mp3 from the old and the new build. It appears the zope.interface-4.1.3-py2.7.egg-info folder and the zope.interface-4.1.3-py2.7-nspkg.pth file are missing in the Jenkins private.mp3.

@qstokkink
Copy link
Collaborator Author

Basic app is up and running now.

egbertbouman pushed a commit to egbertbouman/py-ipv8 that referenced this issue Nov 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium Enhancements, features or exotic bugs
Projects
None yet
Development

No branches or pull requests

2 participants