I have an Android library source code and .jar archive for that library. I also have and Android app that makes use of that library. My library source code and Android app are in the same Eclipse workspace. So, I added .jar archive to build path of the Android app, and attached source code to that .jar archive.
I am able to look inside the functions I call in my app, but when I am debugging, I can not step through the functions from the library that I am calling. In the debugger it says "line: not available".
How can I make it so that I can step through the code in the library? I know that in the Java compiler settings for the Android library, I have to check the box on "Add line number attributed to generated class files", which I already did for both Android app and Android library.
Did I miss something? Why do I still get "line: not available" message in debugger and can't step through the code from library?
Both library and app are compiled with Java 1.6. Android app's build target is Android 5.1.1, and libraries' build target is Android 4.0.3 .
I actually figured it out. I was using .jar archive for this library, but this .jar archive wasn't generated by me and apparently did not allow for line numbers to be added to generated class files. I exported my own .jar archive, linked source code to .jar archive, and was able to debug the code without any issues.
Related
I have an APK which is debuggable="true" (according to the AndroidManifest), meaning I can debug it and this is what I want to do.
I used Android Studio: File -> Profile or Debug APK to load the apk (app.apk).
When I am trying to debug it (Shift+F9) it writes me:
Disassembled classes.dex file. To set up breakpoints for debugging,
please attach Java source files
I used jadx to decompile the APK to java source code by running:
"c:\tmp\jadx-0.8.0\bin\jadx.bat" -d java_source app.apk
I now have inside the java_source directory two directories:
- resources
- sources
Inside the sources folder I have the java files.
How can I attach them to the Android Studio project as it requests by the message?
Just open it as a new project?
Looks like the answer you want is available in the android docs (https://developer.android.com/studio/debug/apk-debugger#attach_java):
By default, Android Studio extracts Java code from your APK and saves them as .smali files. To debug the Java code using breakpoints, you need to point the IDE to the .java source files that correspond to the .smali files you want to debug.
To attach Java sources, proceed as follows:
Double click on a .smali file from the Project pane (use the Android view). After opening the file, the editor displays a warning banner asking you to select the Java sources, similar to what's shown in figure 1.
Click Attach Java Sources from the banner at the top of the editor window.
Navigate to the directory with the app’s Java source files and click Open.
In the Project window, the IDE replaces .smali files with their corresponding .java files—The IDE also includes inner classes automatically. You can now add breakpoints and debug your app as you normally would.
The current Jsoup release 1.7.3 has a known issue that it is using String.isEmpty() which is not supported by Android API Level 8.
I can see crash report of my app so I tried to fix this by change the source code of Jsoup and build my own jsoup.fix.jar. I test this jar with JAVA application and it worked fine on my PC.
I noticed that when I remove the original jsoup-1.7.3.jar from my project, there is errors complaining cannot find jsoup stuff, and the those errors are gone after I add the jsoup.fix.jar which seems to be good. I also check the JAVA build path and the exporting configurations, jsoup.fix.jar are all set as it should.
However, when I tried to run the APP on my Android devices, the APP crashed and saying it cannot find org.jsoup.Jsoup.
I checked the jsoup.fix.jar, opened it with JD-GUI and find the classes are all there, but I used my dex2jar to convert the classes.dex in my /bin directory, I cannot see nay org.jsoup stuff.
Just replace my jar file with the original jar will not have the same issue reproduced.
I also noticed that in my jar, the MANIFEST.MF file only have one line of content, but in the released jsoup-1.7.3.jar, the MANIFEST.MF contains a lot of content.
I am confused now, questions:
Am I doing wrong when build my own jar?
Why the APK still cannot include the jsoup pacakage even I configured it to do so?
Finally I found the reason might be the jar is exported from a JAVA project.
I have tried to create an Android project and copy the source files into it and then export another jar file, and it works!
Could anybody explain why?
I am new to Android development and I have downloaded Source code of Cameraapp from Google web site from following locaiton:
https://android.googlesource.com/platform/packages/apps/Camera
I am trying to build and compile it into the Eclipse ADT environment. However when I open the folder using File> Import> Android> select existing project, I do not see the folder being able to be selected as a project.
I also noticed that there is no Android Manifest file inside this folder. How is this possible?
I read somewhere that camera app does not have its own Android Manifest file but it uses manifest file from the Gallery App. Which may be right. But my question is that how can I even compile this application?
Or would I have to compile the entire android application folder? Hopefully that is not the case.
If you do not have manifest file in the project then you have no option than to create an empty android project and copy the corresponding res/ and src/ file to your empty project.
Then modify your manifest file to define your activities and permissions. Then you can build and run your project in your ADT workspace.
I'm not actually working on android devices, but I'd like to use the android java std lib for a project of mine. I'm extracting the android java std lib from the android ADT here:
http://developer.android.com/sdk/index.html
After unzipping the bundle, it's in
adt-bundle-windows-x86_64-20130729\sdk\platforms\android-18\android.jar
However, when I open this up in Intellij, it doesn't show any source code: all methods are just labelled as "compiled code"
Is there any way to get the source code (in a jar or otherwise) for the android.jar so I can hook it up to the IDE so I can nicely browse the source code of the standard library? I've dug through the sdk download bundle and haven't found anything.
-Haoyi
but I'd like to use the android java std lib for a project of mine
I have no idea why you think that would work, any more than trying to use a Windows DLL on Linux.
Is there any way to get the source code (in a jar or otherwise) for the android.jar so I can hook it up to the IDE so I can nicely browse the source code of the standard library?
The source code for Android is at the Android Open Source Project. The source code for the android.jar is mostly in the platform_frameworks_base repo (GitHub mirror), but the JAR is really an output of a firmware build.
In your Android SDK root directory, go to the sources folder. Here you will find the source files for the different platforms you have downloaded.
Note: This gives you the Java code for Android libraries such as Activity
Unpacking the jar is way more than you need to worry about. Android is open source, so you can get everything you need online. To start, you can browse most of the source on Android's GitHub account, or download the source tree on the Android Open Source Project website. You can also view most (if not all) sources on GrepCode.
If you really want to go through the trouble of extracting the jar and decompiling the source, you can use JD-GUI.
As you use eclipse, use
jadclipse
which extrach any jar that in eclipse, u can view any source code with out download and also without internet. It has also export source code, As a developer It help u most times. :->
link to download
When I open the android jar I'm not able to see .java files , it shows .class files in it .
Please suggest me how to add android jar to eclipse.
Waiting for an early response.
If you want to check the java code of android you should better visit Andrdoid x-86 branch wesite and follow the instructions there.
But you can not see the java code by adding its JAR file in the eclipse project class path.