tauri-apps / tauri-apps/plugins-workspace
[Question] Hi, I have a problem about using shell-execute to run aapt2
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
### Describe the bug
First. I write a tauri-app with the newer version that is **V2.0.** I have a required that I want to use shell, and use shell to exec the android-sdk's aapt2. But, I had configed the shell's permissions. It still report an error.
This is my permissions configurations:
```code
"shell:default",
{
"identifier": "shell:allow-execute",
"allow": [
{
"name": "aapt2",
"cmd": "aapt2",
"args": [
"dump",
"badging",
{
"validator": ".+"
}
]
},
..... //other configurations
````
This is my code:
```code
static async readApkInfo(apkPath) {
try {
console.log(`读取apk信息中,apk路径:${apkPath}`)
const cmd = Command.create(
"aapt2",
["dump", "badging", apkPath],
{cwd: '/Users/USERNAME/Library/Android/sdk/build-tools/35.0.0'});
cmd.stdout.on("data", (data) => {
console.log(`读取apk信息中,输出:${data}`)
})
cmd.stderr.on("data", (data) => {
console.log(`读取apk信息中,错误:${data}`)
})
const process = await cmd.execute();
if (process.code === 0) {
const output = process.stdout;
console.log(`读取apk信息成功,输出:${output}`)
// TODO: 解析输出信息,提取应用名称、版本号等信息
return output;
} else {
console.log(`读取apk信息失败,错误:${process.stderr}`)
}
} catch (error) {
console.log(`读取apk信息失败,错误:${error}`)
}
}
```
Run these code, it throw an error that is "No such file or directory (os error 2)".
I think that the shell cannot find the aapt2 file.
Can you tell me how to resolve the problem. If I want to run the aapt2, what should I do?
### Reproduction
_No response_
### Expected behavior
_No response_
### Full `tauri info` output
```text
No such file or directory (os error 2)
```
### Stack trace
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.