On my Windows platform, I have the latest version of adt bundle (20140321) and ndk (r9d) installed. The installation is as clean as it gets. The environment variables NDK_ROOT, PATH, etc. are all defined properly.
The app I am working on has some C++ native code. The code builds fine both outside Eclipse as well as within Eclipse.
The problem, however, is that the editor complains that jni.h is an unresolved inclusion.
Project-->Properties-->C/C++ General-->PathsAndSymbols shows include directories and one of the directories is C:\adt\ndk\platforms\android-19\arch-arm\usr\include. I have verified that jni.h is present in this directory.
I have already checked all other messages on this forum but couldn't find any concrete steps. Appreciate your guidance. Regards.
I ran into a similar problem with a working project with Android NDK-based code after updating to Eclipse Kepler. I observed similar things: the header files would correctly be listed under "includes" in the project, the actual build (via ndk-build) worked fine, but Eclipse's editor couldn't locate any headers in standard system directories (all headers with < > brackets).
I tried many different fixes, including switching toolsets, rebuilding indices etc. without success.
Finally, I removed the C nature entirely from the project, and added it back via the "Android Tools" menu in Eclipse.
Removing the C nature:
The only way I could find to reliably removed the C nature from the project was by hand editing Eclipse's .project file for the project.
Close the Eclipse project (e.g. by quitting Eclipse).
Open the .project file in a text or xml editor. There will be at least 2 <buildCommand> nodes that need to be removed. Remove the <buildCommand> node with name org.eclipse.cdt.managedbuilder.core.genmakebuilder and all its children, and the <buildCommand> node with name org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder and its children. Finally, remove the lines:
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
Completely remove the .cproject file.
Adding back the Android Native nature
Reopen the project in Eclipse. Then right-click on the project in the Project Explorer, and from the "Android Tools" contextual menu, choose "Add Native Support...".
Looking at the changes made in the .project and .cproject files before and after this change, it appears that it primarily gave new version numbers to the Android NDK tools. In any case, it solved the issue for me.
after add native support,right click project, add includes in c/c++ general--> paths and symbols >> includes, for example add include as %NDK_HOME%\platforms\android-19\arch-arm\usr\include
I had the same problem some days ago. I found a fix in another question here in stackoverflow, but now I can't find the link.
In Eclipse: right-click on your project > Properties > C/C++ General > Code Analysis > Launching and disable both options ("Run with build" and "Run as you type").
There seems to be a problem with CDT and the Indexer, doing this you hide the problem. The editor will still complain but now you should be able to run and debug your application.
I solved this for adt-bundle-windows-x86_64-20140321:
No any environment variables is set, just pointed NDK location under Preferences > Android > NDK.
I created new, clean Eclipse workspace.
Deleted from my project with C++ code next files/folders:
.settings .classpath .cproject .project project.properties
Eclipse > New > Other > Android > Android Project from Existing Code > then point folder with your project, let Eclipse detect it, check "Copy project into workspace" and click Ok/Next, whatever.
Clean project.
Right click on project > Android Tools > Add native support
Rebuild, possibly restart workspace.
Also this solved issue with Eclipse 4.3 previously ignored build system and user defined compiler flags. Now macros folding dependent on this flags etc works fine.
If more general - NDK plugin can properly define for you right includes and anything other required to work fine, but you need to clean your project from broken crap.
Related
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 :)
I have an Android project that I've been happily building for weeks in Eclipse Indigo. I have not changed any settings, libraries, or workspace components, or added or removed any files. A few hours ago I was doing a "Run as" to run my app on a phone and Eclipse did a hard hang. I couldn't even kill it in Task Manager so I rebooted my PC.
Now when I try to build my app I get
"The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project"
I deleted gen and did a clean and build with the same result. In the project Properties for the build path, in the Libraries tab it shows
Android Dependencies
Android Private Libraries
Unable to get system library for the project.
Any idea what's going on? This Eclipse "build path is incomplete" error is very common but when I search Stack Overflow and Google, most of the cases seem to be related to importing new projects, moving workspaces, changing libraries or other things I didn't do.
Thanks in advance!
I fixed my problem.
I did a File>Switch Workspace and switched to another workspace that had a different project in it. Then I switched back to my original workspace and everything was fine.
So we can add this to the very long list of folk-remedies, nostrums, old-wives-tales, superstitions and other bits of software lore that accompany the various weird bugs that afflict Eclipse. I sure hope Android Studio turns out to be better than this!
This worked for me:
Open project properties > Java Build Path > Libraries.
Select "Unable to get system library..." > Remove > OK.
Open Libraries again > Add Library > "Android Classpath Container" > Next > Finish > OK.
The following worked for me, so I thought I would share.
Restarted Eclipse and ran into the same problem.
Did the following to get my project to build again.
Right click on project inside Package Explorer and Select properties.
Go to Java Build Path.
Click on Libraries TAB
Remove the line that says "Unable to get system library for the project"
select ok.
Then right click on project, and select "Android Tools" -> "Fix Project Properties."
Hope this helps.... eclipse can be a real PITA sometimes.
BTW I "watched" for any changes after the delete and fix, and it looks like
Is removed from .classpath, and then the "Fix Project Properties" adds the line right back.
Clean + Build works after that.
The resolution was to force a resave of the selected projects (and their .classpath files):
Open the project properties
Select Java Build Path > Libraries
Add a new, arbitrary library (to be deleted later) > OK
Wait for the workspace to refresh (or force a refresh of the project)
The error(s) will go away
Remove the dummy library
Try Project-->Clean. Also make sure "Build Automatically" is checked
Ever since upgrading my current projects to use the new R14 Tools in Eclipse, I'm now unable to debug any code that exists in my library projects.
When I hit a break point in my library project code, instead of Eclipse opening the original source file, it opens up the read-only copy of the source file contained within the JAR with the message "Source not found".
I've searched around for a solution to this, but have yet to come across anything. Does anybody else have any suggestions? It's quite a pain not being able to debug.
EDIT
The issue has came back and I'm no longer able to debug. I haven't changed any project settings around or anything. Very frustrating.
Tried all of the above and it did not work for me, however the workaround detailed here did.
http://code.google.com/p/android/issues/detail?id=20731
Start debugging, and run until you hit a breakpoint (and precisely get a .class file instead of the .java you would like to have)
Right click in the Debug view of the Debug perspective (for example on the call stack), and choose "Edit Source Lookup Path"
Add all your projects above "Default", via "Add..." > "Java project" > "Select All"
(I'm using ADT 15.0.2 preview from http://tools.android.com/download)
After having this issue as well and doing a little research, I came across this thread and another one that tipped me off. I was pulling my hair out already.
It turns out that the problem is with the build order of your projects (mine was anyway). Since ADT/SDK v14 changed the way library projects are referenced, the build order needs to be correct. Make sure all of the libraries your app uses are built first. I just moved the "src" and "gen" folders for each of my projects to the bottom and now it builds the library first and I am able to debug it and view the source of my library files through the main project.
In case someone doesn't know where to do this, in Eclipse, right click on your project and "Build Path" and then click "Configure Build Path". Then, on the "Order and Export" tab, move the two folders for your project to the bottom of the list below your libraries. I did this for all of my projects and the library projects.
You can also do it globally in Eclipse from Windows->Preferences->General->Workspace->Build Order and moving your library projects to the top. I think the build order defined in each project will override this though, so you may want to do it in both places to solve the issue now and for future projects.
I had the same problem in a project today. The project consists of an app which has two library dependencies. I could not see code during debugging and when using auto-completion when overriding methods Eclipse was unable to deduce proper argument names.
First of all, the problem manifested itself by showing the the 'gen' folder was used as the one that contained the source. To check whether this is the same issue go to your app project, open the Android dependencies and have a look at the properties of the your library dependencies. Location path said /libraryprojectname/gen.
If this is also your problem then go to the 'Order and Export' tab of each library project and move the 'gen' item below the 'src' item. As soon as you click OK Eclipse will work a bit and when you check the Android dependency properties the location path should say: /libraryprojectname/src. Open click the dependency and open any class inside the jar. It should show the source.
I am using ADT plugin 20.0.3 with Android SDK Tools 20.0.3 and Android SDK Platform Tools 14.
The following worked for me on Eclipse Juno:
In Project Properties/Java Build Path:
In the Projects tab, added my library projects.
In the Order and Export tab, moved my library projects to the top, and checked them
Not sure if it's relevant, but Android SDK tools is rev 20.0.3 and Android SDK platform tools is 14.
I assume you are opeining library project and there you put brakepoint.
Try this: On main project open Library Projects->[yourlibrary.jar]->[yourfile.class] from Package Explorer, and then in .class file put brakepoints.
This works for me at least :)
Sometimes this happens to me. Not sure about the reason but the way I solve is:
Remove the main project from eclipse. -- Closs Eclipse -- Delete the jar file in the library project -- Open Eclipse -- Wait for the library project to compile -- Import the main project
This problem also occurs with release 21 of ADT inside Juno. As a workaround, in the "debug" view of the debug perspective (where you see threads and method invocation traces), right click and edit source lookup path.
In order to implement different versions of our UI we broke our program up into UI specific code and a common library project that has everything else. Up until yesterday when I updated to ADT 14 everything was working fine. Now I can't build. I keep getting the error "The container 'Library Projects' references non existing library 'path to the bin folder of my common project and the name of the project.jar'
I've been all over the web and tried everything I can think of to fix this to no avail. Can someone help me out? I'm basically stuck at this point.
Maybe you have the same issues I had when switching to the new ADT:
In my previous setup I had some resources split between the library and the main project. The library project would not compile error free on its own but only in combination with the main project which added the missing resources.
It doesn't work like this any more.
The library project must compile completely error free now. When it does the build process will create a <lib_project_name>.jar in the bin folder of the library project.
If the jar file is not created ( thus the build process of the library project failed for some reason - eg. because the changes in the R.java file (see http://tools.android.com/recent/buildchangesinrevision14 )) you will get the error message you described.
Also, I had to manually remove the <lib_project>_src from the project.
I've had a problem with a few different projects where I did the fixes suggested in the other answer, but they were only fixed temporarily.
Every time I reopened Eclipse or did a Clean on a project, the "Library Projects" directory would disappear, and I would have to open the project properties, remove the library, and add it again.
I solved this the hard way by creating a new project and copying everything into it.
Then I found an easy way to solve it. Right click the project, Refactor-->Rename. You can rename it back afterwards. This fixed it.
Check out the article "Changes to Library Projects in Android SDK Tools, r14" ( http://android-developers.blogspot.com/2011/10/changes-to-library-projects-in-android.html ) on the Android Developers blog.
E.g. #P.Melch: "I had to manually remove the _src from the project" should be done as follows:
To fix the project, you must remove the extraneous source folders with the following steps:
Right click source folder and choose Build Path > Remove from Build
path.
A dialog will pop up. In it, make sure to check “Also unlink the folder from the project” to completely remove the folder.
You have to update the Android SDK in Android SDK Manager
Android SDK Tools Intalled
Android SDK Plataforms Installed
Android SDK Builds Installed
I created a Hello world app but get this strange error:
The project cannot be built until the build path errors are resolved
I haven't changed the project, jut created it and tried to run it.
to avoid that annoying problem i have 3 solutions that worked for me.
Solution 1)
delete your generated R.java file
inside your gen/ folder
Solution 2)
a)Delete your project from Eclipse
(i said ONLY from Eclipse, uncheck option: Delete project
contents on disk)
b) import your project to Eclipse:
file > Import > Existing Projects into
Workspace (Look for your project
previously deleted from Eclipse) >
Finish.
Solution 3)
make Solution 1 then Solution 2
It is either a spurious message you can solve by forcing Eclipse to recompute its library paths
I found the resolution for this at Scott D. Strader's blog.
To summarize the solution I only needed to add a library to my project and then remove it to force Eclipse to perform the necessary actions to resolve the problem. I would post the detailed steps here but I don't want to steal his content.
The resolution was to force a resave of the selected projects (and their .classpath files):
Open the project properties
Select Java Build Path > Libraries
Add a new, arbitrary library (to be deleted later) > OK
Wait for the workspace to refresh (or force a refresh of the project)
The error(s) will go away
Remove the dummy library
Note: as the OP mentions, a simple restart of the IDE can be enough.
Or you actually miss one critical library like a JRE library:
I needed to add the JRE library to the project for it to run. Not sure if this was due to the updated version or something else…. Any way this fixed the issue:
Project > Properties
Java Build Path
Libraries tab
Click add library
Select JRE System Library
Next
Finish
Sounds like you are missing an import or a jar. In your project in the project explorer there should be a red x on the file icon that contains the error.
In addition to the listed answers, there is one other scenario I've seen this error appear when using the sample projects included with the Android SDK. For some reason, the generated R.java file can be invalid or corrupt. You can get around it by expanding the "gen" folder in the Package Explorer and deleting the R.java file. It will immediately get regenerated and the error goes away.
Right click on your project, choose "Build Path", "Configure Build Path" -> and choose Android 2.2, or that target you specified when you created your project
I have had similar issues. for me simply closing the emulator and re-running the project works