how to set paths to Android.mk and Application.mk files

Hi, I am trying to build Android NDK project with Tegra VisualStudio AndroidWorks. Previously I’ve built the project with AndroidStudio using Android.mk and Application.mk scripts

Where in Settings should I put links to these Android.mk and Application.mk files to build the project with Tegra for VS?

You can set NDK project Path, Project property>NDK Build>Genernal>NDK Project Path.at where ndk-build would find *.mk.

Victor

Sorry, but I can’t find this path. Please see my Project’s properties tabs.

and second question: am I right that I don’t have to explicitly indicate any paths for locations of c/c++ sources and .so libraries if these files are already were placed within directory with code, I have imported my project from?


Hi Nikolay,
from your the picture, You don’t use template Import an ndk-build Android Project
What I said is for this kind of projects.
External Media.

If you just use a normal Nsight Tegra project, which uses MSBuild instead of make, there is no need to set *.mk.

Victor

Hi, as I understand I cannot change template of existing project, right?

So I created / imported new android NDK project from existing sources

Now I get the following error: “ndk-build.cmd” exited with code 2

The trace is:

Severity Code Description Project File Line Suppression State
Error MSB6006 “ndk-build.cmd” exited with code 2. AndroidNDK C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Tegra-Android\Nvidia.Utility.targets 57

How can I fix that?

the screenshots for all steps done attached






Could you send me the build log and Nsight Tegra log.
Build log: you can set Level to Diagnostic via Tools>options>Projects and Solutions>Build and Run
Nsight Tegra log: you can find it at %APPDATA%\NVIDIA Corporation\Nsight Tegra\Logs

Victor

Hi, I set log level to Detailed. Here is error listing in log file (attached)

2017-03-05 23:42:34.6481|ERROR|Nvidia.PentaK.SolutionManager|Failed to failed solution platforms: Empty path name is not legal.
System.ArgumentException: Empty path name is not legal.
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Nvidia.PentaK.Tools.MSBuild.SolutionFile..ctor(String filepath)
   at Nvidia.PentaK.SolutionManager.<>c__DisplayClass4_0.<.ctor>b__0()

Please make sure I 'm using Gradle not Ant

By the way, what is the difference of using MSBuild vs. make? What should I changed in project to use that? Remove Android.mk file and МЫ will build all automatically using just Gradle scripts?

Nsight Tegra.log (2.3 KB)

Please make sure I 'm using Gradle not Ant
You can use set Android Build system via Project Properties>Configuration Properties>General>Project Defaults>Android Build System.

what is the difference of using MSBuild vs. make?
Night Tegra adapt MSBuild to native code build, MSBuild has good integration with VS IDE, you can change build options at Project Properties.
Android NDK use make as it’s default build system.
They are two independent build system.

What should I changed in project to use that?
You can see the change native build system at Project Properties>Configuration Properties>General>Project Defaults>Configuration Type:
NDK-Build: use make (NDK default way)
External Build: user defined way
Others: Night Tegra’s own build system based on MSBuild.

Remove Android.mk file and МЫ will build all automatically using just Gradle scripts?
There is no magic water, all depends on your configuration. there is no need to Remove android.mk.

victor

So what about my error and log file I’ve sent.

It looks that the NdkProjectPath is not correct, but I am sure I indicated a full absolute path to the directory where Android.mk is located (see screenshot).

C:\Users\User\Git\android\androidNDK\app\src\main\cpp

What is wrong?

From your log, It complains that Empty path name is not legal.
Would you share us a repro sample project to figure out what’s wrong?

Victor

Hi, the migrating project is large enough, so it’s not possible to share in full. I can share *.sln and *.vcxproj files if it can help? I suggest I could remotely share my PC screen to you at any time just text me at skype-nilyin

I have also added some debug code to add-application.mk and run ndk-build in the directory, which I specified as NDK Project Path:

C:\Users\User\Git\android\AndroidNDK\app\src\main\cpp>ndk-build
Invalid attribute value syntax for android:configchanges: =
“keyboard|keyboardHidden|screenLayout|screenSize|orientation”
android:theme=“@android:style/Theme.Translucent.NoTitleBar”
android:label=“@string/app_name” /
Android NDK: APP_BUILD_SCRIPT: C:/Users/User/Git/android/AndroidNDK/app/src/main/jni/Android.mk
Android NDK: APP_PROJECT_PATH: C:/Users/User/Git/android/AndroidNDK/app/src/main
Android NDK: app build script to search .mk file: C:/Users/User/Git/android/AndroidNDK/app/src/main/jni/Android.mk
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: C:/Users/User/Git/android/AndroidNDK/app/src/main/jni/Android.mk
C:/NVPACK/android-ndk-r12b/build//…/build/core/add-application.mk:208: *** Android NDK: Aborting… . Stop.

C:\Users\User\Git\android\AndroidNDK\app\src\main\cpp>dir

Directory of C:\Users\User\Git\android\AndroidNDK\app\src\main\cpp

12.01.2017 10:27 .
12.01.2017 10:27 …
12.01.2017 10:27 3,413 Android.mk
08.03.2017 22:19 184 Application.mk

C:\Users\User\Git\android\AndroidNDK\app\src\main\cpp>

so, it looks ndk_build file cannot read Application.mk, which contains:

LOCAL_PATH:= $(call my-dir)
APP_BUILD_SCRIPT := $(LOCAL_PATH)/Android.mk

NDK_TOOLCHAIN_VERSION := 4.9
APP_STL := gnustl_static
APP_CPPFLAGS += -std=c++11
APP_ABI :=armeabi-v7a

So:

why project path is different from what I have set in IDE?
why even if I run ndk-build in cli in the correct folder it doesn’t take settings from Application.mk

No need a full project, just the project file and a few source code that could repro this issue is enough.

why project path is different from what I have set in IDE?
from your attachment pic they are the same C:\Users\User\Git\android\AndroidNDK\app\src\main\cpp.

why even if I run ndk-build in cli in the correct folder it doesn’t take settings from Application.mk?
It seems ndk-build assume Android.mk in /Jni. and there is another invalid attribute value.

Invalid attribute value syntax for android:configchanges: =
“keyboard|keyboardHidden|screenLayout|screenSize|orientation”
android:theme=“@android:style/Theme.Translucent.NoTitleBar”
android:label=“@string/app_name” /
Android NDK: APP_BUILD_SCRIPT: C:/Users/User/Git/android/AndroidNDK/app/src/main/jni/Android.mk
Android NDK: APP_PROJECT_PATH: C:/Users/User/Git/android/AndroidNDK/app/src/main
Android NDK: app build script to search .mk file: C:/Users/User/Git/android/AndroidNDK/app/src/main/jni/Android.mk
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: C:/Users/User/Git/android/AndroidNDK/app/src/main/jni/Android.mk
C:/NVPACK/android-ndk-r12b/build//…/build/core/add-application.mk:208: *** Android NDK: Aborting… . Stop.

Hi, attached is visual studio solution / project files and archive with source code directories structure

Waiting for your advice for a fix.
AndroidNDK.zip (4.19 MB)
AndroidNDK_code_folders.zip (13.5 MB)

From your project file and *.mk file, The migrating project is large and has its own some customization building steps.

The better way is to use External build system with it’s existed build system, not to create the Nsight Tegra MSBuild config for each lib and sub-project.

You can add External build system config, write dos batch file to trigger its own build system and then add dos batch file to Build and Rebuild cmd line at Configuration properties>NMake Page.

You can use Nsight Tegra for debugging by set the Configuration Properties>Debugging.

  1. Override APK path
    2 Additional C/C++ source directories
  2. Additional library symbols Directories.

victor

How can I indicate customized build script path (where Android.mk is located) and path to Application.mk with Nsight Tegra VS edition?

You can use VS MACRO such as $(SolutionDir) where *.sln is in.

victor