Cannot debug android native code built on android library on eclipse - android

I have been struggling with this for 3 days and I could not get it done.
I have an android project that links to an android library, containing native code, on eclipse.
I saw this question, which is the same schema as mine, but the steps proposed there would not work.
I rewrite the steps here, which are:
Go to "Run" menu-> "Debug Configurations"
Under "Android Native Application" in the left pane, select your application
Under the "Debugger" tab click "Add..." in the "Shared Libraries" section.
Browse to your android library project directory and add its subdirectory obj/local/armeabi.
Apply and debug.
First problem was, I could not set up Debug config for native app if the application is not set up as native, (only links to a native app), so I cannot select any project to debug.
I tried setting the android app project as having c/c++ nature, with dummy jni/Android.mk, as just not showing any error on build. (I doubt this is the right way to go, though)
The app then runs and links correctly, and I am able to follow those steps --1 to 5. But as I debug it, the console shows (BasicCharacterWithLib is the name of the app):
[2014-05-27 12:18:09 - BasicCharacterWithLib] Error while obtaining file from device
[2014-05-27 12:18:09 - BasicCharacterWithLib] com.android.ddmlib.SyncException: Writing local file failed!
And it would never stop on any breakpoint (native or not)
I am also aware of this other question, having the same symptoms on a different configuration (directly executing an app), but it remains unanswered.
I have successfully debugged another app in the same device, a test app having native code inside it, so I guess the problem cannot be due to the device config.
Do you know how to solve it?
some further details:
I use eclipse from adt bundle (version v22.6.2, sdk highest api level available is 19 and ndk version is r9)
The app runs on more than one thread (executed from java via AsyncTask), but at that point only the main thread is initiated.
The debugging process does work only in the java side if I debug it as an android app, even in multithread.
I have set APP_PLATFORM as android-14 in Application.mk, same as minSdkVersion="14" in manifest.
I also tried restarting eclipse, rebooting the device, and unplugging and plugging the USB again.

See this question. Likely it could be the same issue of the obj/local/armeabi folder not existing on disk.

Related

Android app not running after splash screen

I would like to contact you with the problem that I switched from Delphi version 10.4 to Alexandria (11.2).
From then on, my Android applications compile and build without error, but after the splash screen they do not start on Android devices, regardless of the Android version. Not even on those that ran without errors before.
I did not change the source code, only the development tool was updated.
Looking around the Internet, others are also complaining about this phenomenon, but I can't find a solution anywhere.
My respectful request would be that if you can suggest some kind of solution, please let me know, because this is why I am standing still and it would be good to move forward.
Thank you in advance for your answers.
Android system libraries have been reset to default.
There are a lot of possibilities. Here are a few steps you can use to troubleshoot this sort of failure.
Always back up your project first. Preferably using source control!
Revert Deployment
In the release notes for 11 Alexandria there is section about updates to the Android Manifest
An older Android Project Might Fail at Run Time or When Debugging
Building an older Android project in the IDE can cause the app to fail
at run time and debug time, with a Java "Class not found error". To
correct the issue, do the following:
Select Project > Deployment.
In the Deployment Manager, click the Revert To Default speed button.
It is the 7th button that looks kind of like "undo". Make sure you select the Android platform.
Test a New Project
Create a new simple project from scratch and see if it will run. Try both Android 32-bit and 64-bit. If it doesn't then there may be something wrong in your SDK Manager (Tools -> Options -> Deployment -> SDK Manager).
Look under Android on all three tabs: SDK, NDK, Java; for any warning symbols. You might need to correct a path or install Android support.
Compare AndroidManifest.template.xml
Take the AndroidManifest.template.xml from the new project you created, and compare it to the one in your project from a previous version. If you haven't modified it then you can just copy the new one over the old one.
Revert Android Libraries
Expand out the Project Manager and the Android platforms to Libraries. Right click and choose Revert System Files to Default.
More Debugging
You can use ADB LOGCAT to see the error on failure. This is super useful. There are GUI wrappers for it, like DeviceLens by Dave Nottage of DelphiWorlds.
Check the code in your form constructor. An exception here can cause a crash like you are describing.
Reboot your phone. I hate how often this fixes things for me. It should be the first thing, but it is usually the last.

INSTALL_FAILED_CPU_ABI_INCOMPATIBLE on device using intellij

I've seen some questions about this, but none with real answers nor details. Here is my case:
I have an application that uses Google Maps API v2 which works just fine. Recently I found out that I cannot get it installed on this not ARM-based device.
In order to nail down the problem I'm working with Google Maps samples provided with the SDK (\sdk\extras\google\google_play_services\samples)
which gives me the same error message at install time:
Failure [INSTALL_FAILED_CPU_ABI_INCOMPATIBLE]
I get this message only on a real device using Intellij (12.1.1)
It works fine using both Eclipse on real device and using Intellij on the Emulator configured with CPU: Intel Atom (x86)
Any help would be highly appreciated!
UPDATE
As expected, same thing happens with Android Studio
By default, IntelliJ assumes that the libs folder in the root of an Android module contains native libraries, even if it just holds jars. Thus, it packages the APK making it look like these are native libraries. I just had a similar issue where my application had no native code and would work on the default emulator, but got the ABI warning when installing on the Genymotion emulator. To fix this, tell IntelliJ (or Android Studio) that your libraries are not native code:
Open File -> Project Structure.
Click Modules on the left side of the window.
For each Android module, expand the dropdown and select the Android subitem.
In the Structure tab on the right, delete contents of the Native libs directory field (you can leave it blank).
Once you've done this for each Android module in the project and applied the changes, you may need to rebuild your project for the changes to take place by choosing Build -> Rebuild Project from IntelliJ's global menu.
Latest Genymotion wont support ARM binary. If you have native code compiled for ARM, you can use the Genymotion-ARM-Translation. Just drag and drop this file to Genymotion home folder and reboot .
Reference.
http://forum.xda-developers.com/showthread.php?t=2528952.
In android studio, Fix this issue:
1 Download Genymotion-ARM-Translation_v1.1.zip
download url:
https://forum.xda-developers.com/attachment.php?s=9f1870536cb530a1346794b6ef629e90&attachmentid=2680937&d=1397258016
2 Drag the zip file into your running virtual device and click ok
3 restart Genymotion virtual device

Android framework debugging in Eclipse

I'm working on a project where I'm making changes to the android framework sources. What's the best approach to do this in Eclipse and be able to debug? I've seen posts to attach the android source in Eclipse,but that's the 'standard' source code, not my own version.
At the moment I just make changes to the framework in a text-editor and build via commandline every time, run the emulator from commandline and start a adb logcat session to see if there aren't any exceptions, but there's got to be another (more productive/workable) way to do this?
There is an explanation how to attach debugger in the official documentation that you can find here. In my case the steps differ (Eclipse 3.7.2 and the last android tools):
Run > Debug Configurations...
Right-click "Remote Java Application", select "New".
Pick a name, i.e. "android-debug" or anything you like.
Set the "Project" to your android project name.
Keep the Host set to "localhost", but change Port to 8700.
Click the "Debug" button and you should be all set.
Then go to DDMS perspective and select a process you want to debug
(select the process in the list of processes and then click on green
bug icon). If you want to test your service, I think that it is a
part of system_server process.
Now you can switch to debug perspective.
As it is claimed in the documentation:
Once you do, you should see a list of threads; if you select one and
break it (by clicking the "pause" icon), it should show the stack
trace, source file, and line where execution is at. Breakpoints and
whatnot should all work.
What worked for me is using eclipse to edit/browse AOSP code, but use terminal for building AOSP code. Please check Debugging Android framework services. This blog explains how to setup your eclipse project that doesn't break AOSP builds and then debug using that project. Pretty similar to what the previous answer described, but uses a shadow folder so that eclipse build artifacts don't break AOSP build.

Attach Android debugger to process built with Eclipse project I don't own

I would like to debug a portion of an Android application for which I do not have the original Eclipse project that was used to build it.
I have built a .jar file that implements an Android Activity. I use Eclipse to develop and debug it, and javac/jar to build the .jar with the appropriate classes. The .jar is shipped off to a client, who then builds it into their application.
Now they would like me to debug something, and have provided me a .apk for their application that calls android.os.Debug.waitForDebugger(). I do not have their source code or project. I install and run the application, and when it hits that call, I see the process in the Eclipse DDMS tab waiting on attachment (it has the red bug icon). When I try to attach to the process in Eclipse, by clicking the "Debug the selected process" button, I get this error message:
No opened project found for <their-app-package-name>. Debug session failed!
Is there a way for me to attach to this process, without the original application project? If not, I will resort to android.util.Log statements, but I would rather not, for obvious reasons.
As I wrote above, I have my own project with all the source code used to build the .jar that was incorporated into this application. I have tried changing the package name in my test project manifest, but that does not appear to change anything as far as Eclipse is concerned.
Thanks for any help!
Answering my own question -- I created a debug configuration of type Remote Java Application, and specified the port displayed in the DDMS window. I assume I could use any JDWP compliant debugger to do this.

How do I make a basic App Engine Connected Android Project?

I'm new to this, so please bear with me. I simply want to get the basic App Engine Connected Android Project to work in eclipse.
I first downloaded Eclipse 3.7 and the Android SDK. I installed the ADT plugin through eclipse. I configured eclipse to point to the sdk and created an android project. I added some widgets, messed around with SMS messages, and ran it on my phone. Worked like a charm.
Then I decided it was time to work with app engine. I downloaded the Google plugin for eclipse from within eclipse using this link http://dl.google.com/eclipse/plugin/3.7. I also downloaded the Google App Engine Java SDK from that link.
Ok, here's where it gets more fun. I created a new app engine connected android project and named it "TestProjectThree". I then clicked "Debug as->local app engine connected android project". On the console I got a url, but on my phone I got a black screen. I then noticed that there was nothing in the android/gen folder, so I did a clean build of both projects. Suddenly, it gave me 10 warnings.
"Cannot fully validate context since domain type com.testprojectthree.server.HelloWorldService is not available.
You must run the ValidationTool as part of your server build process."
I googled the problem and found this link http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation.
I began following the instructions. I tried to enable annotation processing, but it was already enabled. I tried to add the requestfactory-apt.jar to the factory path, but it was already there too.
Apparently now I need to run something called an Annotation Processor. I've never used Maven before but I right click on my android project->configure->convert to Maven project. I do a clean build and a POM file appears. I then copy all of the XML from that link to the line right above the /project line in the POM file. I copy the second bit too because I'm using indigo. Clean and build again. New error.
"/TestProjectThree-Android/gen already exists but is not a source folder. Convert to a source folder or rename it."
No idea what that one means either, but I see right click gen->build path->convert to source folder so I click that too. Clean and build again. NO ERRORS!! YAYAYAY!!!
Debug as local app engine connected android project. Got a black screen on the phone, and some sort of error in eclipse. “Source not found”. Looked for a more detailed error message but the console just has the app engine url on it and logcat looks empty.
I went back to the link about the validation tool and read all the comments. A lot of people seemed confused. I have no idea if I did it right, or did any of it right, and am very lost now. Please please please help me!!!
This sounds very similar to a problem I had, although not exactly.
I think the code generated by the AppEngine project that is used by the Android project is either not generated correctly, or needs a refresh.....and clean doesn't do it.
Try this:
First, make sure the requestfactory-apt.jar was in the "Factory Path" of "Annotation Processing" in the "Java Compiler" section of Project Properties.
In AppEngine project.
Properties-> Java Build Path, Source section. Select the ".apt_generated" entry and then "edit…" and rename it, by putting a "1" at the end of the name (or whatever).
Project -> Clean
then in Android Project
Properties-> Java Build Path, Source section.
Select the "apt_generated" source folder that is linked to the ".apt_generated" source folder in the AppEngine project.
"Edit…", then in the first line "Linked Folder Location" navigate to the NEWLY named folder in the AppEngine project (the one with the "1" at the end……)
Then Project -> Clean
Then build & run your Android project, it should now have newly generated RequestFactory code from AppEngine project and validate OK at runtime.
It's possible that closing and opening projects and cleans were also required.
Use parse. I tried using AppEnging for my app's backend, but parse seems to take care of a lot of backend jobs and makes life extremely easy https://parse.com

Categories

Resources