build-local.mk: No such file or directory - android

Please help, I have a very wierd error here, while I trying to compile project. Console says:
03:17:23 ** Auto Build of configuration Default for project
MyProject * bash ndk-build all make.exe:
C:\workspace/MyProject/build/core/build-local.mk: No such file or
directory make.exe: ** No rule to make target
`C:\workspace/MyProject/build/core/build-local.mk'. Stop.
03:17:24 Build Finished (took 654ms)
So I'm trying compile code from book "Android NDK for Beginnners". First of all, an author telling to convert java project to C++ project. Once I did it - an error appears. To fix it I need to build library with ndk-build , an autor offers to make changes in project properties, exactly go to Builders and change default build command to ndk-build, but thats woun't work without bash word before it. So when I figured that out and tried to build the project - an error occures.
Help please, I can' find the solution.

Your book is probably outdated, or it does not address Windows environment. On Windows, instead of ndk-build command or bash ndk-build, use ndk-build.cmd. Download and ise the latest version of NDK.

Related

ndk-build.cmd isn't recognized as internal or external command

I'm working on OpenCV library in android studio.I'm using 2.2.1 version of android studio. Problem is that when I run ndk-build.cmd on command prompt, debugger shows that it is not recognised command,operable program or batch file.
when I build my project it gives error, that is:
" Error:(120) *** Android NDK: Aborting. Stop."
I also have tried to build project without importing OpenCV library as I was following a tutorial, but it also give error.
"Error:Execution failed for task ':app:compileDebugNdk'.
Error: Your project contains C++ files but it is not using a supported native build system.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
http://tools.android.com/tech-docs/new-build-system/gradle-experimental."
Even I download CMake and NDK tools but still this error exists. Please guide me to solve this problem.
Thanks in advance.
To run ndk-build
1)you have to add its path in your Enviroment Variable so yo can access it from anywhere with just "ndk-build.cmd"
or
2) you have to give full ndk path like E:\sdk\ndk-bundle\ndk-build.cmd if you have windows
To run ndk-build from command prompt, you can provide the full path to the script, e.g.
C:\> d:\android\ndk\ndk-build.cmd
It is important to install ndk to a directory with no spaces in its full path, e.g.
d:\android SDK\ndk r13
won't work. Avoid spaces in the path to your project, too. Android Studio will not be happy to build
e:\my projects\android apps\ndk sample\build\outputs\apk\my first ndk app.apk

Android Studio, CMake. How to print debug message in compile time?

I'm using Android Studio 2.3 beta 3. I put message(AUTHOR_WARNING "Hello CMake, hello Android") In my CMakeLists.txt
But I saw this message only few times when rebuilding project in Android Studio. In most cases there's no "Hello CMake, hello Android" string in Gradle Console after build finishes. I've tried resync gradle and clean/rebuild project, still no expected output.
I have some problems with my build (I think it's incorrect paths) so my goal - to print CMake variables in compile time to better understand what is actually going on.
Inside the project tree, you can find the log with all the cmake output inside the folder of each generated architecture. The relative path to the file should be something like:
[project folder]/app/.externalNativeBuild/cmake/debug/arm64-v8a/cmake_build_output.txt
Here you can see all the MESSAGE calls of the cmake scripts.
my android studio cmake output:
compile detail:
.cxx/cmake/debug/arm64-v8a/compile_commands.json
cmake output:
.cxx/cmake/debug/arm64-v8a/build_output.txt
CMake messages are only at generation time (when CMake is used to generate your project / Makefile).
One way to get CMake to generate is to go to retrieve the build folder and the CMakeCache.txt file in it, and then:
Retrieve the path to your cmake executable, by reading the CMakeCache.txt file and checking the value of the CMAKE_COMMAND variable
Open a command prompt in CMakeCache.txt directory
Run: <path_to_cmake_found_at_point_1> .
Note: The build folder should have a CMakeCache.txt file. The above will not work unless it does.
On my rig I found the logs in <module name>/build/intermediates/cxx/<cmake build type>/<hash>/meta/<ABI>/cmake_server_log.txt -- C++ programming for Android just keeps getting more convenient all the time :\
My rig:
Android Studio Arctic Fox 2020.3.1 Patch 3
AGP 7.0.2
Gradle 7.2.0
NDK 21.4.7075529
CMake 3.10.2
Windows 10 (hopefully host OS doesn't matter)

Adding android library project to an android project prevents Ant from building

I'm adding an android library project to my android app (in this case, Beintoo). It's not mine; It's an external library. However, it doesn't come with a build.xml. Building in Eclipse works fine, but when I attempt to build my app with ant, I get this:
BUILD FAILED
C:\Sandbox\MyProject\build.xml:110: The following error occurred while executing this line:
C:\Sandbox\MyProject\build.xml:41: The following error occurred while executing this line:
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:515: Invalid file: C:\Git\Beintoo-Android\beintoo-android-sdk\BeintooSDK\build.xml
It's perfectly true. The file is invalid, because it doesn't exist. I wouldn't know what to do to add it safely, nor if that's even a good idea.
I have learnt that I can't simply build the library project into a jar. How can I get my project to build in Ant with this library project?
Ok, so, Error 454's answer was close, but not quite right. Since r14 of Android Tools, every library project must have it's own build.xml if it is to be built by Ant, as noted here:
https://groups.google.com/forum/?fromgroups#!topic/adt-dev/Z2e3dY-3Ma0
Running android update lib-project (which, as Error 454 notes, is in the android-sdk/tools folder which should be in PATH) on the library project will add a generic build.xml, and allow the main project to build.
For library projects, you need to browse to the library project root and run:
android update lib-project -p .
The android executable is in the android sdk/tools folder which should be added to your path variable in your OS. Once you run this, the necessary build files will be generated and your ant build should succeed.
Similarly, if your root project doesn't have the necessary build files, you will need to browse to the main project root and run:
android update project -p .
Additionally to the two previous correct answers I had to add --target android-16 because I was getting an "Error: The project either has no target set or the target is invalid."
So in my case
android update lib-project -p . --target android-16
Did it. (replace the 16 as you need)

Android NDK in Eclipse :: (Cannot run program "ndk-build": Unknown reason)

I am loosing my mind trying to build my NDK project from eclipse using the CDT plugin and i get the error:-
NDK (Cannot run program "ndk-build": Unknown reason)
The application runs but i loose all of the console output for the build process, this is a nightmare when trying to compile and i have to do it on the command line.
This is how i got there:-
I Downloaded and installed the CDT plugin for Eclipse.
Then:
Added my JNI folder and also your Android.mk in the JNI directory.
Then:
Go FILE / NEW / OTHER /C/C++ / ( Convert to a C/C++ Project )
On setting up my build target:
Check the project, choose MakeFile Project and Other Toolchain click NEXT
Then finally in project properties:
PROJECT / PROPERTIES / C/C++ uncheck " use default build command" replace "make" with "ndk-build"
Then when it builds it spits the error to the console. Though it compiles and makes the build which runs on the device i cant see any of the build output.
I have "ndk-build' in my .bash_profile with the following variables:
:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools:$ANDROID_NDK
I can compile using ndk-build from command line fine. It seems that Eclipse cant see my PATH:
This is on Mac OSX, in Helios version 2.
EDIT: Ok so this compiles fine, and the output from the build is infact hidden underneath this message, this is far from ideal, as when i need to review what items have been built i cant as its covered up. How do i get rid of it?
In my case, I had to give complete path to my ndk-build command in eclipse in order for it to build:
Eclipse -> Your Prj -> Right Click -> C/C++ Build -> "Builder" group: the value for "Build command" should be complete path something like below (instead of just "ndk-build")
/Users/vshakya/MySoftware/android-ndk-r8/ndk-build
I hope this will help others in future for I just wasted like 30 minutes to figure this out.
It might seem stupid but have you check if there are several consoles ? I can imagine there is one for the message you quoted, and another for build output.
See also this : the answer has an interesting link, dealing with setup but also related to eclipse integration.
I had the same problem and although the description at http://developer.android.com/tools/sdk/ndk/index.html#Installing for installing the NDK is good, it does not cover the solution to this frequent problem.
Eclipse seems to allow you to configure stuff in multiple places, you can do global modifications via Window menu or project specific configurations via the Properties option. Simplest is to add full path for ndk-build (ndk-build.cmd for windows) in the {Properties; C/C++ Build} Build command box.
The easier solution, build with the command ndk-build from eclipse project path:
$PROJECT>ndk-build
Everytime you change your native code.
To compile on eclipse, i followed the next steps:
Create the eclipse project.
Add the native code (.cpp) at jni folder
Create Android.mk and Application.mk following the typically structure
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $$Add source files$$
LOCAL_LDLIBS := -lpcap
LOCAL_MODULE := libtest
LOCAL_C_INCLUDES := $$Path of the header files used$$
include $(BUILD_SHARED_LIBRARY)
----------------
Aplication.mk depends that the type of options you want
When eclipse throw warnings, put your mouse on jni code part, and check the option: "convert project to native code", and will convert the project automatically.
Next time you compile, ndk-build V=1 will be called, compiling native code, and then, compile Android part.
NOTE:
You must be able to use ndk-build in all folder on your system. The command detect where has been called, and look for the jni folder, to use the Android.mk to compile all native code.
The basic structure that look for is:
$PROJECT>jni/
/Android.mk
/Application.mk
/code.cpp
But you can modify Android.mk to look for code in other paths.
I hope it help you!
Sequoya is your friend. It is a part of Eclipse since Indigo release.
http://www.eclipse.org/sequoyah/
In my case, I had to give complete path to my ndk-build.cmd command in eclipse in order for it to build:
Eclipse -> Your Prj -> Right Click -> C/C++ Build
C:\Prateek\android-ndk-r9\ndk-build.cmd
Just in case you are somehow only seeing your stdout and not stderr, try redirecting your stderr to stdout.
ndk-build 2>&1
make sure to use "absolutepath\ndk-build.cmd" instead "absolutepath\ndk-build" in windows.
It compiles without error with .cmd added
In addition to system environment.
In Eclipse, You also need to go to preferences->c/c++ Build -> environment. Add a new variable with the name "NDKROOT" and value set to the NDK installation path.
This works for me.

Android NDK: ndk-build script fails - script "check-cygwin-make.mk" not found

I'm new to development with the NDK of Android.
As I'm developing on Win7 I installed Cygwin in order to build the native binaries.
When running ndk-build from the project folder /home/simon/ndk/hello-neon I get the error
ERROR: You are using a non-Cygwin compatible Make program.
Currently using: C:/Programs/cygwin/bin/make
To solve the issue, follow these steps:
1. Ensure that the Cygwin 'make' package is installed.
NOTE: You will need GNU Make 3.81 or later!
2. Define the GNUMAKE environment variable to point to it, as in:
export GNUMAKE=/usr/bin/make
3. Call 'ndk-build' again.
The problem that stops me now is that the ndk-build script seems not to be able to call the check-cygwin-make.mk script in the following lines:
GNUMAKE=`cygpath -u $GNUMAKE`
PROGDIR_MIXED=`cygpath -m $PROGDIR`
CYGWIN_GNUMAKE=`$GNUMAKE -f "$PROGDIR_MIXED/build/core/check-cygwin-make.mk" 2>&1`
When calling
echo $CYGWIN_GNUMAKE
I get the reply:
make: C:/Programs/cygwin/home/simon/build/core/check-cygwin-make.mk: No such fil
e or directory make: AndroidManifest.xml build.properties default.properties jni
res src No rule to make target `C:/Programs/cygwin/home/simon/build/core/check-
cygwin-make.mk'. Stop.
Now I'm lost because I don't understand the role of the check-cygwin-make.mk script and I could not find it anywhere on my drive.
I'm aware of the problem with spaces in the C:/Program Files/ folder name, and I think this is not problem now.
I hope someone can help my to solve this issue,
Regards,
Simon
Install android-ndk and cygwin(with "make" support command) then set the varaibles like this
Right-click My Computer, and then click Properties.
Click the Advanced tab.
Click Environment variables.
then edit"PATH" add this line
C:\cygwin\bin like this
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files......;C:\cygwin\bin
then try with your built steps
'check-cygwin-make.mk' is in '\android-ndk-r6b\build\core', and you should have installed Android NDK to a directory without spaces in the path.
Next you should be running ndk-build either from Cygwin-shell, or with the command 'bash -c ndk-build'.
And of course the necessary paths both to Cygwin binaries (as in the previous answer), and to ndk-build should be specified in PATH.

Categories

Resources