1
+ [ ![ Maven Central] ( https://img.shields.io/maven-central/v/com.avsystem.anjay/anjay-android?label=maven%20central%3A%20anjay-android )] ( https://search.maven.org/artifact/com.avsystem.anjay/anjay-android )
2
+ [ ![ Maven Central] ( https://img.shields.io/maven-central/v/com.avsystem.anjay/anjay-java?label=maven%20central%3A%20anjay-java )] ( https://search.maven.org/artifact/com.avsystem.anjay/anjay-java )
3
+
1
4
# Anjay-java [ <img align =" right " height =" 50px " src =" https://avsystem.github.io/Anjay-doc/_images/avsystem_logo.png " >] ( http://www.avsystem.com/ )
2
5
3
6
## About
@@ -9,55 +12,54 @@ This project provides almost 1:1 API bindings between [Anjay](https://github.com
9
12
This is a preview release and we don't provide any guarantees about API stability
10
13
or library reliability.
11
14
12
- ## Usage
15
+ ## Using in Android Studio
16
+
17
+ This project is released to Maven Central repository as
18
+ ` com.avsystem.anjay.anjay-android ` . Add ` mavenCentral() ` in ` repositories `
19
+ section of your build script and ` implementation 'com.avsystem.anjay:anjay-android:2.+' ` in ` dependencies ` to use it.
20
+
21
+ ## Using anjay-java package
22
+
23
+ Although the ` anjay-java ` package is released on Maven Central repository, it
24
+ requires native shared library to be available. See the Compilation guide for
25
+ details how to build the native library.
13
26
14
- First of all, remember to update all submodules using ` git submodule update --init --recursive ` .
27
+ ## Compilation guide
15
28
16
- ### CMake
29
+ First of all, remember to update all submodules using
30
+ ` git submodule update --init --recursive ` .
31
+
32
+ ### Build library
17
33
18
- The library, example client and documentation can be built from command line as follows:
19
34
``` sh
20
- $ cmake .
21
- $ make -j
35
+ ./gradlew :library:build
22
36
```
23
37
24
- To run the example client execute:
38
+ The ` jar ` file is placed in ` library/build/libs ` directory. Note that it doesn't
39
+ include the native library, which can be found in ` library/build/cmake `
40
+ directory.
41
+
42
+ ### Build and run demo
43
+
25
44
``` sh
26
- $ java -Djava.library.path=$PWD / -jar demo.jar
45
+ ./gradlew :demo:build
46
+ java -Djava.library.path=library/build/cmake/ -jar demo/build/libs/demo.jar
27
47
```
28
48
29
49
By default, the client attempts to connect to ` coap://127.0.0.1:5683 ` , but it
30
- can be customized using command line arguments. Use ` --help ` to see all available
31
- options.
32
-
33
- ### Android Studio
34
-
35
- 1 . Start with creating a simple base project (_ Empty activity_ for example),
36
- using Java and API 26 or newer.
37
- 2 . In the left navigator right click on the _ app_ and select
38
- _ Link C++ Project with Gradle_ , set _ Build System_ to _ CMake_ and choose
39
- _ CMakeLists.txt_ file from the root project directory.
40
- 3 . As of today's version of mbed TLS (2.23.0) there's a problem preventing it
41
- from compiling. A crude and simple workaround for this is to edit
42
- application's ` build.gradle ` as below:
43
- ```
44
- android {
45
- // ...
46
- defaultConfig {
47
- // ...
48
- externalNativeBuild {
49
- cmake {
50
- // Workaround for bad casts within mbed TLS
51
- cFlags "-Wno-pointer-sign"
52
- }
53
- }
54
- }
55
- // ...
56
- }
57
- ```
58
- 4 . The next step is to add Anjay's Java sources to your project so that you can
59
- actually use the bindings. The simplest way to do it is to create a symlink
60
- from ` bindings/main/java/com/avsystem ` to ` app/src/main/java/com/avsystem ` .
61
- 5 . Now you can check
62
- ` bindings/src/main/java/com/avsystem/anjay/demo/DemoClient.java ` to see
63
- how to use Anjay's Java bindings.
50
+ can be customized using command line arguments. Use ` --help ` to see all
51
+ available options.
52
+
53
+ ### Building for Android
54
+
55
+ ``` sh
56
+ ANDROID_SDK_ROOT=< path to Android SDK> ./gradlew -Pandroid :library:build
57
+ ```
58
+
59
+ The ` aar ` files are in ` library/build/outputs/aar ` directory.
60
+
61
+ ### Running tests
62
+
63
+ ``` sh
64
+ ./gradlew :testing:check
65
+ ```
0 commit comments