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

[android] Can not compile projekt [too old dependencies most of times] #54

Closed
Setitch opened this issue Dec 4, 2019 · 8 comments
Closed

Comments

@Setitch
Copy link

Setitch commented Dec 4, 2019

I tried compiling the library to android, C/CPP without a problem, but android part - failes all of times. I already used one week to try to compile the aar file, and it is still failing.

Issues from start

  1. cannot compile at JAVA 11 is unrecognized by very old gradle.
    *. Updating gradle works
  2. Linux/Windows - in dist.sh you explicite blocked compiling android sources on machines other than macos.... WHY? - unblocking it - failes - nullPointerException

finding all of this, downloading proper sdk and ndk (trying almost every combination) still fails.

Would it be possible to get library we will be able to compile properly on modern java and systems? Please

@rossmc7
Copy link

rossmc7 commented May 25, 2020

Hey Setitch, I'm experiencing the same issue did you manage to resolve it?

@Setitch
Copy link
Author

Setitch commented May 26, 2020

Nope

@rossmc7
Copy link

rossmc7 commented May 27, 2020

So I've managed to build the .AAR file now which contains an .so binary for each architecture X86, ARM V7, V8. However, the example application does not boot. The error is logcat is "No implementation found for int com.zerotier.libzt.ZeroTier.init()".

The issue with compiling the project seems to be related to ensuring external dependencies are installed on the system.

brew install ninja
brew install tree

The installed version of java must also be modified in the dist.sh - JDK=jdk1.8.0_251.jdk

The android NDK must also be installed available through android studio, I've found that versions
17.2.4988734 18.1.5063045 19.2.5345600 all seem to work.
export ANDROID_NDK_HOME="/Users/$USER/Library/Android/sdk/ndk/17.2.4988734/“

So back to the running the example application issue, "No implementation found for int com.zerotier.libzt.ZeroTier.init()". This would suggest that the method is not defined in the library, however I've checked the actual generated binary and it does contain the required Java_com_zerotier_libzt_ZeroTier_init function, with a method body.

I've checked the externally visible functions, which lists some of the functions bind,accept,socket,connect but does not contain the init method.

Any ideas how I could further debug this?

@ghost ghost mentioned this issue Dec 21, 2020
@ghost
Copy link

ghost commented Dec 21, 2020

After updating Gradle, I'm still getting this error when running make android_release on MacOS 11 / Android Studio:

./dist.sh android "release"
Executing task:  android ( release )
> Task :app:generateJsonModelRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateJsonModelRelease'.
> /Users/ben/StudioProjects/libzt/CMakeLists.txt : C/C++ release|armeabi-v7a : CMake Error at /Users/ben/StudioProjects/libzt/CMakeLists.txt:431 (add_library):
    Error evaluating generator expression:
  
      $<TARGET_OBJECTS:zt_pic>
  
    Objects of target "zt_pic" referenced but is not an OBJECT library.

@Chanthujan
Copy link

Hi @Ben-L-E

Did you

After updating Gradle, I'm still getting this error when running make android_release on MacOS 11 / Android Studio:

./dist.sh android "release"
Executing task:  android ( release )
> Task :app:generateJsonModelRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateJsonModelRelease'.
> /Users/ben/StudioProjects/libzt/CMakeLists.txt : C/C++ release|armeabi-v7a : CMake Error at /Users/ben/StudioProjects/libzt/CMakeLists.txt:431 (add_library):
    Error evaluating generator expression:
  
      $<TARGET_OBJECTS:zt_pic>
  
    Objects of target "zt_pic" referenced but is not an OBJECT library.

Hi @Ben-L-E

Did you find a solution for the above issue?

@ghost
Copy link

ghost commented Mar 3, 2021

@Chanthujan I ended up switching to Tailscale and Nebula

@ghost
Copy link

ghost commented Apr 14, 2021

@Chanthujan I revisited this project with another attempt. Let me know if it worked: https://drive.google.com/drive/folders/17_D6Cp791E_QObcI9AWshLywps4QWTsm?usp=sharing

@joseph-henry
Copy link
Contributor

An update on this:

Java sources were intentionally removed pending the results of Google V Oracle. We planned on dropping Java support altogether if the case went the wrong way. Now that this is cleared up new (WIP) Java sources have been added. As of this comment they build and pass a basic self-test but still need a lot of refinement, this will take place in the coming weeks.

Btw, thanks for your efforts on this @Ben-L-E. I will take a close look at your PR and figure out what parts are still relevant and if anything can be included.

kennep referenced this issue in kennep/libzt Oct 1, 2021
* Update copyright year in version.rc.in

* Update ios/macos framework modulemap and reference in CMakeLists

* Add documentation to examples section

* Add non-blocking socket examples

* Adjust formatting of CMakeLists.txt

* Update C++, Objective-C and Swift examples

* Fixing Android/Java crash on boot due to missing init method (#70)

* adding extern c to library methods to fix JNI crash on init

* changed style to use ifdef cplusplus

* Minor tweak to example

* Change event code numbering scheme, fix Windows startup bug, fix zts_free(), remove vestigial API functions, update documentation

* first commit of node example

* 1st working version of node example

* add libzt.createConnection()

* small bug fix

* make libzt.a position_independent_code

* major rewrite to handle schemantics

* Update README

* Add minor bit of documentation to zts_send to address ticket #74

* Improved java example

* Fixed host_jar target broken by previous refactoring of java example

* Fix zts_allow_*_caching() bug that prevents user from properly setting value before node startup

* Add check for netif before use in VirtualTap - Fixes bug mentioned in ticket #85

* Support for creating .xcframework

* `make macOS` builds a universal framework
* `make xcframework` builds an .xcframework containing frameworks for macOS (universal), iOS, and iOS Simulator
* Addresses a compiler warning

* Tweaks to Xcode project settings

* Made certain that the result would be a module
* Removed an unnecessary #include that caused errors when included in a project

* Applied correct booleans

* First SPM support attempt

* Improved method to build xcframeworks

* Updated Makefile for xcframework

* update gradle

ref #54 #80 #88 #93

* Remove old C# callback code

* Convert spaces to tabs in dist.sh

* Add preprocessor check in ZeroTierSockets.h for inclusion of integer definitions. A response to e94ca31.

* Add C# P/INVOKE wrapper and client/server example

* Minor preprocessor adjustment in ZeroTierSockets.h

* Change lib output directory for P/INVOKE builds to append -pinvoke. Added makefile targets host_pinvoke, host_pinvoke_debug, host_pinvoke_release

* Add new PowerShell script to replace batch file for Windows builds

* Minor tweak (for clarity) of build instructions in README.md

* Calling convention fix for C# callback delegate from C++

* Fix protocol selection in C# wrapper Socket() method

* Add ZeroTierException to C# Wrapper for better error reporting

* Minor tweak to callback function name for clarity (in code and documentation)

* Update C# example client/server application. Other minor tweaks.

* Fix bug that resulted in peer caching data being written to disk even with not allowed

* e7no7nVRFItg

* Remove errant file

* Add simple test for CI build workflow

* Add CI workflow script (cmake.yml)

* Update CI script to pull submodules before build

* Fix pthreads-related compilation issue on Linux

* Add non-blocking IO support and improved exception handling in C# wrapper

* Remove Homebrew formula file

* Remove old clean.bat, error silencing added to dist.ps1

* Add newline to CI test/error.cpp to make my IDE happy

* Add prototype Central API wrapper

* Remove block that generates authtoken (vestigial leftover from OneService)

* Add prototype key management API

* Restructure packaging directories. Move C# bindings, minor compilation fix.

* Fix various minor compile-time warnings

* Update license header dates

* Add NuGet package and build scripts

* Format CMakeLists.txt with cmake_format. Nice.

* Minor powershell build script fix to silence error

* Remove WIP Java example wrapper

* Update Android build scripts. Remove unnecessary project files

* Remove unnecessary DLL versioning file

* Update C# wrapper (Namespace restructure, API additions, memory leak fix)

* Move Apple framework projects into new pkg/ directory

* Remove errant gradle files

* Rename selftest

* Move C API documentation to include directory

* Update C# wrapper

* Remove incomplete rust wrapper files

* Remove obsolete Java ports directory

* Update Java example

* Rename nodejs example directory

* Improvements to language binding facilities. Add custom signal handler

* Remove unnecessary Android example project resource files

* Fix permissions on dist.sh

They were 644 on my system

Signed-off-by: Erik Hollensbe <[email protected]>

* Add working Python wrapper and examples (WIP)

* Change C# wrapper extension from cxx to cpp

* Improvements to language binding facilities

* Overhaul build system and documentation

* Add PyPI package (WIP)

* Update various READMEs

* Implement more of the Python language binding. Minor adjustments to PyPI package

* Remove Android example. The Java example should suffice

* Run Python language bindings and example code through a linter and formatter

* fix GC issue in c#

Store a reference to the unmanaged delegate so that the c# garbage collector doesn't wipe it out which causes a hard crash since the unmanaged dll is still referencing it.

* Minor update to documentation

* Add GitHub workflow script to build Python wheels. Update PyPI package

* Add Python extension module wrapper code

* Remove now-irrelevant makefile

* Restore previous install behavior in CMakeLists

* Remove non-standard API function accept4()

* Bugfix: calling zts_free() before zts_start() would enter infinite loop

* Improve Central API

* Change error behavior: Return ZTS_ERR_SERVICE in all cases before checking anything else

* Split Java portion of socket API into its own file

* Remove networking functions that can be found elsewhere

* Expose lwIP's DNS API in zts_* API. Fix preprocessor build bug

* Remove submodule (curl)

* Add tests to selftest

* Attempt to circumvent GitHub's broken image caching service

* Update Selftest workflow file

* Update version of libcurl used in Selftest workflow file from 3 to 4

* Add libcurl4-gnutls-dev to selftest.yml

* Buildfix: Missing type specifier

* Attempt to fix zts_recv for Python.

There were a few I'm attempting to fix in zts_py_recv():

Was allocating a static buffer of 4096, but taking whatever
length the user passed in.  This change allocates a PyBytes
object of the size the user requests.

Was converting to a string without giving a size.  Which probably
led to the UnicodeDecodeError I was seeing below, trying to
decode a character beyond the received bytes.  Would also lead
to problems reading binary data that included embedded NULs.
Used the number of bytes received as the size of the returned data.

Variable "err" was being used, changed that to "bytes_read" as
that's what lwip_recv() returns, with <0 bytes read indicating
error.

Read data was being returned as a Unicode string, leading to this
response when I tried talking to my SSH server:

    UnicodeDecodeError: 'utf-8' codec can't decode
    byte 0xa1 in position 42: invalid start byte

My ssh banner is 40 bytes long, so I think position 42 was outside
the received buffer.  Changed it to a PyBytes response as is
normal for network data.  This code was cribbed from the Python
socketmodule

This was producing this error, as it was still returning the tuple:

    SystemError: <built-in function zts_py_recv> returned a
    result with an error set

This indicates that the UnicodeDecodeError had set an exception,
but a tuple was being returned instead of NULL.

In the case of a lwip_recv() error, the error response was not
being sent back to the wrapper code.  Instead, a "return NULL;"
was done.  I changed this case to return the tuple (err, None)
to the wrapper.

NOTE: this code built using "./build.sh host-python release", but
there was some sort of build problem I didn't understand which
produced a _libzt.so that I couldn't import, due to:

    ImportError: dynamic module does not define module export
    function (PyInit__libzt)

So I don't have a way to test these changes.

* Better random number generation in selftest

* Bugfix: Check argument types and encodings in zts_py_send()

* Move Python license into ext/THIRDPARTY.txt

* Update PyPI package version to 1.3.4b1

* Update PyPI package build workflow to build Swig wrapper automatically

* Assorted Python changes based on a code review.

Many changes were based on conventions in the Python socketmodule.

Changed many of the docstrings to match the Python socket library
conventions and enhancing them.  I can either remove the prototype
part or add it to other docstrings in the library, depending on
feedback I get.

Changed setblocking to use the flag argument instead of always
just setting NONBLOCK.

Added enable/disable threading around more lwip calls.

Implementing optional backlog on listen().

Removing a few seemingly unneeded Py_INCREF(Py_None) calls.

Moved getblocking function based on alpha sorting of names.

* Fixing some bugs in socket blocking.

There were some bugs in my blocking code that are fixed in this.
I had the setblocking() flag reversed, and wasn't passing the
flag along to the underlying code properly.

* Remove out-of-place includes for signal handler functions

* Minor Windows build fixes

* Add NuGet package workflow

* Replace manual csc.exe invokation with dotnet project (for NuGet build)

* Python send() with binary data

zts_py_send() was using strlen() to determine the length of the
send(). This works fine with strings, but fails with binary
data.

To fix this, I have removed the string encoding code, and
converted to using the Buffer protocol as is done in the
Python socketmodule send() implementation. This does mean
that this send() implementation only takes byte-like objects.

The workaround for this could be at the python level rather
than the C++ level.

NOTE: This implementation has a bug in the exception handling
if a non-bytes-like object is passed. You get an exception,
but the exception is not accurate, it reports the TypeError,
but the actual raised exception is due to there being a return
value when the error indicator is set. I spent a few hours
trying to fix this but was unable to. I'm afraid I just couldn't
figure it out.

My SSH proxy was misbehaving because the second block
of data going from the client to the server had a NUL byte as
the first byte to send, so the send was returning 0 bytes
sent, but that was due to send() being told to send 0 bytes.

With this, my SSH proxy is now working, including able to run
an rsync of my boot initrd over SSH over ZeroTier entirely in
userspace.

* Update C API: Add functions that simplify wrapper generation

* Fixed memleak, optimize and refactor code

* Add IPv6 to C# ZeroTier.Sockets, Add C# selftest, Misc C API improvements

* Add .clang-format file

* Applied styling rules from .clang-format

* Add code style enforcement to github workflow

* Remove C++ examples (To be replaced with C examples)

* Update .clang-format code style

* Update .clang-format code style

* Update workflows

* Adjust test targets and code style enforcement in build script

* Expand C API and simplify NodeService

* Code style fixes

* Add zts_core_query_ and world sub-APIs. Adjust event subsystem

* Update .clang-format to reflect new ZeroTier standard

* Format according to new ZeroTier standard

* Improve build parallelism in build.sh

* Adjust nomenclature. Add more C API extension functions

* Fix bug in network transport readiness check function

* Add WIP Java language bindings

* Update C API selftest

* Reduce number of compile-time warnings

* Reduce number of compile-time warnings (continued)

* Update C# bindings to 1.4.0 API

* Update Python bindings to 1.4.0 API (WIP)

* Code style fixes

* Add submodule check to build script

* Fix misc build issues

* Minor adjustment to build script

* Slight re-org of C API naming convention

* Update C API selftest

* Move some out-dated examples to attic, update README.md

* Minor Windows build fixes

* Code style fixes

* Commented out pthread_setname_np to address portability concern #116

* Code style fixes

* Remove unnecessary include to fix #115

* Minor update to C examples

* Update README.md

* Update README.md

* Slight re-org of event system and fix bug in zts_util_ipstr_to_saddr

* Fix compile-time errors for C# binding on Windows

* Add sanitizer options to CMakeLists.txt

* Fix socket initialization error on Windows

* Code style fixes

* Add better port binding controls

* Code style fixes

* Minor update to C# NuGet package documentation and example

* Code style enforcement

* Update license file

* Add NetworkStream to C# wrapper. Fix errno bug in C# wrapper

* Fix MAC address getter convenience function in C API

* Add ZeroTierDatagramSocket and ZeroTierServerSocket to Java wrapper

* Add workaround to get tagged version in GitHub workflow script

* Add workaround to get tagged version in GitHub workflow script

* Change how build script reads version tag

* Read .version file before changing into packaging directory

* Correctly handle IPv6 unspecified address in C API

* Bind to IPv6 unspecified address in ZeroTierSocket constructor

* Code style enforcement

* Add Android AAR workflow

* Re-add gradle-wrapper.jar

* Minor changes to documentation comments to make parser happy

* Format Python code with (black)

* Add address getter method to Python wrapper

* Make socket exceptions more specific to match Python semantics

* Bump PyPI package version

* Remove unnecessary return statements in Python sockets error handler

* Prevent clang-format from messing with auto-generated Python bindings

* Update documentation links in READMEs

* Make Node singleton members static. Fixes UB in C# event logic

* Update link to documentation in README.md

* Add Rust bindings (WIP)

* Update Linux build instructions in README.md

* Update documentation

* Save reference to managed callback in C# wrapper. Fixes event bug.

* Make Rust address getter return IpAddr instead of String

* These are some things I noticed while working in this tree:

- target/ was not in .gitignore
- src/libzt.rs is generated, put in .gitignore and deleted
- time_t was not defined; libc is a build dep so didn't want to bring it
  in for a type. Decided to just typedef it.

Signed-off-by: Erik Hollensbe <[email protected]>

* Fixed up build to not use concat and rely on cargo/compiler to do this
work

Signed-off-by: Erik Hollensbe <[email protected]>

* Remove debug traces from C# wrapper

* Update C# NuGet package documentation

* Only invoke Python user callback if set by user

* Add Python copyright and license text for wrapper

* Add select, getsockopt, setsockopt, ioctl and fcntl to Python wrapper

* Update Rust crate README.md

* Possible fix for Python multithread bug #126

* Add Rust bindings (alpha)

* Code style enforcement

* Bump Python version number

* Build fix for Python wrapper

* Code style enforcement

* Build fix for Python wrapper

* Code style enforcement

* Move auto-format.yml to attic

* Check Python version to determine proper timeout rounding mode

* Update Rust crate

* Backport port selection logic from 1.6.X

* Update ZeroTierOne submodule to 1.6.5

* Bump package and license versions numbers

* Remove old Node.js wrapper

Co-authored-by: Joseph Henry <[email protected]>
Co-authored-by: rossmc7 <[email protected]>
Co-authored-by: heri16 <[email protected]>
Co-authored-by: joseph-henry <[email protected]>
Co-authored-by: Bartłomiej Mazurski <[email protected]>
Co-authored-by: Podcast Studio Development <[email protected]>
Co-authored-by: Evan Olcott <[email protected]>
Co-authored-by: Ben <[email protected]>
Co-authored-by: Joseph Henry <[email protected]>
Co-authored-by: Erik Hollensbe <[email protected]>
Co-authored-by: MoogleTroupe <[email protected]>
Co-authored-by: Sean Reifschneider <[email protected]>
Co-authored-by: Sean Reifschneider <[email protected]>
Co-authored-by: GermanAizek <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Erik Hollensbe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants