1
0
mirror of https://github.com/PurpleI2P/i2pd_docs_en synced 2025-01-12 16:07:51 +00:00
i2pd_docs_en/docs/devs/building/android.md

95 lines
2.6 KiB
Markdown
Raw Normal View History

2017-01-25 19:20:49 +00:00
Building on Android
===================
### Note: *Build works ONLY on Linux systems. Current documentation shows how to build application on Ubuntu 18.04*
2017-01-25 19:20:49 +00:00
2017-08-09 19:49:53 +00:00
Pre-requisites
2017-01-25 19:20:49 +00:00
--------------
You need to install `rename` (required for building libraries), `OpenJDK` 11+, `gradle` 5.1+ and `Android SDK`.
2017-01-25 19:20:49 +00:00
```
sudo apt-get install g++ rename openjdk-11-jdk gradle
```
2017-01-25 19:20:49 +00:00
- Android [SDK](https://developer.android.com/studio#downloads) (choose command line tools only)
- If your system provides gradle with version < 5.1, download it from [Gradle](https://gradle.org/install/) homepage
2017-01-25 19:20:49 +00:00
Dependencies
2018-06-16 08:45:30 +00:00
------------
2017-01-25 19:20:49 +00:00
Prepare Android SDK and install required packages
2017-01-25 19:20:49 +00:00
```bash
mkdir /tmp/android-sdk
cd /tmp/android-sdk
wget <latest SDK link>
unzip commandlinetools-linux-*_latest.zip
# install required tools
./cmdline-tools/bin/sdkmanager --sdk_root=/opt/android-sdk "build-tools;31.0.0" "cmake;3.18.1" "ndk;21.4.7075529"
```
2017-01-25 19:20:49 +00:00
Clone repository with submodules
```bash
git clone --recurse-submodules https://github.com/PurpleI2P/i2pd-android.git
```
Compile required libraries
2018-06-16 08:45:30 +00:00
```bash
export ANDROID_SDK_ROOT=/opt/android-sdk
export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/21.4.7075529
2018-06-16 08:45:30 +00:00
pushd app/jni
./build_boost.sh
./build_openssl.sh
./build_miniupnpc.sh
popd
```
2017-01-25 19:20:49 +00:00
Building Android application
--------
2017-01-25 19:20:49 +00:00
### Build application
2017-01-25 19:20:49 +00:00
- Create `local.properties` file with path to SDK and NDK
2022-05-12 17:18:48 +00:00
```
sdk.dir=/opt/android-sdk
ndk.dir=/opt/android-sdk/ndk/21.4.7075529
```
2022-05-12 17:18:48 +00:00
- Run `gradle clean assembleDebug`
- You will find an .apk file in `app/build/outputs/apk` folder
2017-01-25 19:20:49 +00:00
### Creating release .apk
2017-01-25 19:20:49 +00:00
2021-11-03 18:51:35 +00:00
In order to create release .apk you must obtain a Java keystore file(.jks). Either you have in already, or you can generate it yourself using keytool, or from one of you existing well-known certificates.
For example, i2pd release are signed with this [certificate](https://raw.githubusercontent.com/PurpleI2P/i2pd/9000b3df4edcbe7f2c8afd0e1e30609746311ace/contrib/certificates/router/orignal_at_mail.i2p.crt).
Change file `app\build.gradle` by replacing pre-defined values with your own
```
release {
storeFile file("i2pdapk.jks")
storePassword "android"
keyAlias "i2pdapk"
keyPassword "android"
}
2018-06-16 08:45:30 +00:00
```
Run `gradle clean assembleRelease`
2018-06-16 08:45:30 +00:00
Building executable binary
2018-06-16 08:45:30 +00:00
------------------------------
- Set environment variables:
2022-05-12 17:18:48 +00:00
```
export ANDROID_SDK_ROOT=/opt/android-sdk
export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/21.4.7075529
```
2022-05-12 17:18:48 +00:00
- Run `$ANDROID_NDK_HOME/ndk-build -j <threads> NDK_MODULE_PATH=$PWD` from `binary/jni` folder
2022-05-12 17:14:45 +00:00
- You will find an `i2pd` executable in `binary/libs/<architecture>` folder