Debugging libcore String.java file in Android using Eclipse - android

I am trying to resolve this issue http://code.google.com/p/android/issues/detail?id=24417
I want to put a break point (or logs if possible) in the regionMatches() method of java.lang.String package in Android ICS.
I tried multiple times using Eclipse, the code never breaks at that point. I even tried putting a break-point into a calling method and then Stepping into it, but it simply doesn't works for String.java but works fine for every other thing I tried.

I have the same problem with JDK 1.5. The problem is that you class files doesn't contain some debug byte-code information. Solution, that I found was to download the source and recompile it's with debug information enabled.
See Determine whether .class file was compiled with debug info? for more details.

Related

Warning when building app: "Expected stack map table for method with non-linear control flow."

I have a project on which I worked last year. Recently I started working on it again but wanted to update everything that was possible. I managed to resolve basically all problems except this one. I can't find anything online about this warning. I get it when I build the project. I tried downloading and using the latest tapjoy jar but it still appears. In the warning there is a path to a cache folder so I tried deleting it but id didn't change anything; maybe I'm getting this warning because those folders are missing?
The full warning is like this:
AGPBI: {"kind":"warning","text":"Expected stack map table for method with non-linear control flow.","sources":[{"file":"C:\\Users\\black\\.gradle\\caches\\transforms-3\\91514d5ad9a3a762574d6c5e2880beba\\transformed\\jetified-tapjoyconnectlibrary.jar"}],"tool":"D8"}
The problem is that i have around 200 lines of this warning in console and I would like to solve them.
Has anyone seen this warning before and knows how to fix it? Obviously any help is much appreciated.
The missing folder should have nothing to do with this warning. I had this problem in the process of writing custom gradle plug-ins. It seems that ClassWriter or ClassVisitor in ASM did not implement any method, there will be this warning, but that does not affect normal functionality. You can check that your project has used those gradle plug-ins, perhaps these plug-ins are caused by the update of the problem.

Extracted code from apk showing a number of java code errors

I recently read about the concept of reverse engineering and wanted to try it.
So I downloaded an apk and extracted it source code by using
apktool, dex2jar and jd-gui
Every thing went on smoothly and I extracted the resource as well as java files successfully. However the problem arose when I tried to import this project in android studio.
Initially it was showing a number resource files related errors which I corrected by changing the dependencies of the project but now I am getting all these weird errors in java files.
The errors include "not a statement', 'variable not initialized' etc.
Kindly Help. Thanks in Advance!
I have extracted code from apk before myself, and the results I got were similar to yours. I got most of the code, but not all of it and not with all of the formatting. Numerical constants were missing and the the "if, while, for" instructions were faulty. I don't know if this always happens, I did it only once, but I managed to figure out the rest of the code by what this processes gave me in the begging.

java.lang.NoClassDefFoundError with external jars in Android project

I've been searching the internet for two days now, and I feel like I've tried everything.
Please let me know if any code snippets might be helpful in finding a solution.
I've created an android application with the standard login activity. In the doInBackground()-method, I invoke a static method from another external class. Since this method will be invoked once the submit button is clicked, the error occurs during runtime. The class is included in my file, and there are no compilation errors. Whenever I tap/click on the Submit-button, I get a java.lang.NoClassDefFoundError referring to a class (in my external jar) that is used and properly included in my external file I refer to in the doInBackground()-method.
All my external libraries are in the 'libs'-folder. I've tried adding them to the build path manually instead and checking the boxes next to them in the 'order and export'-tab instead of the checkbox next to the 'Android Private Libraries' entry. I've tried putting the 'gen'-directory above the 'src'-directory, which didn't change anything either. Restarting eclipse, reimporting the project as a whole, playing around with the order of the external libraries in the build path, fixing project properties and cleaning the project over and over, nothing helped. I've checked this
http://javarevisited.blogspot.de/2011/06/noclassdeffounderror-exception-in.html
and tried every solution, but none of them worked for me. I ad a similar problem with a library before, and I could solve it by changing some build path settings and restarting Eclipse. However, this just doesn't work for me any more. I hope anybody has another solution or an idea, I have no clue what's wrong...
Thank you all in advance!
Yeehaw
Edit:
Despite creating a whole new project and adding my previous files to this new project, I still had the same problem in the new project. I think I figured out where this error came from: When I added my external library, I still had dependencies from the just added .jar to other jars. After adding those as well, the compiler said I needed the java.rmi.Remote class, which is in Java's JRE system library (rt.jar). Adding the whole jre library to my project made the compiler error disappear, the runtime error, however, still persisted.
After some more research I found out that my external library is probably not compatible with the android runtime environment, which means that the jar's .class-files don't have an equivalent .dex-representation which is neededfor the Dalvik virtualmachine on android powered devices. For many java jar's, especially those designed for use with the android platform, those problems don't occur.
Please correct me if I'm wrong, but this explanation seemed pretty plausible to me. Too bad, since this is the only way to currently access our database programmatically.
Make sure you've updated to the latest version of ADT Eclipse plugin and SDK Tools and also make sure "Android Dependencies" is checked in your project properties.

dx.bat hangs while processing .class files

I'm using dx.bat to prepare my java code and java libraries I'm using for device. I have several .jar's, and the tool always hangs on the same class. It doesn't finish or report any errors. If I remove the .jar that contains that class, then dx.bat completes successfully, but the app won't run, of course, because classes are missing.
The .jar causing problems is aws-android-sdk-1.4.0-core.jar, from Amazon. The class is com/amazonaws/javax/xml/stream/StaxErrorReporter$1.class
I've searched extensively and found other dx errors, but not this one. Has anyone else seen this happen?
UPDATE: I'm running dx.bat from a java build tool I made when it hangs. I tried running the same command from the windows command line, and it runs just fine. So the problem appears to be with java?
Well, it turns out the problem was my java code that was running dx.bat. The issue is explained here:
Java Process with Input/Output Stream
I redirected the error stream, and now it's working.

How to hit breakpoint in library?

I have an Android app that is using an Android library; both projects are open in my Eclipse workspace. I want to create a breakpoint in the library code and have the debugger hit it while i'm debugging the application.
Currently, when I am debugging the application, I can hit breakpoints in the app code but it will not stop at any breakpoints in the library code.
Some quick googling has resulted nothing related to this task.
Is this possible? Am I doing something wrong?
Thanks,
Chris
EDIT ---
OK, I see now how to attach the code to the library and hit breakpoints in the code. I can do this for one library, but for some reason I can't attach the code to the library I really need to debug, but that's an entirely different issue...
Thanks for replies!!
I realized the problem now... The way to hit breakpoints in a library is to attach the source code as suggested by Cristian. However, this was simply not working for my library and I couldn't figure it out for the longest time.
I found out later that in the build process of the particular library, there was an obfuscation step that rearranged the source files, changing their packages. That's why Eclipse couldn't figure out how to map the .class files in the .jar to the .java files in the workspace project... they were in differently named packages.
Thanks for the replies :)

Categories

Resources