Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit 7c824c1

Browse files
committed
add so files to sample app and update docs to reflect issues with providing binaries remotely
1 parent 65ce563 commit 7c824c1

6 files changed

Lines changed: 27 additions & 21 deletions

File tree

docs/get_started.md

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Get Started
1111
- Download `geoip` and `geoip6` files from https://github.com/torproject/tor/tree/master/src/config
1212
- If you prefer the non-mirror repository, you can also obtain them from
1313
https://gitweb.torproject.org/tor.git/tree/src/config
14-
- In your Application module's `src/main` directory, create a new `Directory` named `assets`
14+
- In your Application module's `src/main/` directory, create a new `Directory` named `assets`
1515
- Copy `geoip` and `geoip6` files into the `assets` directory (or a subdirectory within
1616
`assets`, such as `assets/common/`. File extensions not necessary).
1717
- **torrc file**:
@@ -20,21 +20,30 @@ Get Started
2020
[TorServicePrefs](./topl-service/io.matthewnelson.topl_service.prefs/-tor-service-prefs/index.md).
2121
If nothing is in `TorServicePrefs` for that particular setting, then it will fall back on
2222
your static/default [TorSettings](./topl-core-base/io.matthewnelson.topl_core_base/-tor-settings/index.md)
23-
that you supply upon initialization of `TorServiceController.Builder`.
24-
- **Tor Binaries**:
25-
- I use The GuardianProject's <a href="https://github.com/guardianproject/tor-android" target="_blank">tor-android</a>
26-
project to build binaries, and provided them
27-
<a href="https://github.com/05nelsonm/TOPL-Android-TorBinary" target="_blank">here</a>. The
28-
difference is in how they are packaged as a dependency, and the contents of what you are
29-
importing as a dependency. I package them in the `jniLibs` directory so that the Android OS
30-
will automatically install them into your application's `/data/app/...` directory, and include
31-
no unnecessary classes or resources; just the binaries. Android API 29+ no longer supports
32-
execution of executable files from your application's `/data/data/` directory, and must now be
33-
installed in the `context.applicationInfo.nativeLibraryDir` directory (aka, `/data/app/...`)
34-
to execute.
35-
- Nothing more is needed in terms of configuring initialization via the
36-
`TorServiceController.Builder`, as files will be installed in the correct directory, and
37-
named to match what `topl-service` looks for.
23+
that you supply upon initialization of `TorServiceController.Builder`.
24+
- **Tor Binaries**:
25+
- For now, you'll have to copy the binaries into your application's `src/main/jniLibs/<abi>/`
26+
directory so that they are packaged in your APK **uncompressed** (which Android will automatically
27+
extract to your application's native directory on the device (`/data/app/<your app>/<abi>/libTor.so`))
28+
- Tor v0.4.3.5 binaries can be found in the `sampleapp` which you can copy over (for the
29+
time being).
30+
- I am currently building a gradle plugin to streamline binary distribution, so stay tuned!
31+
- The issue: Providing Tor Binaries packaged via an `aar` presents problems, as the
32+
binaries are compressed which results in the Android OS not extracting them automatically.
33+
This requires extraction of the Shared Native Library from the APK to be executed via
34+
inclusion of `extractNativeLibs="true"` in the app's Manifest (min API 23), or code to
35+
unzip the APK and extract the tor binaries to the application's native directory at runtime.
36+
There are many bugs/limitations across the various Android APIs (16-29) that makes this
37+
incredibly inefficient, not UX friendly for library users, error prone, and makes
38+
versioning somewhat complicated as devs have no control over the Android OS' symlink
39+
creation process. API 29 also presents problems with extracting the binaries
40+
to the application's `/data/data/` directory as it
41+
<a href="https://developer.android.com/about/versions/10/behavior-changes-10" target="_blank">
42+
no longer supports running of executables from that location</a>. Because of the plethora
43+
of issues across APIs, distribution of *.so files would be best done as a gradle plugin
44+
such that upon building of your application, the *.so files included in the plugin can be
45+
extracted to your application module's `src/main/jniLibs/<abi>/` directory. This ensures
46+
that when your application is built and zipaligned, everything will simply work.
3847
- If you wish to use GuardianProject's binaries, see
3948
<a href="https://github.com/guardianproject/tor-android" target="_blank">tor-android</a>.
4049
- You'll need to use their `NativeResouceInstaller` to install the binaries.
@@ -49,9 +58,8 @@ Get Started
4958

5059

5160
!!! Info
52-
Tor Binaries are ~8MB for each ABI (will be less after compression), so it's advised that builds
53-
are split to keep apk sizes down. For example, the `sampleapp`'s universalApk size (all ABIs)
54-
is ~16MB, where splits are ~7MB. See the `sampleapp`'s `build.gradle` file for more details.
61+
Tor Binaries are ~8MB for each ABI, so it's advised that builds are split to keep apk sizes
62+
down. See the `sampleapp`'s `build.gradle` file for more details.
5563
<a href="https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/sampleapp/build.gradle" target="_blank">here</a>
5664

5765
## Implementation - Step 2: topl-service

sampleapp/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ dependencies {
9393
implementation deps.kotlin.coroutinesAndroid
9494
implementation deps.kotlin.stdlib
9595

96-
implementation "io.matthewnelson.topl-android:tor-binary:0.4.3.5a"
97-
9896
testImplementation deps.junit
9997

10098
androidTestImplementation deps.androidx.test.core
8.38 MB
Binary file not shown.
8.43 MB
Binary file not shown.
9.29 MB
Binary file not shown.
8.68 MB
Binary file not shown.

0 commit comments

Comments
 (0)