diff --git a/README.md b/README.md index b6df0f7..5a46a60 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/xbuild/src/gradle/mod.rs b/xbuild/src/gradle/mod.rs index 3595533..bcbf817 100644 --- a/xbuild/src/gradle/mod.rs +++ b/xbuild/src/gradle/mod.rs @@ -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; @@ -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(); diff --git a/xbuild/src/gradle/settings.gradle b/xbuild/src/gradle/settings.gradle index 9f5af3e..f60920c 100644 --- a/xbuild/src/gradle/settings.gradle +++ b/xbuild/src/gradle/settings.gradle @@ -14,4 +14,3 @@ dependencyResolutionManagement { } include ':app' -include ':baseAssets'