Compiling React Native project with local fork - NDK_PROJECT_PATH - android

I'm trying to compile my React Native Android project using a local fork of react-native. I've followed the building from source guide and completed all steps (not using Android Studio).
When I try to run react-native run-android (from project root as normal), I get:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ReactAndroid:buildReactNdkLib'.
> Process 'command '/usr/local/opt/android-ndk/ndk-build'' finished with non-zero exit value 2
When I run ndk-build (from project root), I get:
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
/usr/local/Cellar/android-ndk/r12b/build/core/build-local.mk:151: *** Android NDK: Aborting . Stop.
Another SO thread pointed me in the direction of running ndk-build from ./android/app/src and create a jni directory there (I didn't have one), but I'm unsure how to obtain or create jni/Android.mk correctly or if this will even help me. I've tried creating jni/Application.mk with contents APP_BUILD_SCRIPT := Android.mk and jni/Android.mk with the setup described in that SO question. Running ndk-build from android/app/src exits with the following error:
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: Android.mk
/usr/local/Cellar/android-ndk/r12b/build/core/add-application.mk:198: *** Android NDK: Aborting... . Stop.
I have the Android SDK and NDK installed with Homebrew and I have the following exports:
ANDROID_HOME=/usr/local/opt/android-sdk
ANDROID_SDK=/usr/local/opt/android-sdk
ANDROID_NDK=/usr/local/opt/android-ndk
ANDROID_NDK_HOME=/usr/local/opt/android-ndk
I feel like I'm close, but have no idea how to continue.

I think the issue is with android-ndk version. We need to use ndk version specified by react-native documentation. I tried with the latest version of andrid-ndk. I was not able to build the project, got similar error while running react-native run-android.
Then I tried with android-ndk-r10e version. It worked fine, I was able to build the project successfully.
Also you may find this react-native github issue discussion useful.

I'm trying to compile React Native UIExplorer for Android.And I have same issue.
Then I run ndk-build ,I get:
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
/usr/local/Cellar/android-ndk/r13b/build/core/build-local.mk:151: *** Android NDK: Aborting . Stop.
My android-ndk version is /android-ndk/r13b/,So I download android-ndk-r10e .
I use the most direct way:
$ cd /usr/local/Cellar/android-ndk/r13b
$ rm -rf ./*
$ mv YourUnZipPath/android-ndk-r10e/* ./
Then It worked fine, I was able to build the project successfully.

Related

how to ndk setting finished with non-zero exit value 2 on android?

I want to build Gstreamer source and it needs NDK.
I am setting SDK Manager -> Android SDK -> SDK Tools -> NDK install
and I set local.properties dk:dir="C\:\\Users\\ddd\\AppData\\Local\\Android\\sdk\\ndk-bundle.
After setting ndk, I try to build it, but execution failed.
Execution failed for task ':app:ndkBuild'. > Process 'command 'C:\Users\ddd\AppData\Local\Android\sdk\ndk-bundle\ndk-build.cmd" finished with non-zero exit value 2 message.
How to set ndk on android?
To find the specific issue, check the Build tab in Android Studio to see which task is failing. For me it was task "cleanNative".
Then run this task manually from Terminal with --debug option.
On Mac or Linux:
./gradlew cleanNative --debug
On Windows:
gradlew cleanNative --debug
From logs, you can then see why it is failing. In my case it was the wrong ABI settings:
10:24:27.140 [QUIET] [system.out] Android NDK: The armeabi ABI is no longer supported. Use armeabi-v7a.
10:24:27.140 [QUIET] [system.out] Android NDK: NDK Application 'local' targets unknown ABI(s): armeabi
10:24:27.140 [ERROR] [system.err] /Users/michal-home/Library/Android/sdk/ndk-bundle/build/core/setup-app.mk:79: *** Android NDK: Aborting . Stop.
10:24:27.140 [QUIET] [system.out] Android NDK: Please fix the APP_ABI definition in /path-to-app/app/src/main/jni/Application.mk
What I infer from above is that you have already installed NDK, make sure you also install CMake and LLDB. (Restart Android Studio after install)
If the problem persists even after that, try deleting the "obj" folder within your ndk library (located at "yourLibary/main/src/obj") and rebuild.
This solved the problem for me.
You need to make sure the NDK is set properly - go to File->Project Structure->SDK Location and make sure the NDK location is properly set. If it is, perhaps the compilation fails due to some problem with the code, and we will need some more info in order to help you.
In my case and project, it was helpful to use privious ndk version(Revision 17c). So I just have put it in 'C:\Users\UserName\AppData\Local\Android\sdk\ndk-bundle'
Another helpful issue is to put your *.so files within jniLibs folder:
How to include *.so library in Android Studio?
Check your android project path.
I had a similar problem with empty spaces at my folder name. Avoid things like that or ndk can't do the job
.\Users\User1\Desktop\androidprojects\my project\androidproject1
Instead that use
.\Users\User1\Desktop\androidprojects\myproject\androidproject1

Android NDK:Aborting

I have installed ndk correctly when working with previous projects.I have downloaded now openpeer library for Android. When I load the openpeer sdk, I get the following:
14:59:28 ** Clean-only build of configuration Default for project openpeer-android-sdk **
"D:\android-ndk-r8e\ndk-build.cmd" NDK_DEBUG=1 clean
2 [main] pwd 4928 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer. Please report this problem to
the public mailing list cygwin#cygwin.com
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: /cygdrive/d/Android Workspace/openpeer-android-sdk/jni/Android.mk
D:/android-ndk-r8e/build/core/add-application.mk:165: * Android NDK: Aborting... . Stop.
14:59:28 Build Finished (took 330ms)
I also got an error in the project but all of the files appear without any error signs. Please advise
I think you have a problem with the NDK_PROJECT_PATH environment variable..
Are you compiling over cygwin? what is the cygwin connection?
He tries to find some file at this path : /cygdrive/d/Android Workspace/openpeer-android-sdk/jni/Android.mk

Android: ndk-build is returning nothing?

I'm trying to rebuild my Native android project, however all of a sudden, ndk-build decides it doesn't want to, and seems to be sulking on me.
Here's my output:
nathan#nathan-K52F:~/COMBAT/engine/android-build$ android update project -p . -t 1 -s
Updated project.properties
Updated local.properties
Updated file ./proguard-project.txt
nathan#nathan-K52F:~/COMBAT/engine/android-build$ cd jni && ndk-build
nathan#nathan-K52F:~/COMBAT/engine/android-build/jni$ ndk-build
nathan#nathan-K52F:~/COMBAT/engine/android-build/jni$ cd ../
nathan#nathan-K52F:~/COMBAT/engine/android-build$ ndk-build
nathan#nathan-K52F:~/COMBAT/engine/android-build$ //should be erroring here - yet nothing?
It however at least tries to build another native project:
nathan#nathan-K52F:~/GamePlay/samples/browser/android/jni$ ndk-build
/home/nathan/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 9 in /home/nathan/GamePlay/samples/browser/android/AndroidManifest.xml
Android NDK: ERROR:/home/nathan/GamePlay/samples/browser/android/jni/Android.mk:gameplay: LOCAL_SRC_FILES points to a missing file
Android NDK: Check that /home/nathan/GamePlay/samples/browser/android/jni/../../../../gameplay/android/obj/local/armeabi/libgameplay.a exists or that its path is correct
/home/nathan/android-ndk-r8e/build/core/prebuilt-library.mk:45: *** Android NDK: Aborting . Stop.
nathan#nathan-K52F:~/GamePlay/samples/browser/android/jni$
The error's are suppose to be there by the way.
I just haven't a clue why it isn't compiling the project I WANT it to compile - I don't think it likes me anymore :L
I'm running on the latest Ubuntu OS, with NDK r8 and JDK 1.7
I didn't add my the new files to my makefile to be compiled.

How to build libav using ndk-build in cygwin for windowds?

I want to know how to build libav on windows7 using cygwin. I've tried the following steps :
1-change the directory using cd command to libav_file_directory/android(android folder is empty where the .so file will be saved as far as my knowledge is concern).
2-execute the ./ndk-buil command.
I got the following as result:
*Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
/cygdrive/c/Users/balwant.singh.TA/Desktop/Android/android-ndk-r8/build/core/build-local.mk:130: * Android NDK: Aborting . Stop.*
plese reply with solution, and also I want to know which all android media player uses the libav as their native code.
1.)Set all your paths(Java_Home
2.)Set NDK_HOME to Ndk-Build Path
3.)Run Cygwin
4.)GO to project Library path
5.)Run make command
6.)then Run ndk-build

Error with building Android NDK Project

I wand build project in windows, I get same Errors:
bash C:\linux\android-ndk1\ndk-build V=1
cygwin warning:
MS-DOS style path detected: C:\dev\android\workspace4_android\FFWall
Preferred POSIX equivalent is: /cygdrive/c/dev/android/workspace4_android/FFWall
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Android NDK: ERROR:jni/Android.mk:bambuser-libavcore: LOCAL_SRC_FILES points to a missing file
/cygdrive/c/linux/android-ndk1/build/core/prebuilt-library.mk:43: *** Android NDK: Aborting . Stop.
Android NDK: Check that jni/ffmpeg-android/build/ffmpeg/armeabi/lib/libavcore.so exists or that its path is correct
Another way building:
C:\art\android-ndk\ndk-build V=1
Cannot run program "C:\art\android-ndk\ndk-build": Launching failed
Error: Program "C:/art/android-ndk/ndk-build" is not found in PATH
PATH=[C:\Art\android-ndk;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Program Files\PC Connectivity Solution\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\MATLAB\R2011a\runtime\win32;C:\Program Files\MATLAB\R2011a\bin;C:\Program Files\MATLAB\R2007b\bin;C:\Program Files\MATLAB\R2007b\bin\win3;C:\dev\android\android-sdk-windows\tools;C:\cygwin\bin;C:/art/android-ndk/;C:\linux\android-ndk-r7b;C:\dev\android\eclipse]
Why this happened?
From: http://developer.android.com/sdk/ndk/overview.html#reqs
Required development tools
For all development platforms, GNU Make 3.81 or later is required. Earlier versions of GNU Make might work but have not been tested.
A recent version of awk (either GNU Awk or Nawk) is also required.
For Windows, Cygwin 1.7 or higher is required. The NDK will not work with Cygwin 1.5 installations.
Meaning, that you will have to install Cygwin. After that you can call the ndk-build like:
$ProjectPath> /cygdrive/c/myNdkPath/ndk-build
Please also check the "Getting Started" part of:
http://developer.android.com/sdk/ndk/index.html

Categories

Resources