-1

I know this question was asked before but I tried all existing solutions and none of them solved the issue.

I am trying to create a simple hello world native app (binary not apk) but I keep getting this error message when I try to compile using "ndk-build"

Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := main.out
LOCAL_SRC_FILES := main.cpp
include $(BUILD_EXECUTABLE)

Application.mk

APP_ABI := x86
APP_PLATFORM := android-25
APP_STL := stlport_static
APP_BUILD_SCRIPT := Android.mk

main.cpp

#include <iostream.h>

main()
{
    std::cout << "Hello World!";
    return 0;
}

here is the structure for my folder

.
└── jni
    ├── Android.mk
    ├── Application.mk
    └── main.cpp
jww
  • 97,681
  • 90
  • 411
  • 885
DigitalPerson
  • 191
  • 3
  • 12
  • Possible duplicate of [Android NDK: Your APP\_BUILD\_SCRIPT points to an unknown file](https://stackoverflow.com/q/6494567/608639) – jww Aug 26 '18 at 03:14

1 Answers1

0

In this case setting APP_BUILD_SCRIPT shouldn't be necessary since you seem to be using the default name and location.

But let's say your Android.mk was named foo.mk. The thing about APP_BUILD_SCRIPT is that "The build system always interprets a non-absolute path as relative to the NDK's top-level directory".

So you'll probably want to specify an absolute path, but preferably not an entirely hardcoded one since that will complicate things if you move things around on your computer or try to move the project to a different computer.

You can solve this in the following way:

MY_APP_DIR := $(call my-dir)
APP_BUILD_SCRIPT := $(MY_APP_DIR)/foo.mk
Michael
  • 57,169
  • 9
  • 80
  • 125
  • What file is this added to: `APP_BUILD_SCRIPT := $(MY_APP_DIR)/foo.mk`? – jww Aug 26 '18 at 03:08
  • @jww: Application.mk – Michael Aug 26 '18 at 07:43
  • *"The build system always interprets a non-absolute path as relative to the NDK's top-level directory"* – I believe this is a mistake in the doc. Actually, **APP_BUILD_SCRIPT** is interpreted relative to the **$PWD** (in Windows, **%CD%**). It's true that often we run **ndk-build** from the directory above **jni**, but there is no such ***rule***. E.g. all would work well for the TS, if they only run **ndk-build -C jni**. – Alex Cohn Aug 26 '18 at 08:45