Invalid path for Android NDK in Eclipse Preferences - android

I'm looking to incorporate the NDK for C++ code use in my Android project. I'm using Eclipse Android IDE and I've just downloaded android-ndk-r9-darwin-x86_64.tar.bz2 for OSX 64bit. I've uncompressed the ndk and have it in my home folder, but when I attempt to setup the path inside Eclipse prefs, I get this error
I've looked at this similar question (Eclipse error: invalid path for ndk?) for answers, but every suggestion didn't solve the problem. Other relevant information, I have Make 3.8.1, up-to-date SDK, Sequoyah.

I had the same problem and documented the solution to this problem. It are the first 2 steps of the next link you'll need:
http://aplacetogeek.wordpress.com/android-with-opencl-tutorial/
Edit:
The solution is this:
Step 1: setup Android NDK
Download the NDK from:
http://developer.android.com/tools/sdk/ndk/index.html
I unzipped it in the adt-bundle but you can unzip it anywhere you
want.
Note or remember the path you used. I'll need it in the next steps!
Go to Window -> Preferences -> Android -> NDK
Browse to android-ndk-r9c.
Example: /home/dries/AndroidDev/adt-bundle-linux-x86_64-20131030/android-ndk-r9c
Click apply and ok
Step 2: configure Android NDK for your project
Right click on your project folder. Choose android tools -> add
native support (! the bottom one !) and click finish.
The file you just created is going to be your own .so file. This
will be your personal library with the functions you create yourself
in the JNI folder.
Now you should see a JNI folder in your project with a .cpp and an
Android.mk file in it.
Go to project -> properties -> C/C++ build -> build variables -> add
Name: NDKROOT
Value: your android-ndk-r9c folder you also added to NDK in step 1.
Click Ok
Go to C/C++ build and uncheck Use default build path.
Change the
build path to ${NDKROOT}/ndk-build. Make sure you did not end the NDKROOT value on / !
Click apply
You should be able to use the NDK now and compile without errors.

Found a work-around solution to my question with the help from this forum: https://groups.google.com/forum/#!topic/android-ndk/YPFPa9Fen7Y
I downloaded an old copy of the NDK (r5b) and there were no errors when setting up the path, as opposed to r9 the most recent version. As the forum says, the problem lies with Sequoyah which has not updated since 2011 and can not recognize the new structure of that the NDK is laid out in. Hope this helps someone in the future. (If you find a direct solution though, let me know.)

Instead of downloading another version of the NDK, I simply created links inside the build folder to the toolchains, prebuilt and platforms which recreates the folder hierarchy of the r4 NDK.
Doing this made the plugin happy, and I only have one version of the NDK on my computer.

Related

How to change built-in C/C++ paths pointing to a deleted android-ndk-r9 installation?

I recently upgraded my NDK from android-ndk-r9 to android-ndk-r10 (r10d to be exact). Eclipse is 4.4 Luna (Luna Service Release 1 (4.4.1); Build id: 20140925-1800). Eclipse is fully patched for its release. I updated all the Eclipse plugins (including ADT) so they are fully patched. And I also changed my ANDROID_NDK_ROOT in .bash_profile to point to the new NDK directory.
Under the Eclipse Preferences → Android → NDK, Eclipse is showing the new android-ndk-r10 path (I had to set it manually).
Under the Project Properties → C/C++ General → Paths and Symbols, Eclipse is still showing the old android-ndk-r9 path.
Eclipse considers the path built-in, and unchecking the Show built-in values check box makes all the paths disappear. In addition, the Edit... button is greyed out.
I've grepped the following directories, and I cannot find the string "android-ndk-r9":
My Eclipse workspace
~/.eclipse
The project's directory
~/Library
/Application/Eclipse
/etc on the OS X machine
/Library on the OS X machine
The project builds fine. The bad configuration just creates hundreds of errors in the list on the Problems tab. (To duplicate, you need to open a C or C++ file):
Where is the setting coming from? And how do I change it?
This appears to be related: How to remove auto-discovered paths after compiling on Linux from Eclipse CDT project?. But I can't find Discovery Options → Clear discovery entries now (it appears to be a Eclipse 3.x feature). Ditto for Eclipse CDT Invalid Project Path.
This appears to be the Eclipse bug report covering the issue: Include path discovery doesn't discard obsolete paths on compiler upgrade.
Where is the setting coming from?
It appears the information is held in the project's pathInfo file. Below, the project is a sample JNI project called AndroidPrng.
$ cat /Users/jww/Eclipse/.metadata/.plugins/com.android.ide.eclipse.ndk/AndroidPrng.pathInfo
t,1421045575000
i,/opt/android-ndk-r9/sources/cxx-stl/stlport/stlport
i,/usr/local/cryptopp/android-armeabi/include
i,/opt/android-ndk-r9/sources/cxx-stl/system/include
i,/usr/local/cryptopp/android-armeabi/include/cryptopp
i,jni
i,/opt/android-ndk-r9/platforms/android-14/arch-arm/usr/include
i,/usr/local/cryptopp/android-x86/include
i,/usr/local/cryptopp/android-x86/include/cryptopp
i,/opt/android-ndk-r9/platforms/android-14/arch-x86/usr/include
i,/usr/local/cryptopp/android-mips/include
i,/usr/local/cryptopp/android-mips/include/cryptopp
i,/usr/local/cryptopp/android-armeabi-v7a/include
i,/usr/local/cryptopp/android-armeabi-v7a/include/cryptopp
i,/opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.6/include
i,/opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.6/include-fixed
i,/opt/android-ndk-r9/platforms/android-14/arch-mips/usr/include
d,__STDC__,1
d,__INT64_MAX__,9223372036854775807LL
d,__LDBL_HAS_QUIET_NAN__,1
d,__WINT_TYPE__,unsigned int
d,__ORDER_LITTLE_ENDIAN__,1234
d,__DEC64_MAX_EXP__,385
d,__UINT_LEAST32_TYPE__,unsigned int
d,__UINT_FAST64_TYPE__,long long unsigned int
d,__GXX_WEAK__,1
...
I've grepped the following directories ... "My Eclipse workspace, ~/.eclipse, " ...
There were two problems here. First, the project is located on my desktop, and not my workspace directory. Second, the 100's of entries in the log files under org.eclipse.cdt.ui drowned out the entries 15 entries for com.android.ide.eclipse.ndk.
So, before you grep, perform:
rm Users/jww/Eclipse/.metadata/.plugins/org.eclipse.cdt.ui/*.log
That will produce manageable grep results.
And how do I change it?
Exercise left to the reader.
You can edit by hand; or you can delete it and Eclipse will recreate it with the new NDK-related paths.
OP probably figured this out already but adding this here just for future reference.
Eclipse (currently) has issues with the r10d version (see the related discussion in https://stackoverflow.com/a/28108753/1591421). First, if possible one should rollback to an earlier version of the Android NDK (e.g. r10c seems to work just fine) and then make Eclipse point to the newly installed version of the NDK: Preferences -> Android -> NDK -> NDK Location. To let Eclipse pick up these changes the project needs to be deleted from the workspace and then added back (at least I had to). After the project has been re-imported one should see the NDK paths updated: Project -> Properties -> C/C++ General -> Paths and Symbols. Rebuilding the C/C++ Index (Project -> C/C++ Index -> Rebuild) won't hurt either :)

Android NDK build, Method could not be resolved

I have an Android project with native code. I'm able to build native code from command line by calling ndk-build command with no errors or warnings. But when I open it in ADT it shows the following error.
Error message: Method CallStaticIntMethod could not be resolved. There are many files with similar errors in the project.
I double checked configuration and here is what I have. Android build, tool chain and includes are properly configured (see pictures below)
Required includes are also visible in the Project Explorer and they are valid (not empty and point to correct header files).
But when I Clean the project and Build it, the errors are still there. Any ideas on how to solve this?
Configuration: ADT 22.6.2, NDK r9d (64-bit), OSX 10.9.2
After some struggling with preferences, I finally found a solution. This is a bug in NDK plugin which was reported to AOSP but not yet fixed. A past of the answer is described in comment #50. Here is the sequence which worked our for me.
Open Project Properties -> C/C++ Build -> Tool Chan Editor
In the section Used Tools replace Android GCC Compiler with GCC C Compiler. If section is empty, just add GCC C Compiler entry in there.
Open Project Properties -> C/C++ General -> Paths and Symbols and add directories, where your h-files to be included are located. Use Move up button to add a folder with your local includes (/AudioPlayer/jni in my case) to the first place. Then add platform and toolchains includes. Built-in includes should stay at the very bottom.
In my case the full paths to the toolchain includes were like below. These are built-in paths of original Android GCC Compiler toolchain, which we have replaced at step 2.
/Tools/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.6/include
/Tools/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.6/include-fixed
Press OK button, clean and re-build the project. All errors must go away. If they stay, try to remove them from Problems view and re-build project once again.
Update: I have found another place, where you can add paths to include files. However it appears to be Eclipse version dependent. Project Settings -> C/C++ General -> Processor Include Paths, Macros etc. -> CDT User Settings Entries -> Add. After I added the paths listed above, there is no compilation issues anymore. Development is fun again.
Yes, its caused by the IDE not knowing where all of your headers and any libs you linking again are. The errors are generated by the IDE's autocomplete/bug system. You can either fix your includes within eclipse or remove them as errors in the preferences. 
I had a similar error and solved it by going to project->properties->discovery options and changing the discovery profile from managed build system to GCC, after changing to GCC C Complier from Android GCC Compiler and updating the include directories.

Program "/opt/adt-bundle-linux/android-ndk-r8e/ndk-build" is not found in PATH

I imported an existing Android project to my Eclipse.
I get an error in the project that prevents me from building:
I get this message in "problems":
Program "/opt/adt-bundle-linux/android-ndk-r8e/ndk-build" is not found in PATH
and the problem type is: C/C++ Problem.
I have a windows machine with Eclipse (ADT) and Java up to date and I suspect that the original project where this project was built, is different (perhaps it is Linux?), or perhaps it makes use of native code and my Eclispe is not configued to support it. I don't have such an issue with other projects in my Eclipse...
Please, advise....
thanks.
as Chris Stratton stated, this project is made on a Linux machine.
You can change your PATH if you go to: Project -> Properties -> C/C++ build -> Environment
You can edit PATH there. After you've deleted that "/opt/.." you should add the path of your own ndk-build. If you don't know what ndk-build is take a look over here: https://developer.android.com/tools/sdk/ndk/index.html

Tesseract OCR Android in Windows

I've read all of questions forums and blogs about it but i still have a problem. Firstly, i ticked tess-two as a library also my project's using tess-two as a library. I downloaded Android-NDK and from my project's properties i clicked Builders and then new -> Program then i choose ndk's ndk-build file. By the way my project is Gautam Gupta's project. He'd given project. Link: https://github.com/GautamGupta/Simple-Android-OCR. When i run that project in my phone, application starts and captures photo but when i press save then application gives error below. http://t1307.hizliresim.com/1c/l/qg0rl.png
Looks like you need to download only TessTwo, make sure you have properly setup the environments variables (ANT_HOME, ANDROID_HOME and ANDROID_NDK) so these point to where you have Ant and Android SDKs.
Then it's a matter of building the project by following TessTwo guidance. That you set up the library-project that can be imported.
Don't forget that the line commands must be performed in CygWin. Once the library project is built you should have correct .so files in libs/*. In order to actually use these, you could start with this link.
#Burak:
I have solved my problem. For Windows;
Write the codes below to Cygwin
a.cd <project-path'i>/tess-two
b.export TESSERACT_PATH=${PWD}/external/tesseract-3.01
c.export LEPTONICA_PATH=${PWD}/external/leptonica-1.68
d.export LIBJPEG_PATH=${PWD}/external/libjpeg
e./cygdrive/<ndk-directory>/ndk-build
Write the codes below to CMD
f.android update project --target 1 --path .
g. ant release
Don't forget the "." at step f.

java.lang.NoClassDefFoundError on Android sdk and ADT 20 Windows 64

Good morning ppl. I have what it looks like to be a commong problem in android, import jars from libraries. I'm trying to use a library to consume an in house api. I copied the jar into the libs folder on my android project and went to
Properties -> Java Build Path -> Libraries and added the jar. Also, I checked the boxes within the jar name in the Order and Export tab. all I have is the
java.lang.NoClassDefFoundError exception.
I have read almost every post that points to the same answer. Put the jar on libs folder and make the steps listed above. Nothing worked. I'm running the ADT v 20, on the Indigo release on a Win 7 x64. I'm not very skilled on java or java architectures but this is driving me nuts. Anyone has a differente approach to this? I'm missing something?
Thanks in advance
You need to simply drag the jar file into the libs folder and not manually add it. Try deleting the jar file from
Properties -> Java Build Path -> Libraries
clean and rebuild the project.
Explanation:
The process of loading library has been automated and changed from ADT 16 onwards and it is not backward compatible with the older method. You were actually trying to use both the methods of adding library which was adding the library twice and breaking it.
Go on the tab "Order and Export", inside "Properties->Java Build Path" and check the unchecked boxes. It worked here...

Categories

Resources