我正在 Rust 中使用 Tauri v2 编写一个 Android 应用程序。当我执行“bun run tauri android dev”时,应用程序在我的手机上完美运行,但是当我将其传递给生产“bun run tauri android build”时,它会生成 apk“app-universal-release-unsigned.apk”,但是当我尝试在移动设备上安装它,我收到一条错误消息:“软件包信息为空”,并且不允许您安装它。有谁知道它可能是什么?
我附上了我的“lib.rs”代码块和“tauri.conf.json”文件:
{
"productName": "beta",
"version": "0.1.0",
"identifier": "com.tauri.build",
"build": {
"beforeDevCommand": "bun run dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "bun run build",
"frontendDist": "../dist"
},
"app": {"windows": [
{
"title": "beta",
"width": 800,
"height": 600
}
],
"security": {
"assetProtocol": {
"enable": false,
"scope": []
},
"dangerousDisableAssetCspModification": false,
"freezePrototype": false,
"pattern": {
"use": "brownfield"
}
}
},
"bundle": {
"active": false,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/[email protected]",
"icons/icon.icns",
"icons/icon.ico"
],
"android": {
"minSdkVersion": 24
},
"category": "Sports",
"shortDescription": "A simple app to test the beta version of Tauri"
}
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let package_info = PackageInfo {
name: "beta".to_string(),
version: Version::new(2, 1, 1),
authors: "author",
description: "description",
crate_name: "beta",
};
let mut context = tauri::generate_context!();
let info = context.package_info_mut();
info.name = package_info.name;
info.authors = package_info.authors;
info.description = package_info.description;
info.version = package_info.version;
info.crate_name = package_info.crate_name;
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![start, stop, greet, print_files, manually])
.run(context)
.expect("error while running tauri application");
}
使用 tauri rust 进行生产构建 apk 时是否缺少一些代码行?
您应该能够使用以下方式在发布模式下构建适用于 Android 的 Tauri(beta 2.x)应用程序:
npm tauri android build
对于按键配置,我知道最近的测试版中有一些更改,但最新的文档位于here。这可能是未来版本中可能会发生变化的主题。与 API 相同,从
alpha
更改为 beta
。