Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid App Crash but source code shows no errors
    primarykey
    data
    text
    <p>When I compile it, there is no error showing in the Eclipse IDE. But When I run it, it keeps crashing. Why? </p> <p>I don't know what to do since there are no errors showing. It just run and crush before it starts.</p> <pre><code>public class MainActivity extends Activity implements OnClickListener, OnInitListener { private TextToSpeech tts; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tts = new TextToSpeech(this, this); this.initializeTextToSpeech("Hello World"); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override protected void onDestroy() { if (tts != null) { tts.stop(); tts.shutdown(); } super.onDestroy(); } @Override public void onInit(int status) { // TODO Auto-generated method stub if (status == TextToSpeech.SUCCESS) { tts.setLanguage(Locale.getDefault()); } else { tts = null; Toast.makeText(this, "Failed to initialize TTS engine.", Toast.LENGTH_SHORT).show(); } Log.d("onINIT", "started"); } @Override public void onClick(View v) { // TODO Auto-generated method stub } public void initializeTextToSpeech(String str) { if (tts != null) { String text = str; if (text != null) { if (!tts.isSpeaking()) { tts.speak(text, TextToSpeech.QUEUE_FLUSH, null); } } } } } </code></pre> <p>Here my LogCat:</p> <pre><code>12-21 01:53:07.698: I/Process(1467): Sending signal. PID: 1467 SIG: 9 12-21 01:53:07.870: E/Trace(1656): error opening trace file: No such file or directory (2) 12-21 01:53:07.962: D/AndroidRuntime(1656): Shutting down VM 12-21 01:53:07.962: W/dalvikvm(1656): threadid=1: thread exiting with uncaught exception (group=0xa61d2908) 12-21 01:51:16.462: E/AndroidRuntime(1467): FATAL EXCEPTION: main 12-21 01:51:16.462: E/AndroidRuntime(1467): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.testapp.testapp/com.testapp.testapp.MainActivity}: java.lang.RuntimeException: Binary XML file line #11: You must supply a layout_width attribute. 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.app.ActivityThread.access$600(ActivityThread.java:141) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.os.Handler.dispatchMessage(Handler.java:99) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.os.Looper.loop(Looper.java:137) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.app.ActivityThread.main(ActivityThread.java:5041) 12-21 01:51:16.462: E/AndroidRuntime(1467): at java.lang.reflect.Method.invokeNative(Native Method) 12-21 01:51:16.462: E/AndroidRuntime(1467): at java.lang.reflect.Method.invoke(Method.java:511) 12-21 01:51:16.462: E/AndroidRuntime(1467): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 12-21 01:51:16.462: E/AndroidRuntime(1467): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 12-21 01:51:16.462: E/AndroidRuntime(1467): at dalvik.system.NativeStart.main(Native Method) 12-21 01:51:16.462: E/AndroidRuntime(1467): Caused by: java.lang.RuntimeException: Binary XML file line #11: You must supply a layout_width attribute. 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:5614) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.view.ViewGroup$MarginLayoutParams.&lt;init&gt;(ViewGroup.java:5756) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.widget.RelativeLayout$LayoutParams.&lt;init&gt;(RelativeLayout.java:1190) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:1028) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:70) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.view.LayoutInflater.rInflate(LayoutInflater.java:748) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 12-21 01:51:16.462: E/AndroidRuntime(1467): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.app.Activity.setContentView(Activity.java:1881) 12-21 01:51:16.462: E/AndroidRuntime(1467): at com.testapp.testapp.MainActivity.onCreate(MainActivity.java:23) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.app.Activity.performCreate(Activity.java:5104) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 12-21 01:51:16.462: E/AndroidRuntime(1467): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 12-21 01:51:16.462: E/AndroidRuntime(1467): ... 11 more </code></pre> <p>My code was based on this: </p> <p><a href="http://www.techrepublic.com/blog/software-engineer/teach-your-next-android-app-to-speak/" rel="nofollow">http://www.techrepublic.com/blog/software-engineer/teach-your-next-android-app-to-speak/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload