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
2 changes: 1 addition & 1 deletion xbuild/src/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Cargo {
.map(|path| {
if path.file_name() != Some(OsStr::new("Cargo.toml")) || !path.is_file() {
Err(anyhow::anyhow!(
"The manifest-path must be a path to a Cargo.toml file"
"The manifest-path {:?} must be a path to a Cargo.toml file including 'Cargo.toml'", path
))
} else {
Ok(path)
Expand Down
3 changes: 3 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 @@ -102,6 +103,8 @@ pub fn build(env: &BuildEnv, libraries: Vec<(Target, PathBuf)>, out: &Path) -> R
let _ = std::fs::remove_dir_all(&base_assets);

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

@Murmele Murmele Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarijnS95 I have to delete the baseAssets include from settings.grade and adding it if assets are present, otherwise I get a gradle error

Could not open cp_settings generic class cache for settings file '/target/x/release/android/gradle/settings.gradle' (~/.gradle/caches/8.1.1/scripts/d5f98u8ma4q13uozubkfsaw6z).

BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 65


std::fs::create_dir_all(&base_assets)?;
let assets = format!(
r#"
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