Tuesday, August 2, 2011

ListView has zero children - how?

In previous tests, the exerciser monkey had managed to get the app to crash on an NPE, when the list view somehow didn't return a list of children views. I had put in debugging code showing the the list was populated, so I figure / hoped it was just monkey running so fast that a human wouldn't be able to replicate it. Well, I just did. I put it in autorun mode and kept banging away at it and darned if I didn't come up with the same thing.

So, I wonder if it's just a timing thing and if do a pause if it will avoid that? Or, maybe even created a timer to check the the child count is there and exit when it gets there?

I'm going to make the timer thread to check it. I hope it doesn't cause a memory leak or anything.

Maybe I can put it in a pause loop...

I wonder if this would work in Android:

try{
Thread.sleep(1000); // Sleep for 1 sec
}
catch(InterruptedException e){}

How about we try this:

// Workaround on bug raised by monkey exerciser
while (0 == childCount) {

try{
Thread.sleep(1000); // Sleep for 1 sec
}
catch(InterruptedException e){}

Toast.makeText(appState,
"System error, ListView is empty, exiting activity",
Toast.LENGTH_LONG).show();

Log.d(TAG, "!!!!!!!!!!!!! System error, ListView is empty, exiting activity");

}

Hmmm...I'm out of data to test for that - the schedule has everything coming up later than today. In a later release, I'll handle that. They have the browse mode until the time comes to review.

I'd like to copy the project, but I'm unclear of how it affects svn. If I update and commit, does it update the copied from project?

Let's try it.

No, it looks like it copies. But this command works:

http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.export.html

Examples

Export from your working copy (doesn't print every file and directory):

$ svn export a-wc my-export
Export complete.

Ok, let's go in and rename stuff. Just a few items - package name, string for the app label, launch configuration and mainfest package name is changes automatically. This is where I reap the rewards of setting up these little "shell" projects.

Ok, launch. Ok, I got a nice crisp "connect to network" message because I was in airplane mode - shift out of that, and I get the "Panera-mode" message - connect locally but not over the internet. Nice. Then, I got a timeout, but then on the retry a "market-not managed". So, let's add this app to the marketplace.

Why can't I ever remember that url? The network has for some reason slowed to a crawl. I put the url in my blog recently, but I don't know which one. Man. Maybe I should head home and finish it there.

At last, I found it:

https://market.android.com/publish/editProfile


Ok, market android com - I think I've been calling it the Google Marketplace - no wonder I couldn't find it.

Let's go there and bookmark it about 5 different ways.

upload android app apk url android market < tags

Ok, right, I'll generate the apk. The only thing I need to do in advance is export the apk as unsigned. I'm getting this down.

It's in Android tools, and I export it right over the existing one in bin.

Now, run my script...

Oh, I like to see this:

adding: META-INF/MANIFEST.MF
adding: META-INF/ALIAS_NA.SF
adding: META-INF/ALIAS_NA.RSA
signing: assets/epminbld.ttf
signing: res/anim/custom_anim.xml
signing: res/anim/fade_in.xml
signing: res/anim/fade_out.xml
signing: res/drawable/a.png
signing: res/drawable/all_was_darkness.png
signing: res/drawable/backgroundlistcell.xml
signing: res/drawable/btn_radio.xml
signing: res/drawable/btn_radio_off.png
signing: res/drawable/btn_radio_on.png
signing: res/drawable/custom_button_drawable.xml
signing: res/drawable/dialog_custom.png
signing: res/drawable/fragile_as_snow.png
signing: res/drawable/hanami_looking_at_cherries.png
signing: res/drawable/hilight_correct_selector.xml
signing: res/drawable/hilight_default_selector.xml
signing: res/drawable/hilight_gradient_correct_drawable.xml
signing: res/drawable/hilight_gradient_incorrect_drawable.xml
signing: res/drawable/hilight_no_gradient_correct_drawable.xml
signing: res/drawable/hilight_no_gradient_default_drawable.xml
signing: res/drawable/hilight_transparent_drawable.xml
signing: res/drawable/ic_icon.png
signing: res/drawable/idle_hours.png
signing: res/drawable/lin1.jpg
signing: res/drawable/listcell_enabled.xml
signing: res/drawable/listcell_pressed.xml
signing: res/drawable/looking_at_the_moon.png
signing: res/drawable/looking_at_the_moon_240.png
signing: res/drawable/plum_blossoms.png
signing: res/drawable/progress_correct_drawable.xml
signing: res/drawable/progress_horizontal_drawable.xml
signing: res/drawable/progress_incorrect_drawable.xml
signing: res/drawable/progress_timeout_drawable.xml
signing: res/drawable/progress_timeout_drawable_old.xml
signing: res/drawable/sei_shonagan_and_the_hell_screen.png
signing: res/drawable/snow_cranes.png
signing: res/drawable/snow_viewing.png
signing: res/drawable/tasacode_whose_sleeve.png
signing: res/drawable/the_abbot.png
signing: res/drawable/the_go_game.png
signing: res/drawable/the_third_princess.png
signing: res/drawable/ukifune_and_karou_at_uji.png
signing: res/drawable/ukiune_wandering.png
signing: res/drawable/wisteria.png
signing: res/drawable/yugao.png
signing: res/layout/main.xml
signing: res/layout/next_level.xml
signing: res/layout/question.xml
signing: res/layout/settings.xml
signing: res/layout/simple_list_item_single_choice_custom.xml
signing: res/layout/start_layout.xml
signing: res/layout/validation_activity.xml
signing: AndroidManifest.xml
signing: resources.arsc
signing: res/drawable-hdpi/icon.png
signing: res/drawable-ldpi/icon.png
signing: res/drawable-mdpi/icon.png
signing: classes.dex
Checking if APK is verified...
jar verified.
removing old temp file..
running zipalign to temp file..
moving temp back to original deploy apk


I just noticed a minor problem. All the apps are going to show on the marketplace with the same name "JlptVocabaularyQuiz". I'm going to remove them all, and figure out where that name is set. Probably in the manifest.

Huh, it's running into an NPE in the database helper. I'll have to include the sql lite db in the shell projects, just like the fonts. Is there a way to include that?

Hmm, I had to uninstall for the second time due to conflicting signatures.

adb uninstall com.kanjisoft.jlpt5.full


Ok, good. It's loading data.

While I'm waiting, let's look up some information:

Android 2.3 Gingerbread finally gaining on 2.2 Froyo while Honeycomb stagnates

Google has released new information on the breakdown of Android devices on its developer Website. Things are bad and good. Almost eight months after its release, Android 2.3 (Gingerbread) still only accounts for only 17.7 percent of active Android devices, with 2.2 (Froyo) still dominating the charts with a 59.4 percent share of the market. Of course, looking back at the March numbers, the platform shows considerable improvement. At that time, Gingerbread made up less than 1 percent of the market and Froyo had a 61.3 percent share.
Android 3.0 and 3.1 (collectively known as Honeycomb) have not been as fortunate in the last few months. Google’s Tablet-only Android OS still has only a .9 percent share of active devices; it was .2 percent in March. It seems that what we hear about low tablet sales is correct; Android tablets just aren’t selling yet. Either that, or owners aren’t using them. Google gathered this most recent data by monitoring what devices accessed the Android Market for the 14-day period ending July 5.Android 2.3 Gingerbread finally gaining on 2.2 Froyo while Honeycomb stagnates - Yahoo! News

That's good. I need 2.2 so I can support storage on external devices. So, 17.7 + 59.4 + .9, which is almost 80% of the market. That's a lot, and I don't want to download my huge app onto an old, underpowered device with limited storage.

Ok, we're still horsing around with app name. While the market place uses it, and it's probably displayed in the title bar, I don't need to display it on the title page. I'll create a new string in the "core" project.

I'll call it this:

JLPT Vocabulary Quiz

And fix it here:

app_start_page_title

Ok, this is what we have so far in the "shell" string resource:

JLPT 4 Quiz
JLPT 4 Japanese Vocabulary Quiz Game
4

Ok, now we still have some errors cropping up in the core project compile...

Ok, still some massaging to do. The start activity should probably load the app state with the level. Probably the app title that displays on the top as well, but we'll let that go for now.

Sugar. For some reason, it triggered the download logic - which is based on the presence of a particular audio file. At least the last problem is solved.

Hmmm...now it's redownloading the whole data again. Start and restart it, and it does it again. So, where's the logic?

Oh, it's crashing:

E/AndroidRuntime(27515): FATAL EXCEPTION: main
E/AndroidRuntime(27515): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@40562ce8 is not valid; is your activity running?
E/AndroidRuntime(27515): at android.view.ViewRoot.setView(ViewRoot.java:527)
E/AndroidRuntime(27515): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
E/AndroidRuntime(27515): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/AndroidRuntime(27515): at android.view.Window$LocalWindowManager.addView(Window.java:424)
E/AndroidRuntime(27515): at android.app.Dialog.show(Dialog.java:241)
E/AndroidRuntime(27515): at com.jlptquiz.app.DownloadAudioData$ExtractFilesTask.onPreExecute(DownloadAudioData.java:321)
E/AndroidRuntime(27515): at android.os.AsyncTask.execute(AsyncTask.java:391)
E/AndroidRuntime(27515): at com.jlptquiz.app.DownloadAudioData$DownloadFilesTask.onPostExecute(DownloadAudioData.java:204)


Ok, the new project setup seems to be causing some kind of a problem with the download. I thought I was all set with that, once I got it out of the validation routine. Does it need the root window running? I'll take away the finish.

Ouch. The validationActivity is showing the old errors which were already taken care of in the core project, and when I do a clean - the old R error shows up. Words cannot describe how much that R error unnerves me.

Ah, in this case, it was the manifest - I was still referring to app_name, which been taken out of the core.

Ok, now we want to change to let the bootstrap activity survive the launch.

Ok, so far the download seems to be going smoothly. So, if that's true, then I will have to implement some other way of avoiding the Place of Darkness that the users lands in when he or she exits the StartActivity display.

So, I guess that means there's a problem if you exit the root window.

Ouch - are we into the broadcast listener business again? Why again did we need to launch from the Validate routine? Why can't we just put the callback into the bootstrap activity.

Uh-oh. The *extract* died. How on God's good earth could such a thing happen? Extracts never die. Never! Yet, there it is.

Uh-oh. Remember that thread wait I put in, way back? Well, it's freezing the app. Let's yank it.

Well, it appears that this empty listview is turning into a real pain in butt.

Let's go to where it's set up and print out some data:

Log.d(TAG, "*******************************************************");
Log.d(TAG, "appState.mAnswerArray: " + appState.mAnswerArray);
Log.d(TAG, "appState.mAnswerArray.length: " + appState.mAnswerArray.length);

Log.d(TAG, "mChoiceArrayList: " + mChoiceArrayList );
Log.d(TAG, "mChoiceArrayList.size(): " + mChoiceArrayList.size() );
Log.d(TAG, "*******************************************************");


So, things are going good - but after a while:

StagefrightPlayer( 68): setDataSource('/mnt/sdcard/data/.com.kanjisoft.jlpt5.full/aud5/5_231.mp3')
D/QuestionActivity(28546): **************************************************************
D/QuestionActivity(28546): appState.correctAnswers: 3
D/QuestionActivity(28546): appState.quizSequenceIndex : 7
D/QuestionActivity(28546): appState.quizSequence.size() : 10
D/QuestionActivity(28546): percent: : 42
D/QuestionActivity(28546): **************************************************************
I/EventLogService( 217): Aggregate from 1312331226865 (log), 1312331226865 (data)
D/QuestionActivity(28546): *******************************************************
D/QuestionActivity(28546): appState.mAnswerArray: [Ljava.lang.String;@4051c408
D/QuestionActivity(28546): appState.mAnswerArray.length: 4
D/QuestionActivity(28546): mChoiceArrayList: [かてい, こうちゃ, わたくし, ろうか]
D/QuestionActivity(28546): mChoiceArrayList.size(): 4
D/QuestionActivity(28546): *******************************************************
D/InitUtils(28546): appState.currentQuestion: 664
D/QuestionActivity(28546): !!!!!!!!! ListView is empty!!!!!!!!!
D/QuestionActivity(28546): !!!!!!!!! ListView is empty!!!!!!!!!
D/QuestionA

I'm kind of at a loss here. I'll have to pick it up tomorrow.


This might have something to do with it:

http://stackoverflow.com/questions/4039206/how-to-know-when-an-android-listview-is-done-being-populated

No comments:

Post a Comment