Skip to content

Error "NoPlatformFound" has poor description #62

@hut

Description

@hut

Hi, I just spent >1 hours debugging why cargo apk run tells me "Error: Android SDK has no platforms installed.", even though I had a platform installed.

Finally I found out that this is because of the final filter in the code of ndk.rs:

        let platforms: Vec<u32> = std::fs::read_dir(&platforms_dir)
            .or(Err(NdkError::PathNotFound(platforms_dir)))?
            .filter_map(|path| path.ok())
            .filter(|path| path.path().is_dir())
            .filter_map(|path| path.file_name().into_string().ok())
            .filter_map(|name| {
                name.strip_prefix("android-")
                    .and_then(|api| api.parse::<u32>().ok())
            })
            .filter(|level| (min_platform_level..=max_platform_level).contains(level))
            .collect();

My platform version was simply outside of the range min_platform_level..=max_platform_level. So the problem was not that it has "no platforms installed", but that the installed platform version is incompatible.

Would it be possible to adjust the error message? If you wish, I can make a PR.

P.S. i see that this tool is deprecated. feel free to close the PR without any action then

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions