diff --git a/docs/release-notes/release-notes-0.15.0.md b/docs/release-notes/release-notes-0.15.0.md index 8673f2892..53421658e 100644 --- a/docs/release-notes/release-notes-0.15.0.md +++ b/docs/release-notes/release-notes-0.15.0.md @@ -58,4 +58,5 @@ * Joost Jager * Liviu * Torkel Rogstad +* Vsevolod Kaganovych * Yong Yu diff --git a/mobile/README.md b/mobile/README.md index 068e5329c..22bb80e89 100644 --- a/mobile/README.md +++ b/mobile/README.md @@ -2,6 +2,18 @@ ## Prerequisites +### Go language + +- [Install](https://github.com/lightningnetwork/lnd/blob/master/docs/INSTALL.md#preliminaries-for-installing-from-source) `GO` language. +- Provide `$GOPATH` to `.zshrc` or `.bash_profile` files. + +```shell +export GOPATH=$HOME/go +export PATH=$PATH:$GOPATH/bin +``` + +Or any path you want it to be in. + ### Docker - Install and run [Docker](https://www.docker.com/products/docker-desktop). @@ -16,17 +28,21 @@ ### Go mobile -Install [gomobile](https://github.com/golang/go/wiki/Mobile) and initialize it: +- Install [gomobile](https://github.com/golang/go/wiki/Mobile): ```shell ⛰ go install golang.org/x/mobile/cmd/gomobile@latest -⛰ gomobile init +``` + +- Install `gobind` + +```shell +⛰ go install golang.org/x/mobile/cmd/gobind@latest ``` ## Building the libraries -Note that `gomobile` only supports building projects from `GOPATH` at this -point. So, before continuing, be sure to be in the `src` folder: +Note that `gomobile` only supports building projects from `GOPATH` at this point. So, before continuing, be sure to be in the `src` folder: ```shell ⛰ cd $GOPATH/src/github.com/lightningnetwork/lnd @@ -38,6 +54,26 @@ To checkout the latest tagged release of lnd, run ⛰ git checkout $(git describe --tags --abbrev=0) ``` +Or, the second option: just clone the project and checkout to any branch/tag (pay attention to the dot in the end). + +```shell +⛰ git clone https://github.com/lightningnetwork/lnd . +``` + +#### For Android: + +Move to the folder or create one: + +```shell +⛰ cd $GOPATH/src/golang.org/x +``` + +After that clone the goland mobile repo + +```shell +⛰ git clone https://github.com/golang/mobile +``` + ### Building `lnd` for iOS ```shell @@ -46,6 +82,8 @@ To checkout the latest tagged release of lnd, run ### Building `lnd` for Android +Go to `$GOPATH/src/github.com/lightningnetwork/lnd` and run the command below (make sure that the Docker engine is running): + ```shell ⛰ make android ``` @@ -114,22 +152,99 @@ to your project to support the generated code. ### Android +#### First option: + In order to generate protobuf definitions for Android, add `--java_out=.` to the first `protoc` invocation found in [ `gen_protos.sh` ](../lnrpc/gen_protos.sh). Then, run `make rpc`. + +#### Second option (preferable): + +- You have to install the profobuf plugin to your Android application. +Please, follow this link https://github.com/google/protobuf-gradle-plugin. +- Add this line to your `app build.gradle` file. +```shell +classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.17" +``` +- Create a `proto` folder under the `main` folder. + +![proto_folder](docs/proto_folder.png) + +- Add `aar` file to libs folder. + +- After that add these lines to your `module's` `build.gradle` file: + +```shell +plugins { + id "com.google.protobuf" +} + +android { + sourceSets { + main { + proto { + + } + } + } +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation "com.google.protobuf:protobuf-javalite:${rootProject.ext.javalite_version}" +} + +protobuf { + protoc { + artifact = "com.google.protobuf:protoc:${rootProject.ext.protoc_version}" + } + generateProtoTasks { + all().each { task -> + task.builtins { + java { + option "lite" + } + } + } + } +} +``` +- Then, copy all the proto files from `lnd/lnrpc` to your `proto` folder, saving the structure. +- Build the project and wait until you see the generated Java proto files in the `build` folder. + +#### Note: + +If Android Studio tells you that the `aar` file cannot be included into the `app-bundle`, this is a workaround: + +1. Create a separate gradle module +2. Remove everything from there and leave only `aar` and `build.gradle`. + +![separate_gradle_module](docs/separate_gradle_module.png) + +3. Gradle file should countain only these lines: + +```shell +configurations.maybeCreate("default") +artifacts.add("default", file('Lndmobile.aar')) +``` + +4. In `dependencies` add this line instead of depending on `libs` folder: +```shell +implementation project(":lndmobile", { "default" }) +``` + + ## Options -Similar to lnd, subservers can be conditionally compiled with the build by -setting the tags argument: +Similar to lnd, subservers can be conditionally compiled with the build by setting the tags argument: ```shell ⛰ make ios ``` -To support subservers that have APIs with name conflicts, pass the "prefix" -flag. This will add the subserver name as a prefix to each method name: +To support subservers that have APIs with name conflicts, pass the "prefix" flag. This will add the subserver name as a prefix to each method name: ```shell ⛰ make ios prefix=1 diff --git a/mobile/docs/proto_folder.png b/mobile/docs/proto_folder.png new file mode 100644 index 000000000..43f0e1570 Binary files /dev/null and b/mobile/docs/proto_folder.png differ diff --git a/mobile/docs/separate_gradle_module.png b/mobile/docs/separate_gradle_module.png new file mode 100644 index 000000000..cc884ee3b Binary files /dev/null and b/mobile/docs/separate_gradle_module.png differ