user9841612
user9841612

Reputation: 13

Windows user trying to build Android NDK project built for Linux

I'm in the process of building an Android NDK project. I'm running into issues where I'm getting the following error when building the project:

Process 'command 'C:\Users\my-user\AppData\Local\Android\Sdk\ndk-bundle/ndk-build.cmd'' finished with exit value 2 (state: FAILED)

I know which task is causing it, but as it turns out, it looks like it might be failing because the .mk and .sh scripts were written for Linux, whereas I'm a Windows user.

So I've been going through each .mk and .sh file and converting it to run on Windows, e.g.:

Changing lines like:

SOME_PROJECT_DIRECTORY := $(shell cd $(LOCAL_PATH)/build;pwd)

To:

RMSDK_HOME := $(LOCAL_PATH)/build

However, I'm getting stuck on lines like this:

SHELL_RESULT := $(shell $(SOME_PROJECT_DIRECTORY)/android/MyShellScript.sh $(SOME_PROJECT_DIRECTORY))

Where the shell script is:

#!/bin/bash
if [ -n "$1" ]
then
MY_DIRECTORY=$1
else

... etc ...

Of course, you can't run .sh scripts on Windows, which would mean I would normally have to manually rewrite these scripts into batch files or something that Windows can read. But I'm wondering if there's any way to build this project without having to make any changes to the files? i.e. is there a way to build these files, written for Linux, for Windows?

Upvotes: 0

Views: 858

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57163

Your best friend is the WSL. On Windows 10, you get a native language Linux shell. You use the Linux (x86_64) version of NDK, and everything just works. It may be tricky to integrate this into Android Studio, but anyway you usually prefer to use prebuilt libraries for 3rd party components.

If you have git on your machine, you have the git bash shell. It may be worth trying to build your project from that shell.

Upvotes: 2

Related Questions