How to debug signed Android app from Eclipse? - android

Android 2.2.
I need to debug my signed APK on my Nexus S. How can this be done using Eclipse?
I start the app on my phone and then...?

Set the debuggable=true in the manifest, export, install and sign the the app. Connect the device via USB, enable USB debugging. Then open the DDMS perspective, select the device and attach to your app's process (you will see the package name listed). If you have a rooted device, you can connect to any process if adb is running as root.

When device connect to your eclipse running mechine , set debuggable=true in manifest file and enable debug mode in android phone it can view current running log using logcat, otherwise
You can debug your running application using adb tools from the command line
adb logcat - View device log
will display the current logcat (debug messages)
adb logcat [ <filter-spec> ]
using you can filter only your given debug messages
for configure debug tool view
http://developer.android.com/guide/developing/tools/adb.html

In Android Studio stable, you have to add the following 2 lines to application in the AndroidManifest file:
android:debuggable="true"
tools:ignore="HardcodedDebugMode"
The first one will enable debugging of signed APK, and the second one will prevent compile-time error.
After this, you can attach to the process via "Attach debugger to Android process" button.

You have two ways ..
You can use Log.v or log.d or Log.i (Logging) in your code and get all those logs in logcat view in eclipse while your application runs on your device.
You can run (while debugging , pressing that insect icon on eclipse ) the application from eclipse on device, By putting breakpoints in your code you can debug your application.

Related

Android Instant Apps: How to debug an instant app?

When I debug my instant app on Android Studio, the debugger attaches to instant app process and pauses execution at most breakpoints. However it seems to ignore breakpoints at my main activity's onCreate method. I've tried "Debug" and "Attach Debugger to Android Process" options. What am I missing?
Basic information about how to use Android Studio debugger to debug an Android app is available at Developer Documentation Debug Your App
.
Android Studio debugger works normally most of the time when debugging an instant app. However, you will notice that the debugger will fail to stop at breakpoints early in the app's lifecycle (such as Application.onCreate or Activity.onCreate) on devices running Android N and below.
When your instant app is up and running, it runs under your app's package name. However, there is a short period of time during app startup when it runs under a temporary package name, in the following form:
com.google.android.instantapps.supervisor.isolated[0-9]+
This temporary name is assigned by the runtime. Because Android Studio is not aware of this name, the debugger will not attach to this process.
The workaround is to find out this temporary name and use adb to set the app to debug. This can be done by running the following command in terminal before running your app. It will print out the name when your app starts.
=> adb shell 'while true; do ps | grep com.google.android.instantapps.supervisor.isolated; sleep 1; done'
u0_i6 31908 630 1121664 29888 0 00ea57eed4 R com.google.android.instantapps.supervisor.isolated15
Once you identify the package name, use the following command which will pause and make your instant app process to wait for the debugger. Then attach the debugger normally, but choosing the temporary process name in the Choose Process window by clicking on “Show all processes”.
=> adb shell am set-debug-app -w --persistent com.google.android.instantapps.supervisor.isolated15
I had also problems recently debugging instant apps.
with multiple log messages
"Waiting for application to start debug server"
in the debug window and after several retrials
"Could not connect to remote process. Aborting debug session."
The way I solved the issue is
by using the "Attach To Process" option from Android studio "Run" menu.

My Application can't start debug mode in Android Stduio

The logcat show:
Waiting for device.
Target device: lge-nexus_4-01aa55d2b923e7a9
Uploading file local path:
C:\Users\HOXCN\AndroidStudioProjects\Horcrux\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.hoxcn.horcrux
No apk changes detected.
Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND:
am force-stop com.hoxcn.horcrux
Launching
application:com.hoxcn.horcrux/com.hoxcn.horcrux.ui.activity.SplashActivity.
DEVICE SHELL COMMAND:
am start -D -n
com.hoxcn.horcrux/com.hoxcn.horcrux.ui.activity.SplashActivity" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER]
cmp=com.hoxcn.horcrux/.ui.activity.SplashActivity }
Warning:
debug info can be unavailable. Please close other application using ADB: Monitor, DDMS, Eclipse
Restart ADB integration and try again(PS: I restart the adb with adb kill-server, don't work)
Waiting for process: com.hoxcn.horcrux
If i create a application with a default, the debug mode can run.
If i click run 'app', it work; if i click debug 'app', it show the message above and the screen show the dialog "Waiting for debugger" all the time
You hava to remove android:debuggable="true", because when you run/debug an application in Android Studio is signed with a debug certificate so that setting is not mandatory.Then check from console if the device is correctly attached with an adb devices. You should see it listed.
Below steps follow:
close Android Studio and any other IDE you have opened (maybe you have Eclipse also running?) and emulator instances;
Remove USB cable from PC;
3 . Run adb kill-server from console;
4 .Open Android Studio;
5 . Click on run/debug;
6 . when the window to select the device appears, attach your device to USB and USB to your computer;
enter link description here
Ok, this has happened to me. This usually occurs if you already have an apk with the same package name but different signature installed in your device. So the way to fix this is to uninstalll any existing apk's in your device.
Now in some android phones there are options for multiple user accounts and as such if an app is uninstalled it sometimes remains there for the other users. So you should go to the app options in the settings and scroll down to the very bottom. It might show your app at the bottom. Uninstall it from there too and it would work.
There is a Debug icon on the toolbar. It is located right next to the Run icon. Try to launch the app with that.
There is also a debug flag in the AndroidManifest.xml file. It is located under the application tag, and should be set to "true", as follows:
<application android:debuggable="true"> </application>
OR
Go to Tools => Android => disable adb integration and again enable it
after, Unplugged USB from device and again plugged in. Then press shift + F9
on Mac, I had the same problem.
I had an application to transfer files from my android device, this application causing the problem. All I had to do was to uninstall the androidFileTransfer application and install it again.
Good luck!
You can try to Restart your android studio and Reconnect your device..Its worked for me
Thank you

Attach to Android process from Qt Creator

I use Qt Creator to develop an Android dynamic library, i.e. a .so file. This .so file is then used by an Android application, but that is developed in Eclipse.
I need to debug my native code, but since it's a library, I can't start the application from Qt Creator, I must attach to the already running process.
Now, if it were a desktop application, I'd use Debug->Start Debugging->Attach to Running Application, but how do I attach to an Android process, which would be running on the emulator or on a connected phone, which is more like remote-debugging?
I think that I should use Debug->Start Debugging->Attach to Running Debug Server:
However, I'm not sure what the exact steps are - how do I start a debug server for ADB, and which port do I connect to?
So it looks like there may be another way to set up a debugger that can connect properly.
http://lists.qt-project.org/pipermail/qt-creator/2012-June/001017.html
Set a toolchain with this version of gdb, and set your project to use it.
In Tools -> Options -> Debugger -> GDB insert your commands in "Additional
Startup Commands"
...
I use Debug -> Start Debugging -> Attach to Remote. All the fields are
there (solib-absolute-prefix is an alias for sysroot, and "location of
debugging information" is solib-search-path), and the last few
"configurations" are stored, so you can call them back easily. I have
to start gdbserver on the target manually, set a shortcut to open the
'attach to remote' dialog, and it is been working great for me so for.
It's old (June 2012), but it goes into better detail about how the gdbserver is started and the setup for a debugger and attaching to a process in Qt. It also mentions some of the relevant environment variables:
set solib-absolute-prefix $ANDROID_SRC/out/target/product/MYPRODUCT/symbols/
set solib-search-path $ANDROID_SRC/out/target/product/MYPRODUCT/symbols/system/lib/
Hope that helps.
Attaching to a adb logcat is independent of Qt and what Android source you are using. Make sure adb.exe can be found on your path such as: C:\Android\SDK\platform-tools, and you have the adb drivers for the device you are debugging with. Try this one if you are struggling: http://www.koushikdutta.com/post/universal-adb-driver
Command Line ADB commands
This should print out any connected devices that can be found:
adb devices
This clears the current logcat logs:
adb logcat -c
This starts a connection to logcat:
adb logcat
Usually you don't have to worry about which port to connect to, because it is automatically found by adb.
Attaching to logcat over wifi is also do-able.
adb tcpip
adb connect 192.168.XX.XX:5555
Hope that helps.

Android .apk installation - Application not installed

I've installed the appropriate .apk file, however when trying to install it the app it gives me the error 'Application not installed'. I've tried to put a simple Hello World .apk file on there and I receive the same message.
Here's what I have tried:
1. Adding the following to Application Manifest
android:debuggable="true"
2. I have installed multiple File Managers including Astro, Android File Manager and ES File Explorer
3. I have enabled all of the correct settings on the Sony Xperia U (running Android 2.3.7)
4. Tried installation whilst the device is plugged in, and whilst it isn't
I'm using a Unsigned Android Application. Everything runs accordingly on the Eclipse emulator
Logcat is reporting the following:
This is displayed even when my device is connected via USB.
Locate your myapp.apk file on your hard drive:
Install it via command line:
C:\android\android-sdk\platform-tools\adb.exe install myapp.apk
List of connected devices:
adb devices
Connecting a device (if its number is 5554):
adb connect 127.0.0.1:5554
Restarting ADB:
adb kill-server
adb start-server
Your APK is having an expired or mis-configured certificate.
You need to resign the apk using the following tools.
https://play.google.com/store/apps/details?id=kellinwood.zipsigner2&hl=en
or
https://code.google.com/p/apk-signer/
Sign the APK with output filename as HelloWorld_signed.apk
Then go to my files you Will see your signed apk.
Install HelloWorld_signed.apk.
The app Will install successfully..
I believe there is a constraint of permission to prevent you to do so, I have worked around and find a simple solution for my Sony Xperia 1, OS version 5.1.1
Go through these steps:
Settings
Apps
Download Tab
Scroll down to find your app there
Press the menu and select Uninstall for all users

How do I view Log messages in Android?

I am trying to debug my android application using log messages. When I use System.out.println and Log.i and run the android application,I cannot see the debug message in either console or Logcat. If I have to get the debug messages do I have to run the android app in debug mode
from eclipse goto window -> open perspective -> other -> select DDMS.
And then run your app. And then select your running device from DDMS.
If it is not resolved your problem, restart your eclipse without closing your emulator and then flow the same above steps.
Njoy,
You do not need to run your app in debug mode to see log messages.
In order to see the log messages, you only need to have usb debugging enabled on your phone, the adb drivers for your device installed, and a copy of the android developer tools. It sounds like you have the above things, so I will suggest some steps for troubleshooting this.
Don't use System.out.println, because it does not allow you to specify a tag. Make sure that you set a good tag for your log messages. Once all of the above is confirmed, attempt to view the log message in eclipse's logcat view. Create a filter with the tag you are using because many messages will print and it may be difficult to find yours. You can also filter by application by using the name of your application's package.
If you have tried all this and you still can't see log messages, try running:
adb kill-server
and
adb start-server
If no luck, try restarting eclipse.
Confirm your device is plugged in!
If none of this is working, you can also run ddms from the sdk tools which is a bit more reliable.
Finally if that doesn't work, you can simply issue an adb logcat on the command line. If you have multiple devices, you can list them with adb devices and resolve the device or emulator with -d for the only connected device, -e for the emulator, or -s serialno to resolve otherwise.
There are also tools that will allow you to view the logs on your device, such as alogcat
sometime you may not select the emulator
and another way is to
restart your eclipse i also have faced this problem many times
If you're using Eclipse make sure that:
You have Debugging enabled in your device (or that you use emulator),
Your device is connected properly - it should show up in the Devices view. If you don't have this view get it from Window->Show View->Devices,
You've SELECTED your device in the Device View (simply click on it),
You don't have the LogCat paused and no filter is enabled - All messages (no filters).

Categories

Resources