I have not been able to trigger breakpoints set in Android source files (framework source files, as opposed to my application's source files). I have attached the Android source files, so I can see them and set breakpoints, but when I run in debug mode, these breakpoints are not triggered. I have also tried adding Class Loader breakpoints: this works fine on Android source classes. I am using Eclipse 3.7.2, and I've tried with several different Android SDK versions.
Robguinness,
It looks like what you would like to do is debug Android framework, right? The best method of doing this, from what I understand, is to import the AOSP project into Android Studio (only recognizes Java files) by running "make idegen && development/tools/idegen/idegen.sh" and then opening the android.ipr file that it generated in Android Studio. You can then hook up your emulator and set breakpoints in the Java code.
There are also a wide selection of tools to debug the Kernel, C native code, etc. but there it is such a long topic to cover on this site. If you are interested in more specifics, I would highly recommended Karim Yaghmour's class on Android Debugging (http://www.opersys.com/training/android-debug-and-performance). He has also given several talks at AnDevCon that should be freely available on Youtube about AOSP and Android Internals.
Best Wishes!
Related
I was trying to look at the sources of some AOSP classes like:
"android.com.android.server.am.DumpHeapProvider" (i then found the source inside this repository and looked at it online: https://android.googlesource.com/platform/frameworks/base/+/master/services/core/java/com/android/server/am/DumpHeapProvider.java), so I tryed to import the class inside a new project created with AndroidStudio and I immediately noticed that AndroidStudio didn't found the class...
So I was wondering if AOSP classes and its packages are somehow "external" things that should be downloaded and imported in you project before they can be used, just like a library.
It sounds weird because searching for AOSP gets me to a sentence which states that AOSP is composed by android OS and middleware, so I was expecting its libraries to be part of Android SDK, which I downloaded with AndroidStudio...
What is the correct way to use these AOSP classes?
I tryed to import the class inside a new project created with AndroidStudio and I immediately noticed that AndroidStudio didn't found the class
The vast majority of the AOSP represents code for an operating system. Very little of it is part of the Android SDK, and very little of it is usable by an app.
I was wondering if AOSP classes and its packages are somehow "external" things that should be downloaded and imported in you project before they can be used, just like a library.
They are used to build an operating system.
What is the correct way to use these AOSP classes?
Build an operating system, such as Android.
The environment...
I have a brand new Visual Studio 2015 Android NDK Solution.
This contains 2 projects (the default template code that is generated by visual studio):
A native activity. This is where I want to put Android specific code. It has some default code which fades the screen colour between green and black.
A 'Packaging' project to help with deployment.
I have deployed this successfully to an Intel HAXM virtual device as well as to a real device connected via USB. All good so far.
I then added an Android dynamic library project (.so) - this is where I want to put core code (platform agnostic).
I added a reference to this Core library from the native activity project.
Everything compiles and links fine. I can still create an .APK file.
Other info:
Android SDK 5.1 (Android-22)
Android NDK 21
x86
Clang 3.8
C++ 11
Not using Make files or Gradle
The problem...
Now whenever I deploy to the virtual/real device I get the following error (taken from logcat)
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.NATester/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app/com.NATester-2/lib/x86/libNATester.so
Things I have tried...
changing the Core library to static (.a)
checked the android device to see if the file exists - it does exist.
Manually deploying the .APK to the android device.
Some articles have suggested using Java code to load the libraries - I want to avoid calling Java code e.g. System.LoadLibrary as this seems like a hack - I feel that it should be possible to to have a pure C++ application on android. I can't be the only person to run into this issue?!
This looks relevant but old and again an unnecessary hack for what must be very common situation
- Can't load native shared library with dependencies in a native activity app
- https://github.com/ikonst/android-dl
For what its worth, I am a seasoned C# developer with Visual Studio (15 years).
I therefore take a lot of things for granted when developing apps - this is my first project using C++/Android and it seems more of a manual battle to get everything to work!
Been struggling for a while but managed to deploy the libraries, quite easy in the end.
Right click on the project [theProject (Andorid-xx)] in the Solution Explorer and select add new item, add your .so library.
Right click on the newly added library and select properties, item type should be library, set Content to Yes, this will deploy the lib.
There are numerous questions like this around here, the Qt sites and the OpenCV sites, but none of them quite match my case. (And a lot are unanswered anyway.)
I'm using OpenCV for Android 2.4.6 (the prebuilt version downloadable from the official site)
to build a native App for Android (4.1.2) on a Samsung Galaxy Note 2 with Qt 5.0.1 for Android
(using QtCreator 2.7.2) on a x86_64 Linux host.
I've linked against the libraries in the ../sdk/native/libs/armeabi-v7a folder. (I haven't built OpenCV from source, I'm just using what was in the downloaded package). This includes a libopencv_androidcam.a library. (And I've also tried the libnative_camera_r4.1.1.so shared lib.)
I've also downloaded the market app "OpenCV Manager".
The sample .apks from the samples directory work on my phone, but I haven't tried to build them on my own, as I don't have a Java development environment set up.
Starting my application, which contains a cv::VideoCapture inputCapture(CV_CAM_ANDROID); statement, I get the following error and no camera input:
E/OpenCV::camera(15299): CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library
E/OpenCV::camera(15299): Native_camera returned opening error: 4
My questions:
Should this work? I have seen a lot
of bug reports, but all with older
OpenCV versions and newer/older
Android versions. Bonus points if it
has been seen working on this phone
model.
Should this work out of the box with the downloaded OpenCV Android SDK? Or do I need to build OpenCV from source with some special options? (Which ones?)
Do I need special library versions on the phone itself? Do I need to have root access to the device to make this work?
Are there any "known to be working" Andoid examples using native code instead of Java?
Thanks a lot for any help!
I'll repeat the answer I got from user #Moster at http://answers.opencv.org here:
Copy libnative_camera_r4.1.1.so from the folder
/sdk/native/libs/armeabi-v7a to your Qt project's folder
/android/libs/armeabi-v7a. Make sure you have also allowed the camera
in the android_manifest in the Qt creator. Maybe all this helps
This indeed works. While I already mentioned the camera permissions in the Manifest.xml (or rather the Qt project settings), copying the shared lib to the project directory did the trick.
Seems like it's found and linked during build, but not copied to the device from its original location.
Neither the "Copy local Qt libs to device" in the deploy settings (Qt libs only?) nor the OpenCV Manager App (only loads the right libs when called directly from the Java code?) helped before.
I'm developping a android's aplication using some shared
libraries written by me and compiled with ndk-r5b. The application works,
y and the calls to the libraries works too, but I detected some errors,
segmentations faults, and I need to debug it, but, I don't know how debug
native code from android and I don't know if I can generate core dumps,
as in linux, for debug my libraries.
Any idea?
The ndk comes with ndk-gdb, which supposedly allows you to debug native applications. Also, if you download the whole andriod open source project, they also have some version of gdb used for debugging. Look in the docs/ folder of the ndk to learn about using it. This tutorial might also prove helpful: http://vilimpoc.org/blog/2010/09/23/hello-gdbserver-a-debuggable-jni-example-for-android/
However, as shown in a recent question I asked: Running ndk-gdb with package not found error on motorola phone I still can't get it to work.
Edit: You said in the comments you were using a Samsung Device: Samsung decide to wreck havoc on some of the crucial internals required for native debugging, but it's easily fixable if you have root access to the device. If you use the --verbose flag, you'll probably find that the error is different than that, a package unknown error. That's because it's looking in /data/system/packages.list, but samsung renamed that file to /dbdata/system/packages.list. So if you make a symlink to that file in /data/system/packages.list, (requires root access) it should work. Or at least so claims the ndk mailing list: http://osdir.com/ml/android-ndk/2011-03/msg00036.html
I need to edit the original Android Apps from packages
in terms make my own distro/mod..
I want to make changes to the In Call screen, lock screen, contacts, calendar etc..
I understand that for doing this I will have to build everything from
source,
however I need to edit the source and to do so I need to open the OS provided apps as
eclipse projects,
When I did I saw that there are
missing imports which are hidden in the SDK (or missing)
hidden parameters within the classes..
I don't want to use reflection since the whole code is here and
available, but how do you build a platform development kit..
or PDK ?:)
Can any one help?
You start by reading the documentation.
EDIT:
If you are trying to download some single project from AOSP and compile it using the SDK, odds are very strong that it will not work, and that you will encounter problems like the ones you cite. You do not build Android by building individual apps; you build Android ("my own distro/mod") by building the entire firmware. Most AOSP applications are not designed to be compiled by the SDK, but need the whole firmware.
Please check Using eclipse to browse and edit AOSP. You can atleast edit your code using eclipse, but you will have to use AOSP build system to build your distro.
You might also check Debugging Android Java Framework services as that would help debug your changes.
Just open Eclipse,
then go to "window" +"preferences" +"android"
there you will get sdk location,then give the appropriate path of the android sdk for proper run...