Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Hi, I have a problem about using shell-execute to run aapt2 #2276

Open
YugeCse opened this issue Jan 7, 2025 · 0 comments
Open
Labels
plugin: shell question Further information is requested

Comments

@YugeCse
Copy link

YugeCse commented Jan 7, 2025

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:

 "shell:default",
        {
            "identifier": "shell:allow-execute",
            "allow": [
                {
                    "name": "aapt2",
                    "cmd": "aapt2",
                    "args": [
                        "dump",
                        "badging",
                        {
                            "validator": ".+"
                        }
                    ]
                },
..... //other configurations

This is my 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

No such file or directory (os error 2)

Stack trace

No response

Additional context

No response

@FabianLars FabianLars transferred this issue from tauri-apps/tauri Jan 7, 2025
@FabianLars FabianLars added question Further information is requested plugin: shell labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: shell question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants