ndk-build not found as a command - android

I have been working with Android SDK for a while & just came across an requirement to use the NDK
So, I downloaded the Android NDK for Windows. Jumping on the first example, when I am trying to build the library using the process defined in the NDK example
http://developer.android.com/sdk/ndk/overview.html
Specifically the command /ndk-build from the command line
I am getting the error
ndk-build is not recognized as an internal or external command, operable program or batch file
I have added the path for ndk-build in the PATH variable and even tried calling the command going to the folder, still the same error
Does anybody have a clue?

Guess that should have been an answer instead of a comment.
You must use Cygwin as your shell in order to run ndk-build.
See http://www.cygwin.com/

Once you have Cygwin installed you can have Eclipse automatically build your project for you by:
Right click on your project, pick properties.
Select "builders" from the left-hand list.
Click "New..." on the right side.
Select "Program" as the configuration type. I name mine "Native Builder"
Location - c:\cygwin\bin\bash.exe
Working Directory - c:\cygwin\bin
Arguments -
(for NDK r3):
--login -c "cd /cygdrive/c/Android_NDK && make APP=myapp"
(for NDK r4):
--login -c "cd /cygdrive/c/ && /cygdrive/c/Android_NDK/ndk-build"
Make sure you have the two hyphens before login and the quotes after the hyphen-c
Now go to the refresh tab
Check "Refresh resources upon completion"
Select "Specific resources"
Click on the "Specify resources" button and select your project's
lib directory.
Check "Recursively include sub-folders"
Now go to the build options tab
Check "Allocate Console"
Check "Launch in background"
Check "Run the builder After a Clean"
Check "Run the builder During manual builds"
Check "Run the builder During auto builds"
Check "Specify working set of relevant resources"
Click on "Specify Resources"
Select your project's JNI directory and all files within.
Now click OK on the bottom.
Now you can edit and save in your c files and it will compile and create the .so file on the fly.

Maybe, your development IDE hides system PATH and uses it's own PATH. I had same problem with MOTODEV Eclipse for Android 3.1. Detailed solution is here: How to solve problem with Motodev Eclipse for Android 3.1: wrong PATH It is for MOTODEV IDE, but Eclipse may have same thing.

Related

ndk-build not recognized as an internal or external command [duplicate]

I have been working with Android SDK for a while & just came across an requirement to use the NDK
So, I downloaded the Android NDK for Windows. Jumping on the first example, when I am trying to build the library using the process defined in the NDK example
http://developer.android.com/sdk/ndk/overview.html
Specifically the command /ndk-build from the command line
I am getting the error
ndk-build is not recognized as an internal or external command, operable program or batch file
I have added the path for ndk-build in the PATH variable and even tried calling the command going to the folder, still the same error
Does anybody have a clue?
Guess that should have been an answer instead of a comment.
You must use Cygwin as your shell in order to run ndk-build.
See http://www.cygwin.com/
Once you have Cygwin installed you can have Eclipse automatically build your project for you by:
Right click on your project, pick properties.
Select "builders" from the left-hand list.
Click "New..." on the right side.
Select "Program" as the configuration type. I name mine "Native Builder"
Location - c:\cygwin\bin\bash.exe
Working Directory - c:\cygwin\bin
Arguments -
(for NDK r3):
--login -c "cd /cygdrive/c/Android_NDK && make APP=myapp"
(for NDK r4):
--login -c "cd /cygdrive/c/ && /cygdrive/c/Android_NDK/ndk-build"
Make sure you have the two hyphens before login and the quotes after the hyphen-c
Now go to the refresh tab
Check "Refresh resources upon completion"
Select "Specific resources"
Click on the "Specify resources" button and select your project's
lib directory.
Check "Recursively include sub-folders"
Now go to the build options tab
Check "Allocate Console"
Check "Launch in background"
Check "Run the builder After a Clean"
Check "Run the builder During manual builds"
Check "Run the builder During auto builds"
Check "Specify working set of relevant resources"
Click on "Specify Resources"
Select your project's JNI directory and all files within.
Now click OK on the bottom.
Now you can edit and save in your c files and it will compile and create the .so file on the fly.
Maybe, your development IDE hides system PATH and uses it's own PATH. I had same problem with MOTODEV Eclipse for Android 3.1. Detailed solution is here: How to solve problem with Motodev Eclipse for Android 3.1: wrong PATH It is for MOTODEV IDE, but Eclipse may have same thing.

coco2d-x: java.lang.IllegalArgumentException: Unable to find native library

I have started learning Coco2d-x and want to run the sample app on my android phone. I have imported sample project Hellocpp in my eclipse and fixed the library path. I am able to install it on my device but when i run it i get below error.
I am following this tutorial: coco2d-x
Please help me out.
Are you sure you have the linked the source cocos library to your project in the java build path. and if so. please check your environment variables for COCOS2DX_ROOT,NDK_ROOT.
1: In Eclipse, right-click on your project and select the last option "properties".
2: In Project Properties window, select "Java Build Path" in the left pane.
3: Under Java Build Path, select tab "source". It should be selected by default.
4: Click on button "Link Source"
5: Browse it to following location-> COCOS2D-X_INSTALLATION_FOLDER/cocos2dx/platform/android/java/src. My path will be: E:\cocos2d-x-2.2\cocos2dx\platform\android\java\src
6: Give any folder name. For example, remove src and replace it with: Cocos2d-x-source. Click Finish.
We are done now. Run your poject on an Andorid Device and it should show you the nead cocos2d-x logo. Please note that running this in an Android Virtual Machine may not always work.
If there is an error after the project has been imported and build like:
Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml eclipse
You can change the Eclipse settings by following these steps, provided by a someone from Google (at this link) (but also, see my IMPORTANT note below):
IMPORTANT! What the Google guy didn't note is that you also need to use the "Move Up" button in the settings to move your new rule to the top because otherwise some other more generic rules overshadow it and it doesn't work.
In eclipse:
Window -> Preferences -> C/C++ -> Build -> Settings
Select CDT GNU C/C++ Error Parser
In the Error Parser options at the bottom, add a new entry with the following contents:
Severity: Warning
Pattern: (.?):(\d+): Android NDK: WARNING:(.)
File: $1
Line: $2
Description: $3

Android NDK in ADT and Mac OS (10.8): Cannot run program "/ndk-build": Unknown reason Error: Program "/ndk-build" is not found in PATH

The error while building is
/ndk-build
Cannot run program "/ndk-build": Unknown reason
Error: Program "/ndk-build" is not found in PATH
PATH=[/usr/bin:/bin:/usr/sbin:/sbin]
I am trying to build a OpenCV project on Eclipse ADT and have done the following so far to build it.
Normal android projects(not involving c/c++ code) works fine.
1- I have edited the /etc/paths to the following
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
PATH=$PATH:/Users/mohitagrawal/adt-bundle-mac-x86_64-20130219/sdk/tools
PATH=$PATH:/Users/mohitagrawal/adt-bundle-mac-x86_64-20130219/sdk/platfor
m-tools
PATH=$PATH:/Users/mohitagrawal/android-ndk-r8e
2- I have edited $PATH to following(knowingly or unknowingly)
-bash: /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:
PATH=$PATH:/Users/mohitagrawal/adt-bundle-mac-x86_64-20130219/sdk/tools:PATH=$PATH:/Users/mohitagrawal/adt-bundle-mac-x86_64-20130219/sdk/platfor:m-tools:
PATH=$PATH:/Users/mohitagrawal/android-ndk-r8e:/opt/X11/bin:/usr/local/git/bin:/usr/texbin: No such file or directory
3- Build command in "C/C++ Build" in project properties is set to
${NDK_ROOT}/ndk-build
4- NDK location in Preferences of ADT eclipse is set to
/Users/mohitagrawal/android-ndk-r8e
Please help me. I am stuck from many days and has even tried on different platform.
You need to change the PATH in Eclipse since it is Eclipse that is trying to run the command. Go to Project Properties > C/C++ Build > Environment > PATH
Add the path to your ndk directory in the PATH variable (i.e. add /Users/mohitagrawal/android-ndk-r8e to the PATH variable).
Moreover, it apparently tries to run /ndk-build. Make sure that in Project Properties > C/C++ Build, "Build command" is ndk-build and not /ndk-build
EDIT: you can also try to build your project from the terminal, by navigating to your project and running the command ndk-build.
I've tried all the solutions that I could find on stackoverflow and none of them worked.
In the end I've found this blog.
I'll post the solution here as the link may break in the future:
1. Open up Terminal.
2. Run the following command: sudo nano /etc/paths
3. Enter your password, when prompted.
4. Go to the bottom of the file, and enter the path you wish to add.
5. Hit control-x to quit.
6. Enter "Y" to save the modified buffer.

New android SDK 17 issue in my app?

Today i was update my android sdk to new android adk-17 .
i am facing some problems in this, that is unable to show AddMob in my app, if i remove addmob in the code able to run the app without any errors otherwise not. what is the solution for this, is this bug in new sdk.
this is the Logcat information
Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader
dalvik.system.PathClassLoader[/data/app/com.veritra.iflipout-1.apk]
Maybe the ADK update has messed-up with your project's build-path.
Try removing the admob JAR and add it again to your libs folder, add it to your Build Path and do a Clean Project.
Anyway it's hard to help you without more details on the error you encounter.
EDIT following poster's comment about not having a libs folder:
You should try this:
Remove all references to the AdMob JAR in your project -> your code should not build without error anymore
Create à libs folder at the root of your project
Copy the AdMob JAR into the libs folder
Make sure this AdMob JAR is in your Build Path (this will allow your code to build wihtout error)
(If still not running OK) Right click your project > Android Tools > Fix Project Properties
The 'problem' here is that the SDK is a lot more strict about the libraries. If you do not check the library as 'exported' in eclipse, it is not added to your APK, leading to this nasty class not found exception. You should mark your libraries as exported.
Project Properties | Java Build Path | Order and Export
when I updated my SDK it was total mess. Well, the only I had to change was the PATH in Environment Variables.
http://developer.android.com/sdk/installing.html :
Adding both tools/ and platform-tools/ to your PATH lets you run command line tools without needing to supply the full path to the tool directories. Depending on your operating system, you can include these directories in your PATH in the following way:
On Windows, right-click on My Computer, and select Properties. Under the Advanced tab, hit the Environment Variables button, and in the dialog that comes up, double-click on Path (under System Variables). Add the full path to the tools/ and platform-tools/ directories to the path.
On Linux, edit your ~/.bash_profile or ~/.bashrc file. Look for a line that sets the PATH environment variable and add the full path to the tools/ and platform-tools/ directories to it. If you don't see a line setting the path, you can add one:
export PATH=${PATH}:/tools:/platform-tools
On a Mac OS X, look in your home directory for .bash_profile and proceed as for Linux. You can create the .bash_profile if you don't already have one.

Failed to load properties file for android project

I finally was able to build and debug the android platform with this tutorial. I imported my project in eclipse, and afterwards installed ADT. Then I converted my imported project to android project (Android Tools -> Convert To Android Project). And now I'm having Failed to load properties file for project 'droid-platform' error. Session data:
eclipse.buildId=M20100211-1343
java.version=1.5.0_18
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=ru_UA
Command-line arguments: -os linux -ws gtk -arch x86
Does anyone know, how do I deal with this?
Use the contextual menu on the Project in error, "Android Tools"-->"Fix project properties", I also tried "Refresh (F5)" in the same pass, than it worked again.
ADT does not work good with the platform itself. Actually, the platform is not an android project itself.
I really struggled with this one and finally solved it using the solution here:
"Debug certificate expired" error in Eclipse Android plugins
I also had the error message you mention, but somehow, deleting the keystore fixed everything.
p.s. do a clean after deleting the keystore.
Yusuf
The solution to this problem is to setup some System Environment Variables.
Right click on "My Computer" and select "Properties"
Select the "Advanced" tab
Click the "Environment Variables" button
Under "System Variables" find "Path", select is and then click "edit"
Scroll to the far right, now you need to add two paths, "C:\Documents and Settings\YOUR_USER_NAME\.android\avd" and "C:\Program Files\Java\jdk1.7.0_01\bin", you need to add a ; at the end of each path. Click "Ok" when done.
Select the "New" button, for variable name enter "ANDROID_SDK_HOME", and for variable value enter your SDK install path (Default is "C:\Program Files\Android\android-sdk") and then click "Ok"
Restart Eclipse and it should work!
on my mac, with Eclipse and the Android AVD exited,
1) i deleted all projects in my workspace (backup first!),
2) recreated it with the same workspace name and
3) finally restarted eclipse and a new project setup works fine without the "Failed to load properties.." msg.
So easy just choose the project that has an error, and then go to menu>project>build Project
Just create a new file called project.properties in the root of your project.
Add the line:
target=android-10
Or modify it to whatever version of the Android you're targeting.
I got the a similar error When following the Notepad tutorial on the Android Developers website, the first step in Exercise 1 is to create the first project by going to
File->New->Android Project-> "Create project from existing source"
The problem is that when you select the Notepadv1 path to create the project from existing source, Eclipse will take the project out of the parent folder and move it up a level. For example, if you select
C:\workspace\NotepadCodeLab\Notepadv1
... as the existing source, Eclipse will copy all the contents of that subfolder except the AndroidManifest.xml (and Android.mk file) into a new folder one level up, eg.
C:\workspace\Notepadv1
So one workaround is to create the project, close Eclipse, then copy in all the missing files from the old subfolder to the new folder, then open Eclipse again and refresh the folder.
Presto, no more missing files.
In my case, I just add to import the R.java (ex:import com.exercise.teste.R;) to my class files by right clicking on ex: R.id.mybutton and choose import ex; your.package.name.R, then CLEAN, BUILD.
What fixed the problem for me was going into eclipse sdk manager and installing the tools there even though I had them installed on my sdk manager. It seems that there 2 separate sdk managers with different files, so try directly going into the sdk manager in Eclipse and seeing if you have the tools installed there.
I had the same problem, and without installing AUSKey only corrected the error by removing the log4j.jar / Library / Java / Ext on Windows (\C:\Program Files\Java\jre7\lib\ext) was fixed. In my case, the solution was like this:
https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=54452
I had this error when I manually tried editing the manifest file, "AndroidManifest.xml". When I made changes using the little GUI provided for editing the file, it works fine.
Make changes via the Manifest General Attributes and Manifest Extras sections that opens up when you double click the "AndroidManifest.xml" file. Yet beware of changes made directly to the xml, even if they are identical!
I was facing the same issue but I finally got the solution:
Right-click on your Eclipse project.
Go to Build Path->Configure Build Path->select Android from left side.
In Library section select and remove the existing v7 library
Add it again from your imported v7 project.

Categories

Resources