I have two Android Projects 'A' and 'B'. 'B' depends on 'A' and is a Library. Whenever I'm in Project 'B' and hit 'Open Declaration' for a Java source file which resides in 'A', Eclipse navigates to the class file instead of the source file. This of course has several disadvantages!
I had a look at the build path of project 'B' to see if the referenced library 'A' has the correct path to it's source project which is the case.
Anyone knows how to fix that?
Here are the .classpath and project.properties files for each project:
ProjectA .classpath
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="gen"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry kind="output" path="bin/classes"/> </classpath>
ProjectA project.properties
# This file is automatically generated by Android Tools. # Do not modify this file -- YOUR CHANGES WILL BE ERASED! # # This file must be checked in Version Control Systems. # # To customize properties used by the Ant build system use, # "ant.properties", and override values to adapt the script to your # project structure. # Project target. target=android-8 android.library=true
ProjectB .classpath
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="gen"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry kind="output" path="bin/classes"/> </classpath>
ProjectB project.properties
# This file is automatically generated by Android Tools. # Do not modify this file -- YOUR CHANGES WILL BE ERASED! # # This file must be checked in Version Control Systems. # # To customize properties used by the Ant build system use, # "ant.properties", and override values to adapt the script to your # project structure. # Project target. target=android-8 android.library.reference.1=../ProjectA
Right Click on the project -> Properties -> Project Facets -> Click on the Configuration Link -> Click on Apply Button -> Click on OK button.
You can select an element name in your code and quickly navigate to its declaration. Open declaration will attempt to navigate to the exact definition of the selected element if the selected element is a reference or a declaration.
You can't use Eclipse to run an external class file with a main method without creatin a java project with this class in its class path. This would give Error: Could not find or load main class classname.
There are two ways to debug a class file. The first way is to set the decompiler preference, and to realign the line number. The second way is to check the debug mode in the decompiler menu bar. When your Eclipse workspace is in debug perspective, the debug mode becomes the default.
You can import the library project not only as an Android Lib (that is the way it's meant to be done), but also as a linked project in the usual "Java Build Path" menu. Next, be sure to move this import to the top (at least more that "Library projects" entry) in the "Order and export" tab.
This works, but it a hack and it's dirty. This is not the way it is meant to be done... and when you deploy the app to the phone, eclipse will write a error message in the console saying that some apk cannot be found...
Still, I find it more convenient that linking to the class file.
I don't know what this is happening. My buddies in the office are running the same configuration than me, and they have not this issue, but it seems we are not the only ones whith this problem: http://code.google.com/p/android/issues/detail?id=20731
I had the same problem when my version of library project A was in "Properties > Java Build Path > Libraries", but not in "Properties > Java Build Path > Projects".
The problem was solved after I did the following:
The .classpath should have the following:
<classpathentry combineaccessrules="false" kind="src" path="/A"/>
Actually navigating to class files was not the most annoying, but breaking in class files instead of java files during debugging was driving me crazy before this problem was solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With