Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
xbuild is a build tool for rust projects with support for cross compiling and publishing to all
major stores. The goal of xbuild is making native app development as easy as web development.

To configure the build of the packages for the platforms a `manifest.yaml` file must be created in the working directory. To configure for an android apk check all options of `AndroidManifest` struct (https://github.com/rust-mobile/xbuild/blob/master/apk/src/manifest.rs#L8).

To set internet permissions for android for example:
```yaml
android:
manifest:
sdk:
min_sdk_version: 23
target_sdk_version: 36
# See https://developer.android.com/guide/topics/manifest/uses-permission-element
uses_permission:
- name: "android.permission.INTERNET"
- name: "android.permission.ACCESS_NETWORK_STATE"
```

## Getting started
Install `xbuild`:
```sh
Expand Down Expand Up @@ -30,6 +45,20 @@ info: component 'rust-std' for target 'aarch64-linux-android' is up to date

![x](https://user-images.githubusercontent.com/741807/162616805-30b48faa-84f0-4fec-851a-4c94fd35c6bd.png)

### Version compatibility (Android gradle)

When using gradle with android make sure you have the correct versions installed (https://kotlinlang.org/docs/gradle-configure-project.html#kotlin-gradle-plugin-data-in-a-project)

Tested:

| Software | Version |
| ------------- | ---------- |
| java | 17 |
| Gradle | 8.1.1 |
| AGP Plugin | 7.3.0 |
| Kotlin Plugin | 1.7.20 |


## Troubleshooting

### Command not found
Expand Down
5 changes: 5 additions & 0 deletions xbuild/src/gradle/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{task, BuildEnv, Format, Opt};
use anyhow::{Context, Result};
use apk::Target;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;

Expand Down Expand Up @@ -49,6 +50,10 @@ pub fn build(env: &BuildEnv, libraries: Vec<(Target, PathBuf)>, out: &Path) -> R
let config = env.config().android();
let mut manifest = config.manifest.clone();

if !config.assets.is_empty() {
std::fs::OpenOptions::new().write(true).append(true).open(gradle.join("settings.gradle"))?.write(r#"include ':baseAssets'"#.as_bytes())?;
}

let package = manifest.package.take().unwrap_or_default();
let target_sdk = manifest.sdk.target_sdk_version.take().unwrap();
let min_sdk = manifest.sdk.min_sdk_version.take().unwrap();
Expand Down
1 change: 0 additions & 1 deletion xbuild/src/gradle/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ dependencyResolutionManagement {
}

include ':app'
include ':baseAssets'
Loading