Error: Program "/NDK-build" not found in PATH - android

I need help. I'm trying to install and configure OpenCV 2.4.7 library in my computer (Ubuntu 12.04). After run OpenCV samples appears those errors in my Console:
Cannot run program "/NDK-build": Unknown reason
Error: Program "/NDK-build" not found in PATH=[/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games]
I've seen numerous tutorials and nothing worked. I ask you to be very specific since I am "new" programming and also because my mother tongue is not English (I have some difficulties). Thank you!

Easiest Method which worked for me is.
Goto the Project Properties
Click on C/C++ Build (An other list will open)
Click on the Environment from the list
Now click on Add
Here you have to Put 2 values
Put Name as NDKROOT
In Value put PATH TO THE NDK FOLDER
You are done :)

Same case happened with me (when my NDK location was already set), so changing to original Android Builder removed my problem for doing so simply go to project properties, C/C++ Build | Tool Chain Editor and select Android Builder as current builder.

Do you have android-ndk installed? If yes, add path to ndk-build to your path.
e.g:
export PATH=$PATH:~/android-ndk/bin

Add the ndk-build to your path
Follow this guide
http://my.safaribooksonline.com/book/programming/android/9781849691529/setting-up-your-environment/ch01lvl1sec18

this is a frequent issue with openCV for Android. It stems from having the incorrect build target, which creates an error within the library for the Video.java file. After getting that patched up, you can import sample projects. Although, after fixing that, you may not be able to see the C/C++ Build node under project preferences. There's a fix for that on the second link. However, if under project preferences you can see C/C++ Build, make sure the path reads: "${NDKROOT}/ndk-build" Finally, it will be looking for NDKROOT,which is undeclared. The third link will direct you on how to do this, it's very simple. ALSO, make sure if your on MAC or LINUX to remove the .cmd from the end of NDK-BUILD. Good Luck!
Video.java issue:
http://answers.opencv.org/question/8266/opencv-library-244-on-eclipse-gives-error/
C++ Build/General Missing from Project Preferences:
http://stackoverflow.com/questions/16953548/eclipse-missing-c-c-build-and-general-from-project-properties
Now, make sure you add NDK root to the build varialbles so you can find it:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_add_build_var.htm`

Related

Environment variable in settings.gradle not working with Android Studio

I do have a multi-module project with a library project in a different root path. As illustration you can imagine something like this:
/projects_home/projects/app_root
|--app/
| |--build.gradle
|--build.gradle
|--settings.gradle
/libraries_home/libraries
|--libA
|--build.gradle
In my settings.gradle file I am able to set the absolute path to the library project utilizing the projectDir attribute. This works just fine within the console as well as with Android Studio.
But if I try to use an environment variable it stops working with Android Studio. The settings.gradle for the example above would look like this:
include ':app'
include ':libA'
project(':libA').projectDir = new File("$System.env.LIB_ROOT", '/libraries/libA')
If I build with the graddle wrapper from the console, it still works. But AS stops working with the following error msg:
Gradle 'app' project refresh failed:
Configuration with name 'default' not found.
If I unset the environment variable, the build on console fails with the same msg:
* What went wrong:
A problem occurred configuring project ':app'.
> Configuration with name 'default' not found.
Therefore I guess that AS is somehow not be able to access the environment variables set with my ~/.bashrc
Does somebody of you maybe know a way how I can make AS aware of my environment?
Android Studio does read the environment variables. You can prove it by launching Android Studio from the shell in which those env. variables being specified instead of from X-window dash board.
The reason you did not have those variables is the X-window environment you were using did not read $HOME/.bashrc which contained those variables. This makes sense because bashrc is for Bash not X.
Assuming you are using GNOME or Unity, to launch Android Studio with those environment variables being specified, just modify the .desktop file of Android Studio (e.g. ~/.local/share/applications/android-studio.desktop):
Find this line:
Exec="/home/username/tools/android/android-studio/bin/studio.sh" %f
Change it to:
Exec=env LIB_ROOT=/libraries_home "/home/username/tools/android/android-studio/bin/studio.sh" %f
Note:
This modification just prepend env LIB_ROOT=/libraries_home to the original command. You must replace username with your own user name.
Update
If you have any questions, please leave a comment instead of editing the answer directly.
On Macs, Android Studio does not read environment variables for use in Gradle apparently. I believe this is the cause for confusion in the answers here - maybe it does on Windows.
In order to get Android Studio to read environment variables, I run the application from the command line:
> /Applications/Android\ Studio.app/Contents/MacOS/studio
The other answers here offer solutions other than using environment variables. For my situation, I'm using a library I didn't write that requires the use of an environment variable, and I'd rather not edit their code so it's easier to update later.
EDIT: And, I have a dock icon to launch Android Studio this way:
OSX: Add Dock icon for dedicated Terminal command explains how.
Android Studio doesn't read environment variables, so this approach won't work. Also, using the projectDir scheme in settings.gradle will probably cause problems. Android Studio has a limitation that all of its modules need to be located underneath the project root. If you have libraries that are used in multiple projects and they can't be placed under a single project root, the best advice is to have them publish JARs or AARs to a local Maven repository that individual projects can pick up.
Despite the answer from Scott Barta is correct, I realized there is a way to solve my problem and wan't to share this in case somebody else has the same requirement.
I am now using the gradle.properties file do define and use gradle properties instead of system properties. The documentation of this feature can be fined in the user guide
The solution to my original question now looks like this:
$USER_HOME/.gradle/gradle.properties:
LIB_ROOT=/libraries_home
The settings.gradle file has to be modified to use the gradle property instead of the system property:
include ':app'
include ':libA'
project(':libA').projectDir = new File(LIB_ROOT, '/libraries/libA')
This works fine for me, headless as well as with AS.
Some more words regarding the fact that I am working with modules which are not placed underneath one project root. Till now it looks like AS is not complaining about this. But I just started working with this structure and it may be that I will run into problems later. What I like about this is the more flat representation in AS which is more like I am used to have it with Eclipse.
What is also described in the user guide, is to set system properties with the gradle.properties file. I tried this also, but I did run into the same problems with AS using environment variables.
It works for me with the following steps:
Set your variable in Windows
Reboot
reach it in gradle build: System.env.MYVARIABLE
I faced the same issue in apple laptop after the Android Studio Bumblebee update. This seems to be happening due to some permission issue with the Android Studio.
The workaround is to add missing flag:
chmod +x /Applications/Android\ Studio.app/Contents/bin/printenv
You can check this issue tracker for more details.
You can set environment variable by appending:
-DYOUR_VARIABLE=variable_value
to ~/Library/Preferences/AndroidStudioX.X/studio.vmoptions that you can open by selecting Help -> Edit Custom VM Options... from Android Studio menu.
And then you can use it like:
System.env.YOUR_VARIABLE
in build.gradle or settings.gradle.
MAC OS Update
I confirm that I have Environmental Variables working on Mac OS Catalina
You just need to set it in the shell you are using. I was using zsh, and was trying to set ~/.bash_profile, so it wasn't working.
Example:
ZSH Profile

Project 'HelloFacebookSample' is missing required Java project 'facebook'

I have been following the instructions for integrating the facebook SDK into my apps. I have succeeded in getting all the given sample apps to compile and run except for "helloFacebookSample". For this I get a compilation error:
Project 'HelloFacebookSample' is missing required Java project 'facebook'
My understanding of projects/libraries/build paths etc is a little hazy, but I can not work out why this should fail where all the others succeeded.
Here's a screen grab of my properties window for HelloFacebookSample:
I can confirm that the directory:
c:\android stuff\facebook\facebook-android-sdk-3.0\facebook\bin
contains a file facebooksdk.jar
Any ideas?
EDIT: Thrashing around some more, I just clicked on the "projects" tab that you see in the screen grab above, and saw that it says "facebook (missing)". I'm a bit confused because I thought that projects may need to rely on libraries rather than other projects... but still I have no idea how to resolve the problem. I don't seem to have a project called simply "facebook"...
Edit: thrashing around some more, I just experimentally deleted the "facebook (missing)" from the java build path and then did an "add" of "FacebookSDK"... I thought this was cluttching at straws, but to my surprise it worked!!! HelloFacebookSample compiled and ran!!! - I have no idea what's going on though and would still like an explanation.
The previous version of the Android Facebook SDK referred to the project as 'facebook'. It looks like this sample was not updated to delete the old reference, and add the new one to 'FacebookSDK'. You took the corrective steps to resolve this yourself already by modifying the Java Build Path of the project.
The problem will easily be removed by simply going to the properties of your project and right clicking it, then go to project tab, select the project which prompts missing and remove it.
Now click on project->build project->clean
Now run your project and it will surely do fine

How do I force eclipse to update the apk on my hardware device with each build?

If I change some code, save, and Run, it runs the last version of the program, not what I just saved. The only way I can make it update is if I Clean the project, Build the project, and then Run the project. Is there some way to avoid this tedium?
I spent some time create two dummy projects (one Android and one Java) and have a play with it, and finally come up with a workaround which is not used very often but able to solve your requirements.
First, I will explain your question a bit more (based on my understanding and what I have tried) so that other people can have a more clear understand about what is happened here.
According to the conversation in comments:
could you tell me what you have in following setting: project->properties->Builder ? – Sudar Nimalan
#SudarNimalan: I am not sure this is what you are asking, but: there's text that says "Configure the builders for this project", and under it is a single option, "Java builder", which is selected (checked). – shino
for android project, there should be, "Android Resource Manager", "Android Pre Compiler", "Java Builder", "Android Package Builder" in this order, chould you add those and try? – Sudar Nimalan
#SudarNimalan: I owe you an apology; I do have those four components. My "project" is split into 4 projects - "core", "core-android", "core-desktop", and "core-html". It's a little weird because I set it up with the libGDX project setup UI, and I was looking at the 'core' project when I answered your question. My 'core-android' project has all four (in that order), and it is the one that has the problem in my question. – shino
Scenario:
You have 4 project:
core: a regular java project (common pure java code here)
core-android: an Android application project.
core-desktop: not related to question so ignored.
core-html: not related to question so ignored.
The core-android project has dependency on core project, by adding core to core-android's build path (Properties -> Java Build Path -> Projects -> Add ...) and export list (Properties -> Java Build Path -> Order and Export).
Problem (Not Really):
Change some code in core and save it, run core-android, eclipse install last compiled apk, not the new one with change.
Reason:
The is the expected behavior, the way you used to reference core project in core-android only create a weak link (or something sort of) between core and core-android, the core-andorid's auto-build script doesn't aware any changes made in core. You have to clean the project (only need clean core-android project) so that Eclipse can delete the existing apk (under bin directory) and re-generate the apk (with the latest code changes from core).
See Xav's comments below, Android SDK tools should aware changes from plain Java project under project build path, and it does not behaviour this feature normally at the moment.
Note that if core is an Android Library project, then there is no problem and your core-android project will aware any changes in core project (java code, android resource and etc), if core is only used in core-android, this could also be a workaround: turn Java project core into Android library project.
Workaround (Eclipse Link Source):
There is another way (not commonly used) for adding soft link between projects:
First, you need remove core project from core-android's build path, this will also remove it from Export and Order list.
Right click core-android, choose Build Path -> Link Source ... Add ../core/src as Linked Folder Location and src-lib1 as Folder Name,see screen screen in the end.
This create a symbolic link src-lib1 under core-android in Package Explorer windows point to core's src foder, in the file system, you still have two separate project folder. Now if you change some code in core and run core-android, Eclipse will build and install latest apk. No need to clean core-android project.
Link Source Window:
Final look in Package Explorer:
You should always consider the normal approach as first option, after all, manual clean project is not a big deal compare to the unusual approach I described above.
Please follow this steps..
1. Project--> Build Automatically been checked??
2. Please following setting: project->properties->Builder like that?
Check below image.
And Also Check Below Settings.
Also Check Below Image
IF problem continues then please Update your ADT & SDK.
Hope it works for you .
Navigate to Windows->Preferences->Android->Build. Make sure that the checkbox "Skip packaging and dexing..." is NOT checked.
The Problem is the In your Eclipse, go to Project Properties - Builder, There is one CheckBox with AndroidPackageBuilder that is required to be Checked True. Now everytime you will do any changes in you project that will be reflected in your build and the Compiler will never say that
"Application Already Deployed, No need to Reinstall"
This will work evenif you dont have selected Build Automatically, Because everytime you run by clicking Run icon or Ctrl+F11 that will first Build the Project and Then Run it. So The requirement is just to Enable the Android Package Builder
You won't believe how easy and silly is the solution
On Eclipse,
go to Window-Prefences->run/debug ->launching
And then, on Save required dirty editors before launching :
choose the Prompt option,
Apply and OK

How do I fix Eclipse CDT Error "Function 'isdigit' could not be resolved" with Android NDK?

I am using Eclipse Indigo with an Android/NDK mixed project. I've added C++ nature and almost everything is working. Automatic builds work; that is, when I edit a file ndk-build is invoked and completes successfully - no build errors. Mouseover code assist works (the little window pops up with information about the function). If I place the cursor on an include line and press F3, a relevant header file open (not the one I would expect based on my configuration, but a relevant one - maybe a clue?).
If I select the following line in my .cpp file, it opens $NDKROOT/platform/android-3/arch-arm/usr/include/ctype.h:
#include <ctype.h>
(isdigit is defined in this file)
However, Eclipse insists that isdigit is not defined. I have read many posts suggesting that either the static analyzer or the indexer is to blame, but I've tried many of the suggested solutions to no avail.
If I add a line like the following, the error goes away and mouseover code assist for the function works:
extern int isdigit(int);
Again, this is not a linker error or a compiler error - ndk-build completes with no errors. This is something inside eclipse. Thanks for taking a look!
Edit: I now believe this to be a Code Analysis problem. A better solution is to edit the Code Analysis options to make "Function could not be resolved" be a warning instead of an error. That way you can see the warnings in Problems view, but continue to work. If the function is REALLY missing, the compiler will tell you! I also have a new theory, that the problem is with the Code Analyzer following symlinks, because all of the "missing" functions are in symlinked include files. Would love any input on this theory.
After spending several days working on problems like this, I developed the following recipe for dealing with issue.
I hope it helps you or others:
Summary: Usually, your problems in eclipse are due to eclipse configuration problems. The following assumes that your C++ code is building ok with ndk_build or ndk_build.cmd (on windows).
No joy with eclipse juno (4.2) and CDT version 8.1. Use eclipse indigo (3.7)
Make sure that you have the CDT for indigo installed and enabled (version 8.0X) by looking in the "install new software". It defaults to installed but not enabled on indigo on some downloads.
When you are dealing with native code or android config for native code, make sure you are in the C++/C perspective in eclipse, not the java one. It is deceptive, but there is a only a subset of options available in Java perspective. You can be sure you are C++/C perspective if you see "C/C++ general" as a choice when you do "Project > Properties."
The usual problem is that the indexer in C/C++-land thinks there are errors when there is not (e.g. building with ndk-build works ok, often you can see this in the console window even). This is caused by bad paths in the "Paths And Symbols" part of "Project > Properties > C/C++ General" on the first tab.
To fix the problem, the primary tool is to right-click on the project, select "Index" and "Search for unresolved includes." This will tell what files it can't find--and these are typically not the ones that you have in your files with the little pink mark by them.
To find the right file, search in your NDKROOT directory (where you installed NDK). A typical one to add is: ${NDKROOT}/platforms/android-9/arch-arm/usr/include or the right android-N for your android target. There are many copies of the standard include directories in the NDK because of multiple versions of android and copies of the C++ standard libraries.
Two big warnings
The "unresolved includes" view in eclipse does not automatically update when you change the indexer configuration on the Properties > C/C++ General/Paths and Settings so be sure to run it again each time. Most views in eclipse do this update properly!
Also the little red/pink error markers in the source code views in the eclipse editor don't automatically update either. You have to "touch" the file in some way for it discover that the error is now fixed.
I worked around this issue via the approach I suggested in my question and haven't been able to find a better way yet.
Perhaps this will help:
Go to Project > Properties
Navigate to C/C++ Build > Settings
Go to GCC C Linker > Miscellaneous settings
Add the following in the Linker flags : -lc
Have you tried rebuilding the indexer? (right click project in project explorer index->rebuild)
Sometimes that takes care of problem... If you upgraded from an earlier version of eclipse your indexer setup could be a problem -- you might want to try restoring the indexer defaults (preferences c/c++ Indexer)... Hope this helps – this issue can be 'maddening' (seems to happen way to often)
I had the same problem on Linux with different toolchains. Even the simplest C++ code (like the one create by the hello wizards) would have syntax errors, without aby build problem. As pointed out in another post by Thorbjorn Jemander the problem is in the indexer and it can be eliminated by deselecting the option "Allow heuristic resulution of includes". Explicitely: Winsow -> Preferences -> C/C++ -> Indexer -> deselect the above option.
After that you may see that highlighted errors disappear after you open the file in editor and just click within the editor page...

Conversion to Dalvik format failed with error 1 with javax/net/SocketFactory.class

Encounter this problem when trying to Build Project getting such output in console:
[2010-07-19 23:29:23 - myProject]
trouble processing "javax/net/SocketFactory.class":
[2010-07-19 23:29:23 - myProject]
Attempt to include a core VM class in something other than a core library.
It is likely that you have attempted to include the core library from a desktop
virtual machine into an application, which will most assuredly not work. If
you really intend to build a core library -- which is only appropriate as
part of creating a full virtual machine binary, as opposed to compiling an
application -- then use the "--core-library" option to suppress this error
message. If you go ahead and use "--core-library" but are in fact building
an application, then please be aware that your build will still fail at some
point; you will simply be denied the pleasure of reading this helpful error
message.
[2010-07-19 23:29:23 - myProject] 1 error; aborting
[2010-07-19 23:29:23 - myProject] Conversion to Dalvik format failed with error 1
I was looking for my project to use the package javax, not found, clean all also does not help. what I am doing wrong?
Update
Sorry guys, but I could not find good fix for that, I want to emphasize the fact, that i dont use SocketFactory class in my project at all! source code was not changed before this problem, and that's why i think that problem in eclipse or adt or something else, BUT if i use ant(generated by sdk) to build this project there is no problem!!!
I solve this problem by removing Eclipse, Android SDK, Eclipse workspace, and just reinstall them, after this all works fine for now.
Hope this will help someone.
I had the same problem..
This worked for me
project-->properties->java build path->libraries-> remove all including android jars
now go the project browser, right click on the project you are working on,
then android tools---> fix project properties...
do a clean and then build...
I solved the problem (at least for me).
Here's what I did:
Go to Project » Properties » Java Build Path » Libraries
Remove all except the "Android X.Y" click OK.
Go to Project » Clean » Clean projects selected below » select your project and click OK.
That did the trick for me.
Hope it works for you as well
Update: well actually I might have to retract my opinion.. the actions removed the error messages but now I am missing certain classes and methods... arggghhhh
I just restarted Eclipse, and the error didn't appear anymore!
I had the same problem,and solved it as follows:
First clean all jars; (This problem must because your some jars)
Delete the project;
Reimport project;
Make sure your sdk is right, and project select one sdk version;
(This is my issue to solve the problem) Right click your project, and select "build-path", next select "add Librarys", and add your private jars;
clean-build, the problem has fixed;
I just had the same problem and I tried all of the solutions listed here with no success (I was starting to get annoyed). Then I removed the project from the workspace and then imported it again, and there were no problems!
This happened to me this way,
I have a quite an old project which I had to start working again today. I use 'Universal Image Downloader' library for basically every project where I have to deal with lots of images. So in this old project I had the source files of 'Universal Image Downloader' included to it's 'src' path. Back then I was a newbie and slowly I started developing my own library which could handle every day simple Android development tasks very easily. Obviously I included the 'Universal Image Downloader' to this.
After dusting off the old project today the first thing I did was to reference my library to speed up the development process but as I was trying to debug I ran into the "Conversion to Dalvik format failed with error 1" over and over again. First I thought it was the support library but even after clearing all libraries and adding only mine and doing a quick 'Fix project properties' I still got it. After trying various solutions I noticed this in the console "java.lang.IllegalArgumentException: already added: Lcom/nostra13/universalimageloader/cache/disc/BaseDiscCache;"
It was as simple as that... I'm trying to compile a class which has already been compiled.
Solution : I just simply removed all the class files I got from 'Universal Image Downloader' library from the 'src' directory. Since my library references "Universal Image Downloader" library the old project started working just fine.
Hit same problem shown on your log when trying to run an example project which was imported into eclipse.
Additional Info: in eclipse's Problems View I see the following error:
"The project cannot be built until build path errors are resolved"
In my case the imported project find the libraries just right(by just right I mean I can see the external path to each of the android libs in this case 2 libs, android.jar and maps.jar). So no shuffling of libs in my case, but might be your problem.
I followed Spock's suggestion of cleaning the project which I had to clean multiple times until it somehow resolve its issues. After, issue was solved I had to specify an AVD for the project to run and soon after was up and running on the emulator. Also, note that my eclipse is set up to Build Automatically.
In my case I'm not missing any class files or anything after the clean as the build is properly generating them.
Regards!
I was getting the same error. My problem was that i had an android device hooked up to debug with. As soon as I unplugged it I was able to export.
The answer I found was checking the source and library build path in the project's properties. Most likely there will be a duplicate as in something being referenced in both the source and library tabs. So delete the extra in the source tab and then clean the project and you should be good to go.
Either:
javax.net.SocketLibrary is in your source code, or
javax.net.SocketLibrary is included in a JAR file in your project
Under certain conditions it gets its knickers in a twist and the best fix I've found is to remove referenced jars, clean, add them back in and then compile again.
I believe the error can be caused by including the same classes twice.
This error will also occur (and you won't be able to get rid of it by cleaning) when using classes that are not part of the Android environment.
To summarise the information in the link bimbim.in provided (well my understanding when I glanced over it)
The Android Davik VM tries to compile the jars but finds some stuff that it can't compile to .dex files
so
Just create a "lib" directory in the root of the project (where the src, bin res directories are) and add them to the build path. Project Properties... Java Build Path... Libraries.. Add JARs..
I could resolve this issue by creating a new project, looks like the some project settings were creating this issue and could not really find the root cause for that. But, dumping the existing source code onto the new project resovled this issue. If anyone has found the root cause for this problem pls do let me know.
I had the same problem and solved it as follows:
- Go to Project/Properties/Java Build Path/Libraries and remove all JARs except Android
- Do a project clean
- Add the JARs again as External JARs (first time I added them internally, so that might be the problem)
After that the error was gone.
I solved the problem by updating available packages in the Android SDK et AVD manager. No need to remove Eclipse.
Whenever the Project is having the ambitious data. This problem is caused. May be android can't able to find which one choose.
From what I understand, this same cryptic error could be caused from a wide variety of reasons. I've got "Conversion to Dalvik format failed with error 1" error too. In my case the problem was that for some reason Project -> Properties -> Java Compiler was not set to "Enable project specific settings" with proper Java 1.5 settings, but was left to defaults instead (1.6 in my case). Debug, build and test on devices/emulators worked fine, but export always failed with the above error message.
If unsure about the proper settings, create the same project on some alternative location and just copy all needed files from the old project into the new one. This fixed the issue for me.
The next problem with the same error message came from using proguard. Updating to the latest version by replacing the one that came with android sdk, fixed that.
Hope this helps
My problem was having a jar file in my src folder. Removing jars from the build path works, but only if you don't need the jar in question. For people who need the jar in question, make sure that your jar file is not in the project folder (maybe just src subtree, but I would keep it separate to test). Put it on your desktop or something and try the "Add external jar.." option. Be sure to remove the jar from the project filesystem before adding another external. Having both is what causes the problem.
I have done it as the instruction of the first answer and it works.(Linux)
I think the problem may caused by SDK or ADT updates.
I do have to clear all the lib in Java Building path and then use android tools to fix the project. After cleaning and rebuild, it works as before.

Categories

Resources