URGENT..Few problems related to Android basics...please help

Put your problem here if it does not fit any of the other categories.

URGENT..Few problems related to Android basics...please help

Postby tv_sathish » Wed Feb 06, 2008 6:16 pm

Hi all,
I am trying to use ListView and extending ListActivity in main class. I am repeatedly getting the following RuntimeException and I am not able to figure out what differently I have done from other example apps that I have with me, that use ListView. So kindly help.

Source snippet :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class SmsNavigator extends Activity {
  2.     private ListView inboxListView = null;
  3.     /** Called when the activity is first created. */
  4.     @Override
  5.     public void onCreate(Bundle icicle) {
  6.         super.onCreate(icicle);
  7.         setContentView(R.layout.sms);
  8.         inboxListView = (ListView) findViewById(R.id.inbox_list);
  9.     }
  10. }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

sms.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.                           android:orientation="vertical"
  3.              android:padding="4dip"
  4.              android:gravity="center_horizontal"
  5.              android:layout_width="fill_parent"
  6.              android:layout_height="fill_parent"
  7.              android:text="@string/app_name">
  8.     <ListView id="@+id/inbox_list"
  9.            android:layout_width="wrap_content"
  10.            android:layout_height="wrap_content"
  11.            android:layout_weight="0"
  12.            android:paddingBottom="4dip"
  13.            android:text="@string/sms_inbox"/>              
  14. </LinearLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


and the Exception is in attached JPG file. Please help.

Also can anybody point to any tutorial on how to debug in Eclipse in general and more so with Android, as most of the times when Exceptions are thrown, setting breakpoints does not seem to help and using "Step Over" also does not help. Basically the debugger sometimes takes you to "Looper.class", "Instrumentation.class" that are likely from the SDK. How to then ste out of those classes? In the case of the problem posted above, it did not even reach the first line inside oCreate(). Then how can we debug in such cases?

And when sometimes debugger does not attach to your launched configuration or DDMS windows is blank, what can b done? I tried re-installing plugin, resetting SDK path but nothing worked. And how is DDMs different from Debug window?

Thanks and regards,
Sathish
Attachments
ListView_Exception.JPG
Exception thrown
ListView_Exception.JPG (78.91 KiB) Viewed 1929 times
tv_sathish
Developer
Developer
 
Posts: 29
Joined: Wed Jan 09, 2008 12:32 pm

Top

Re: URGENT..Few problems related to Android basics...please

Postby plusminus » Wed Feb 06, 2008 10:43 pm

Hello tv_sathish,

answers in a hurry...
tv_sathish wrote:Hi all,
I am trying to use ListView and extending ListActivity in main class. I am repeatedly getting the following RuntimeException and I am not able to figure out what differently I have done from other example apps that I have with me, that use ListView. So kindly help.

For using ListActivity and the "... R.id.list ... Exception..." have a look at this topic:
:arrow: viewtopic.php?p=954#954
You'll have to use this id:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. id="@+id/android:list"
  2. <!-- this should also work, i'd prefer it: -->
  3. id="@android:id/list"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


tv_sathish wrote:Also can anybody point to any tutorial on how to debug in Eclipse in general and more so with Android, as most of the times when Exceptions are thrown, setting breakpoints does not seem to help and using "Step Over" also does not help. Basically the debugger sometimes takes you to "Looper.class", "Instrumentation.class" that are likely from the SDK. How to then ste out of those classes? In the case of the problem posted above, it did not even reach the first line inside oCreate(). Then how can we debug in such cases?

SDK is not yet open and therefor we cannot debug internal classes :( .

tv_sathish wrote:And when sometimes debugger does not attach to your launched configuration or DDMS windows is blank, what can b done? I tried re-installing plugin, resetting SDK path but nothing worked. And how is DDMs different from Debug window?


Having problems that the debugger does not attach, I kill the adb.exe-Process from the TaskManager. Helps often not always :roll:.

Regards,
plusminus
Last edited by plusminus on Fri Feb 08, 2008 1:09 pm, edited 1 time in total.
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

URGENT..Few problems related to Android basics...please help

Postby tv_sathish » Thu Feb 07, 2008 10:04 am

Hi Plusminus,
I am still getting the same problem. Please refer my modified layout and source files.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.  
  4.              android:orientation="vertical"
  5.  
  6.              android:padding="4dip"
  7.  
  8.              android:gravity="center_horizontal"
  9.  
  10.              android:layout_width="fill_parent"
  11.  
  12.              android:layout_height="fill_parent"
  13.  
  14.              android:text="@string/app_name">
  15.  
  16.     <ListView id="@android:id/list"  
  17.  
  18.            android:layout_width="wrap_content"
  19.  
  20.            android:layout_height="wrap_content"
  21.  
  22.            android:layout_weight="0"
  23.  
  24.            android:paddingBottom="4dip"
  25.  
  26.            android:text="@string/sms_inbox"/>              
  27.  
  28. </LinearLayout>
  29.  
  30.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class SmsNavigator extends ListActivity {
  3.  
  4.         private ListView inboxListView = null;
  5.  
  6.  
  7.  
  8.         /** Called when the activity is first created. */
  9.  
  10.         @Override
  11.  
  12.         public void onCreate(Bundle icicle) {
  13.  
  14.                 super.onCreate(icicle);
  15.  
  16.                 setContentView(R.layout.main);
  17.  
  18.                 inboxListView = (ListView) findViewById(android.R.id.list);
  19.  
  20.         }
  21.  
  22. }
  23.  
  24.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


I was referring to the case when trying to debug my class shifted the control to SDK classes and I was not trying to debug SDK classes. This especially happened when trying to figure out where exceptions are occurring - I did not understand how to get control back to my class - I feel without any line number or pinpointing of source code line, the exception tracing in Android is a nightmare. Sometimes even after setting breakpoint to first line of onCreate - i.e. super.onCreate, the control was not coming to that line - how to debug in such cases? First of all, how can you ensure if debugger is attached to the process?

I also have started facing a peculiar problem with FriendFinder. Clicking "Maps" in the "Applications" window opens the map, while trying to open the Visual FriendTracker, I get NullPointerException saying it was not able to start the activity (a few lines before the Exception stacktrace shows some "Tiles" missing - if that is true, then how "Maps" application worked). I am getting this problem even with other Map applications (Internet connected, of course, so that can't be a problem - like for loading maps, Internet may be needed).

Can you provide info on these two issues? By the by, what is your contest entry? AndNav?

Cheers
Sathish
tv_sathish
Developer
Developer
 
Posts: 29
Joined: Wed Jan 09, 2008 12:32 pm

URGENT..Few problems related to Android basics...please help

Postby tv_sathish » Thu Feb 07, 2008 10:07 am

Hi Plusminus,
A small correctio nto my previous post. For the List app, I am getting NullPointerException. Strangely when debugging the code, it stepped through all the lines - till end of the method, then where does the exception get thrown?

Regards,
Sathish
tv_sathish
Developer
Developer
 
Posts: 29
Joined: Wed Jan 09, 2008 12:32 pm

Postby plusminus » Fri Feb 08, 2008 1:10 pm

Hello tv_sathish,

if you got a problem with the XML simplify it further and further, until the bug is revealed. Thats what I do when I got a XML-bug.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.  
  3.              android:orientation="vertical"
  4.  
  5.              android:padding="4dip" <!-- Remove everything not necessary and insert it back later on -->
  6.  
  7.               android:gravity="center_horizontal"
  8.  
  9.               android:layout_width="fill_parent"
  10.  
  11.               android:layout_height="fill_parent"
  12.  
  13.               android:text="@string/app_name"> <!-- Layout should have no text! -->
  14.  
  15.     <ListView id="@android:id/list"  
  16.  
  17.            android:layout_width="wrap_content"
  18.  
  19.            android:layout_height="wrap_content"
  20.  
  21.            android:layout_weight="0"
  22.  
  23.            android:paddingBottom="4dip"
  24.  
  25.            android:text="@string/sms_inbox"/> <!-- Should have no text! -->
  26.  
  27.      <TextView id="@+id/android:empty" <!-- Is this to set what the ListView should show when no items are in -->
  28.  
  29.                android:layout_width="fill_parent"
  30.  
  31.           android:layout_height="wrap_content"
  32.  
  33.           android:text="Nothing!"/>              
  34.  
  35. </LinearLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


to use the empty-View do this in your onCreate:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. myListView.setEmptyView(findViewById(...));
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


To the maps issue:
:| Can you use the Android-Built-In-Browser :?:

Perhaps AndNav! is one of the Contest-Entries, so many ideas, but just 1 month of time :|

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Contd...Few problems related to Android basics...

Postby tv_sathish » Fri Feb 08, 2008 6:01 pm

Hi Plusminus,
I think I found the problem the hard way but probably the right way, by looking at documentation. The layout_height for ListView can't be 'wrap-content'. But there was no way to find out by debugging the code. That's where I find debugging tough when something happens in XMl. Now coming to testing your FriendFinder, I am able to open the regular Map browser, yes, but when opening FriendFinder or any other map application, I get the following exception:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Uncaught handler: thread Main exiting due to uncaught exception
  2. java.lang.RuntimeException: Unable to start activity ComponentInfo{org.anddev.android.friendfinder/org.anddev.android.friendfinder.FriendFinderMap}: java.lang.NullPointerException
  3.     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1397)
  4.     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1410)
  5.     at android.app.ActivityThread.access$1200(ActivityThread.java:76)
  6.     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:980)
  7.     at android.os.Handler.dispatchMessage(Handler.java:80)
  8.     at android.os.Looper.loop(Looper.java:71)
  9.     at android.app.ActivityThread.main(ActivityThread.java:2506)
  10.     at java.lang.reflect.Method.invokeNative(Native Method)
  11.     at java.lang.reflect.Method.invoke(Method.java:380)
  12.     at android.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1170)
  13.     at android.os.ZygoteInit.main(ZygoteInit.java:1121)
  14.     at android.dalvik.NativeStart.main(Native Method)
  15. Caused by: java.lang.NullPointerException
  16.     at com.google.common.io.android.AndroidPersistentStore.deleteAllBlocks(Unknown Source)
  17.     at com.google.googlenav.map.b.eraseAll(Unknown Source)
  18.     at com.google.googlenav.map.b.a(Unknown Source)
  19.     at com.google.googlenav.map.b.<init>(Unknown Source)
  20.     at com.google.googlenav.map.a.<init>(Unknown Source)
  21.     at com.google.googlenav.map.Map.<init>(Unknown Source)
  22.     at com.google.android.maps.MapActivity.createMap(MapActivity.java:192)
  23.     at com.google.android.maps.MapActivity.onCreate(MapActivity.java:115)
  24.     at org.anddev.android.friendfinder.FriendFinderMap.onCreate(FriendFinderMap.java:175)
  25.     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:786)
  26.     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1367)
  27.     ... 11 more
  28.  
Parsed in 0.042 seconds, using GeSHi 1.0.8.4


Are you able to get any clue on this?

I am at the other end of the spectrum as far as number of ideas is concerned. I have just two ideas and I am not very confident if any of them is really good. I read a couple of posts where people are saying that Google will develop Map apps with all fantastic features that you will have nothing left to think - then what is the point in trying anything related to maps and LBS? And similarly I read somewhere that some companies participate in this contest spending time and money that individual developers don't stand chance.

Please provide your comment on what I had mentioned in above para.


What do you think is left out in Android (or) will be left out in Android when they will release their newest SDK in a few weeks for us to develop? I feel this is especially true as far as Maps and LBS is concerned.

As an aside, have you tried DrivingDirectionRenderer? I tried it, but it did not work. Do you know of any other way by which we can get Driving Directions? Is the Google Map API a Java-based one and is it already part of the Android SDK?

Regards,
Sathish
tv_sathish
Developer
Developer
 
Posts: 29
Joined: Wed Jan 09, 2008 12:32 pm

Top

Postby plusminus » Fri Feb 08, 2008 7:09 pm

Hello tv_satish,

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.     at com.google.android.maps.MapActivity.createMap(MapActivity.java:192)
  2.     at com.google.android.maps.MapActivity.onCreate(MapActivity.java:115)
  3.     at org.anddev.android.friendfinder.FriendFinderMap.onCreate(FriendFinderMap.java:175)
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


The FriendFinderMap.java:175 is the super-call right :?:
No idea why exception is thrown with you :?

Hm, I have not explicitly heard of an actual company announcing challenge submissions. Remember that the idea is what tips the scales (I hope you understood what I tried to say with this sentence ^^). Sometimes there is not much code behind a extremely famous service, like i.e. Twitter.

The Maps-Activity by Google provides already a lot of features like Driving Directions and Proximity Search. I am currently working (exams are over, wohoo) on an application which will enhance the driving directions to perform like a actual navigation-program (where you would normally have to pay a lot of $$ to get the maps) and the GoogleMaps API is open and so easy to use in Android.

The Friendfinder is probably a good idea of what Android is capable of and shows how easy it is to enhance an application by LBS.

The AndNav! Preparation-Tutorial, I'll probably provide to the community tomorrow, will show how to use the DrivingDirections on Android. (At least on sunday!)
In the end the Tutorial will look similar to this:
Image


The GoogleMap API is so close within Android, always announced by Google as a KeyFeature, that one can create a Map-using APplication within minutes. So I would say it IS a part of Android.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Basics problems (contd..)

Postby tv_sathish » Sat Feb 09, 2008 4:43 pm

Hi Plusminus,
Kindly bear with me for disturbing you again, but believe I am trying out things and even referring docs, and when I am not able to find only, I am writing to you for help.

1. Somehow help me Plusminus, on the map issue. The SDK can only be unzipped and pointed at in the Eclipse IDE. I even reinstalled plugin. Basically I am talking about 'reinstalling', thinking that it might be a crash in the system - but even that has not helped.

2. How to refer multiple packages in the AndroidManifest.xml? Can't a project have multiple activites located in different packages?

3. Isn't there a way at all to start a SubActivity when the main activity starts and then later refer to the SubActivity instance?


Finally, how to debug in Eclipse if there is something wrong in XML?

Regards,
Sathish
tv_sathish
Developer
Developer
 
Posts: 29
Joined: Wed Jan 09, 2008 12:32 pm

Postby plusminus » Sun Feb 10, 2008 1:55 pm

Hello tv_satish,

1.) :| No clue

2.) YES WE CAN :lol: (sub-packages definitely. perhaps define the outermost "package="..."" a bit more "outer" if needed).
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.    package="org.anddev.android.andnav">
  4.     <application android:icon="@drawable/icon">
  5.         <activity class=".Menu" android:label="@string/app_name_menu">
  6.             <intent-filter>
  7.                 <action android:value="android.intent.action.DEFAULT" />
  8.                 <category android:value="android.intent.category.VIEW" />
  9.             </intent-filter>
  10.         </activity>
  11.         <activity class=".nav.ui.searchdestination.SDCountry" android:label="@string/app_name_sd_country">
  12.             <intent-filter>
  13.                 <action android:value="android.intent.action.DEFAULT" />
  14.                 <category android:value="android.intent.category.VIEW" />
  15.             </intent-filter>
  16.         </activity>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


3.) You could use a service to communicate between two Activities. Paller wrote some articles about services :arrow: :src: Advanced Tutorials.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Help requested for problems...(contd..)

Postby tv_sathish » Mon Feb 11, 2008 1:20 pm

Hi Plusminus,
Do let me know if you feel I am frequently disturbing you for help.

Today I found a strange problem. I had a small program that worked fine standalone, worked fine as a simple Eclipse project, but throws Exception , when run within android Project (in IntentReceiver class or in main class within onCreate). The code simply contacts Google website and gets some data and processes it. The code has no programming or logical errors and is working fine in other two situations I have mentioned. Why would it fail within Android project? Any networking issue?

And what is the default duration till which Intents are valid or must be used within?

Finally which specific tutorial are u referring to when you mean "Advanced Tutorials"? And I wonder how I can get the reference to the SubActivity instance by running activities as services (
You could use a service to communicate between two Activities.
)? So please indicate which specific tutorial are you mentioning?

Thanks and regards,
Sathish
tv_sathish
Developer
Developer
 
Posts: 29
Joined: Wed Jan 09, 2008 12:32 pm

Basic questions...(contd...)

Postby tv_sathish » Wed Feb 13, 2008 6:08 pm

Hi Plusminus,
I had asked a few questions before. Please can you have a look at them? here are the questions:

Today I found a strange problem. I had a small program that worked fine standalone, worked fine as a simple Eclipse project, but throws Exception , when run within android Project (in IntentReceiver class or in main class within onCreate). The code simply contacts Google website and gets some data and processes it. The code has no programming or logical errors and is working fine in other two situations I have mentioned. Why would it fail within Android project? Any networking issue?

And what is the default duration till which Intents are valid or must be used within?

Finally which specific tutorial are u referring to when you mean "Advanced Tutorials"? And I wonder how I can get the reference to the SubActivity instance by running activities as services (Quote:
You could use a service to communicate between two Activities.
)? So please indicate which specific tutorial are you mentioning?


Additionally I wish to know how to interpret a Spinner's clicks (both OnClickListener and OnItemClickListener cannot be used with Spinner). At the same time the API demo code nor the documentation seems to mention how to handle Spinner item clicks? Can you tell how to do this?

Can't the "getString(R.id.<something>) be used within onCreate? I am strangely getting NullPointerExcption. What might be the problem?

Is Network connectivity not possible within onCreate or IntentReceiver? Basically this is what to know when I mentioned in my previous post about one issue where the Google website access code dpes not work within Android project but works fine inside normal Java project>

Regards,
Sathish
tv_sathish
Developer
Developer
 
Posts: 29
Joined: Wed Jan 09, 2008 12:32 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 12 guests