[android-developers] Re: Text To Speech Android 1.6 with minsdk 3
I think I got it working. Thanks for the direction. My mistake had been moving the boolean that reflected the availability of the TTS function INTO my wrapper class (where code design sort of suggests it would like to be) and this would cause me VerifyError exceptions. So there was indeed a method to the madness of keeping it outside. tone -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Text To Speech Android 1.6 with minsdk 3
Of course, 2 minutes after posting this, I see the twisted path of how to specify the 1.5 target. I get, however, an exception (VerifyError) on a call to my TTS wrapper. I think this might be because I modified the nature of this slightly, and in a way that alters the delicate balance of the example. Let me tweak it back and fuss a bit more. Your claims of success inspire me to see what I might have done wrong. tone On Feb 14, 11:06 am, DulcetTone wrote: > Ok, I definitely do not see how to make this work. > I don't grasp how the wrapping method here in any way spares the 1.5 > runtime environment from having references to text-to-speech things. > > A 1.5 user tried my test build and gets a force close. I redoubled my > efforts to manually select a 1.5 emulation target, and if my > dependency is 1.6 and minSdk=3, it will not show my 1.5 target. If I > compile against 1.6 and then try to trick Eclipse by changing it to > 1.5 before invoking the debug upon my 1.5 target. Then, it realizes > the trick and balks. > > I am rapidly realizing that I should have separate products for 1.5 > and earlier and one for 1.6 and later. That would be an ugly upgrade > transition, as I have taken money from all users for a common build. > > tone > > On Feb 4, 9:09 am, Eric Carman wrote: > > > Hello Tone, > > > You definitely have to target the 1.6 (or greater) platform for this > > to compile. > > > I remember having trouble getting the debugger to attach to the 1.5 > > emulator. I don't remember if I was able to do that or if I relied on > > Toast/log messages to zero in on my 1.5 specific issues. I'm not near > > the proper computer now to test it out. I vaguely recall having to > > make sure the 1.5 emulator was the only one running and I had to start > > it explicitly before running the application - not sure why that > > mattered, but... > > > All of this may depend on what version of the SDK you have installed > > (1.6, 2.0, ...). Currently I have installed v2.0. > > > HTH > > > Best Regards, > > Eric > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Text To Speech Android 1.6 with minsdk 3
Ok, I definitely do not see how to make this work. I don't grasp how the wrapping method here in any way spares the 1.5 runtime environment from having references to text-to-speech things. A 1.5 user tried my test build and gets a force close. I redoubled my efforts to manually select a 1.5 emulation target, and if my dependency is 1.6 and minSdk=3, it will not show my 1.5 target. If I compile against 1.6 and then try to trick Eclipse by changing it to 1.5 before invoking the debug upon my 1.5 target. Then, it realizes the trick and balks. I am rapidly realizing that I should have separate products for 1.5 and earlier and one for 1.6 and later. That would be an ugly upgrade transition, as I have taken money from all users for a common build. tone On Feb 4, 9:09 am, Eric Carman wrote: > Hello Tone, > > You definitely have to target the 1.6 (or greater) platform for this > to compile. > > I remember having trouble getting the debugger to attach to the 1.5 > emulator. I don't remember if I was able to do that or if I relied on > Toast/log messages to zero in on my 1.5 specific issues. I'm not near > the proper computer now to test it out. I vaguely recall having to > make sure the 1.5 emulator was the only one running and I had to start > it explicitly before running the application - not sure why that > mattered, but... > > All of this may depend on what version of the SDK you have installed > (1.6, 2.0, ...). Currently I have installed v2.0. > > HTH > > Best Regards, > Eric -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Text To Speech Android 1.6 with minsdk 3
Hello Tone, You definitely have to target the 1.6 (or greater) platform for this to compile. I remember having trouble getting the debugger to attach to the 1.5 emulator. I don't remember if I was able to do that or if I relied on Toast/log messages to zero in on my 1.5 specific issues. I'm not near the proper computer now to test it out. I vaguely recall having to make sure the 1.5 emulator was the only one running and I had to start it explicitly before running the application - not sure why that mattered, but... All of this may depend on what version of the SDK you have installed (1.6, 2.0, ...). Currently I have installed v2.0. HTH Best Regards, Eric -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Text To Speech Android 1.6 with minsdk 3
I don't see how one is supposed to compile this without targetting 1.6, and if one targets 1.6, how does one get it to run on a 1.5 device? I have minSdk=3 but my Eclipse projects don't want to compile WrapTTS without replacing my Android 1.5 dependency with Android 1.6 Once I do that, I can start a 1.5 emulator and the debugger will not target it. Ideas? tone -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Text To Speech Android 1.6 with minsdk 3
Eric, Thanks for the response! Sorry for my delay as well, it's been a busy holiday. I'm not exactly sure what I did, but I got it working on 1.5 devices. Thanks for writing your initial message and code, it's much appreciated! Hayden On Dec 30 2009, 8:54 am, Eric Carman wrote: > Hello Hayden, > > I'm not sure why you are getting this error. It looks like the method > checkavailable can't be found. Strange. Also hard to say without > seeing the code. > > One thing to check: Make sure the block > > static { > try { > WrapTTS.checkAvailable(); > mTTSClassAvailable = true; > } catch (Throwable t) { > mTTSClassAvailable = false; > } > } > > isn't part of any method in your main unit. It is called outside of > any constructor or any other method. > > Also, sorry for the delay in responding. Apparently I don't have my > profile set up to email me when I get a response to a posting. > > Best Regards, > Eric -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Text To Speech Android 1.6 with minsdk 3
Hello Hayden, I'm not sure why you are getting this error. It looks like the method checkavailable can't be found. Strange. Also hard to say without seeing the code. One thing to check: Make sure the block static { try { WrapTTS.checkAvailable(); mTTSClassAvailable = true; } catch (Throwable t) { mTTSClassAvailable = false; } } isn't part of any method in your main unit. It is called outside of any constructor or any other method. Also, sorry for the delay in responding. Apparently I don't have my profile set up to email me when I get a response to a posting. Best Regards, Eric -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Text To Speech Android 1.6 with minsdk 3
Thanks, glad you posted this! I used your WrapTTS class exactly as you have it, but nfortunately, running it on the 1.5 emulator still crashes (works great on 1.6 though). Just doing what you did above, declaring the 2 global variables and doing the checkAvailable() check, but the app force closes as soon as the activity starts. Below are the errors I am getting in LogCat pertaining to this. Any ideas? LogCat: 12-19 13:33:24.507: INFO/dalvikvm(953): Failed resolving Lme/myApp/ WrapTTS; interface 42 'Landroid/speech/tts/TextToSpeech $OnInitListener;' 12-19 13:33:24.587: WARN/dalvikvm(953): Link of class 'Lme/myApp/ WrapTTS;' failed 12-19 13:33:24.597: ERROR/dalvikvm(953): Could not find method me.myApp.WrapTTS.checkAvailable, referenced from method me.myApp.DisplayStory. 12-19 13:33:24.647: WARN/dalvikvm(953): VFY: unable to resolve static method 562: Lme/myApp/WrapTTS;.checkAvailable ()V 12-19 13:33:24.647: WARN/dalvikvm(953): VFY: rejecting opcode 0x71 at 0x0020 On Nov 18, 4:48 pm, Eric Carman wrote: > Hello, > > I was playing with addingTexttoSpeechto one of my applications and > have been working with it using the Android1.6SDK. I was hoping to > release the code such that it could be used on the earlier1.5OS > since there are still quite a few of these around - and this is an > upgrade. I realize that the TTS won't work on the1.5(at least not as > I have it here), but I didn't want the app disappearing from the > market for those devices. > > At any rate, after struggling for a while with this - a lot of trial > and error - I came up with what now seems like a simple wrapper to > allow for the backward compatibility. This was mostly taken from the > Android blog entry > > http://android-developers.blogspot.com/2009/04/backward-compatibility... > > so I'm not exactly breaking new ground. Also, I'm not using all of the > TTS features, hence the short list of "wrapped" methods, expand at > your leisure. I'm attaching it here for anyone to use and anyone to > comment on if I have done something really stupid. I'll comment back > if my testing uncovers anything untoward. > > Wrapper Class: > > package com.mydomain.myapp; > > import java.util.HashMap; > import java.util.Locale; > > import android.content.Context; > import android.speech.tts.TextToSpeech; > > public class WrapTTS { > > private TextToSpeech mTTS; > > /* class initialization fails when this throws an exception */ > static { > try { > Class.forName("android.speech.tts.TextToSpeech"); > } catch (Exception ex) { > throw new RuntimeException(ex); > } > } > > /* calling here forces class initialization */ > public static void checkAvailable() {} > > private OnInitListener onInitListener = null; > public interface OnInitListener { > public abstract void onInit(int status); > } > > public WrapTTS(Context context, WrapTTS.OnInitListener listener) { > onInitListener = listener; > mTTS = new TextToSpeech(context, > new TextToSpeech.OnInitListener() { > > @Override > public void onInit(int status) { > onInitListener.onInit(status); > } > > }); > > } > > public int setSpeechRate(float speechRate) { > return mTTS.setSpeechRate(speechRate); > } > > public void shutdown() { > mTTS.shutdown(); > } > > public int speak(Stringtext, int queueMode, HashMap > params) { > return mTTS.speak(text, queueMode, params); > } > > public int setLanguage(Locale loc) { > return mTTS.setLanguage(loc); > } > > public int isLanguageAvailable(Locale loc) { > return mTTS.isLanguageAvailable(loc); > } > > } > > The following is used at the top of my main application. > > private WrapTTS mTts = null; > private static boolean mTTSClassAvailable = false; > > /* establish whether the "TextToSpeech" class is available to us */ > > static { > try { > WrapTTS.checkAvailable(); > mTTSClassAvailable = true; > } catch (Throwable t) { > mTTSClassAvailable = false; > } > } > > Use the mTTSClassAvailable to know whether to bother to even try to > set up the engine. > > Hopefully it helps someone. > > Best Regards, > Eric -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe fro