Debugging ADF Mobile Apps on Android

Not that you'll ever need this, after all your code is perfect. But I did run into a situation where I wanted to figure out what exactly is wrong with my ADF Mobile code. The way to do debugging is documented in the ADF Mobile Developer Guide, but here is a version of those instructions with nice pictures (which might make it easier for you to find files etc).

1. First locate the cvm.properties file (In the Application Resources accordion). In this file you'll want to change the value of java.debug.enabled to be true. Also note in this file the value set for java.debug.port,  by default this is 8000 and we are going to keep that default value in our example.

2. Next have a look at your application level deployment profile, or even better create a new deployment profile and call it debugDeploy. The key thing here is to make sure your build mode is in Debug mode and not Release mode (remember the previous post where we told you that Release mode creates a smaller/faster deployment, but right now we do need the bigger package to be able to debug).

3. Next deploy your application with your new debugDeploy profile. We'll assume deployment directly to the device.

4. Now from the command line locate the directory where your Android's SDK adb.exe utility is and issue the following command to let the device (-d) know that we are going to use port forwarding for debug:

adb -d forward tcp:8000 tcp:8000

5. Now on your device start your application. You'll notice that it seems to be stuck, well this is because it is waiting for the debugger to connect to it. So what are you waiting for?

6. In JDeveloper, stand on your viewController project and right click to choose debug. If you changed the port number you'll need to update that info in the dialog that pops up - but if you kept it at the default 8000 we should be ok.


The debugger will now try and connect to your running application, and will stop at the breakpoint you set.

Happy debugging.

By the way if you want to debug on the emulator of Android the only difference will be in step 4 where instead of -d you'll use a -e .

P.S. - you might also be interested in this blog entry about setting up logging on Android with ADF Mobile.

For iOS debugging tips see this blog entry by Joe.

Comments:

really Nice Thanks for sharing .. very clearly discussed and presented.

Posted by guest on January 02, 2013 at 11:55 PM PST #

Hi Shay,

I have the android phone connected to computer with its debug on.
Can you put some light on, how to deploy to an android device directly from jdev?

What all settings are required for jdeveloper to identify the device for deploying?

Thanks you.

Posted by Prabhanjan Nag on January 22, 2013 at 08:58 PM PST #

Prabhanjan, development and deployment is described in our tutorials here:
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/adfmobiletutorials-1882877.html

As long as you can see your device from your computer as a hard-drive you should be set to have JDev deploy directly to device.

Posted by shay shmeltzer on January 23, 2013 at 11:19 AM PST #

How about debugging in iOS ?

Posted by guest on March 06, 2013 at 08:13 PM PST #

guest - debugging on iOS should be basically the same without the adb command that is needed for Android.

Posted by Shay on March 07, 2013 at 01:34 PM PST #

Hi Shay,
How come my System.out.println() don't work?
How can I see what is printed in the log console?

Posted by Diego on May 14, 2013 at 12:01 AM PDT #

Diego - System.out.println() won't show up inside JDeveloper - you can start the log monitor for your environment and see it there.
For Android look under the Android SDK install in the tools directory you'll see ddms.bat file - run it and your SOP will show up there.

Posted by Shay on May 14, 2013 at 12:53 PM PDT #

Hello Shay, thanks for answering,
I ran the ddms.bat and I get 'The standalone version of DMSS is deprecated. Please use Android device Monitor (monitor.bat) instead.'
I ran the monitor.bat and It opened an android debud monitor.
Well I figured out how to get the return object from the WS.
My Session Facade Bean was returning a CustomBean but the WS method was returning an Object I changed the return type of the WS from Object --> CustomBean
and that solved my problem, plus when I created my web service data control I put the Port url instead of the WSDL url I dom't know if that has anything to do, but I saw in a tutorial that the WSDL is needed so I changed it

Posted by Diego on May 14, 2013 at 01:03 PM PDT #

Diego - see this entry - https://blogs.oracle.com/shay/entry/adf_mobile_logging_on_android

Posted by Shay on May 14, 2013 at 02:44 PM PDT #

Dear Shay.
I am running the command adb -d forward tcp:8000 tcp:8000 from ...\sdk\platform-tools , But i am getting the error (The Android Emulator is running):
tcp:8000 tcp:8000
error: device not found

in addition when i start the debug from Jdev i am getting : .Debugger unable to connect to remote process.

Posted by guest on June 08, 2013 at 11:56 AM PDT #

guest - you might need to issue an : adb -services first to make sure the adb service recognizes the emulator.

Posted by shay on June 11, 2013 at 09:31 AM PDT #

Hi, after following each step, I get this message in the console: unable to connect to debugger. I use 'e' in command prompt and test it in an emulator.

Posted by guest on June 26, 2013 at 04:11 AM PDT #

Hi,

I got the same error as : "unable to connect to debugger. I use 'e' in command prompt and test it in an emulator."

Please help me.

Posted by guest on July 09, 2013 at 06:08 AM PDT #

Hi Shay, I have query on UI Components.How to adjust the components for different screen size devices in android.The application which i have made
the issue is it appears fine on smaller devices but on high end devices the 1/4th screen appears to be blank.Can you throw some light on this issue.Also how to customize the in built components.

Posted by guest on August 30, 2013 at 03:14 AM PDT #

guest - try posting this on the OTN forum.
If you are targeting both phones and tablets you might want to consider developing two separate interfaces in the same project and using constraints to decide which UI is shown.
http://docs.oracle.com/cd/E37975_01/doc.111240/e24475/constraints.htm#BEICDBCI

Posted by Shay on August 30, 2013 at 12:32 PM PDT #

Hi shay thanks for responding.I am targeting only phones but of different screen sizes.For e.g. Samsung (galaxy ace,Note,S4) ,Google (Nexus ,Nexus 4),HTC(Sensation,Butterfly).These phones are of different screen sizes.The UI Which i am making looks fine on some of these devices but on rest it leaves some part blank @ bottom of screen . I wanted components to stretch in terms of width according to screen sizes as we can do in native android development.If you can provide me email i can send you pics to better understand my question.Thanks.

Posted by guest on September 01, 2013 at 11:02 PM PDT #

guest, Have a look at the layout demo that comes with the ADF Mobile demos for some techniques.
Many components will stretch based on the component that contains them.
For others you can use a specific stylesheet to force their size.

Posted by Shay on September 03, 2013 at 05:14 PM PDT #

Hi shay still not able to do the required task.One more issue which i am facing is functionality point of view.I want camera to take a picture when user clicks on "Take Picture" button.And when photo is taken preview is to be displayed on the same page below "Take Picture" button.The issue i am facing is as soon as application starts ,DIRECTLY STARTS CAMERA & preview of image is shown.what i wanted was , when i click on "Take Picture" button , it should open camera & then show preview.Help is appreciated.

Posted by guest on September 04, 2013 at 04:43 AM PDT #

Guest, try and see if it works properly when you remove the image preview from your screen.
My guess is that it tries to render the preview when the app loads and therefor directly tries to take a picture.
If you put the preview on another page, or if you'll only make it visible after you took the picture it should behave.
By the way - for faster answers post your questions on the OTN ADF forum.

Posted by Shay on September 09, 2013 at 04:20 PM PDT #

Unfortunately could not connect debugger to example application (LifecycleEvents) neither on the emulator nor on the device (I tried Nexus 7 with Android 4.3.3).

In all cases application do appears to be stuck waiting for something but JDev says "Debugger unable to connect to remote process".
I tried to use localhost (as indicated in your post) as well as ip of the device (as indicated in the manual). In all cases the result the same. I tried port 8000 and 4000.

More, I tried several example applications without any success.

On device i do see that application is listening on port 4000 and I can ping my device over wifi but jdev still unable to connect.

From posts here it looks like I am not alone, right?

What can be wrong?

Posted by guest on September 13, 2013 at 06:28 PM PDT #

Shay!
I tried that command in linux-ubuntu it tells me the adb command not found

Posted by Diego on February 03, 2014 at 11:56 PM PST #

Diego - you need to execute the command from the directory that contains the adb utility under your Android SDK installation.

Posted by Shay on February 04, 2014 at 09:18 AM PST #

Hi, I couldn't find it I searched for adb
and I got this file adb_has_moved.txt
The adb tool has moved to platform-tools/

If you don't see this directory in your SDK,
launch the SDK and AVD Manager (execute the android tool)
and install "Android SDK Platform-tools"

Please also update your PATH environment variable to
include the platform-tools/ directory, so you can
execute adb from any location.

Posted by Diego on February 04, 2014 at 09:33 AM PST #

For those having problems connecting the debugger to the emulater - I was having the same issue. Double-checked my cvm.properties, "debug" release, port number. The emulator was clearly waiting. So I ran the "adb -e forward tcp:8000 tcp:8000" twice - and suddenly the debugger could continue. Strange, but for what it's worth, that worked for me.

Posted by guest on March 02, 2014 at 11:09 PM PST #

Hi Experts,

I’m programmatically trying to use Base 64 encoding for one of my restful service call.

For this, I created a Custom Application in Jdev (version 11.1.2.4.0) and included jersey jar ‘jersey-core-1.1.5.jar’ from inside $MW_HOME/jdeveloper/jersey/1.1.5/lib

Below details..

import com.sun.jersey.core.util.Base64;
..
..
byte[] bytes = com.sun.jersey.core.util.Base64.encode(auth);

My java version is 1.6.0.24. It worked in java SE environment

Now, I tried to do the same in ADF mobile project in same jdev settings. However, I am getting error - “com/sun/jersey/core/util/Base64” (Unsupported major.minor version 49.0)

I am using same parameter as stated above, however under – Libraries and Classpath (under project properties I can see) – CVM_JDK profile (which uses libraries from jdev extensions.)

I understand, the unsupported exception will come when it’s compiled with higher version and run in lower version.

Can you suggest, please.?

Regards,
Sumit

Posted by Sumit Sahay on March 24, 2014 at 02:32 AM PDT #

Sumit, ADF Mobile uses JDK 1.4 - you can't bring in JDK 6 libraries into it.

Posted by guest on March 24, 2014 at 06:20 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

me
I'm a Director of Product Management for the Oracle Java Development Tools.
Follow me:
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today