javaandroidandroid-studiotext-to-speech

Android-Text To Speech works in an emulator but not on an Android device


Text to speech app works on an emulator fine, but on both of my Samsung devices, it does not work today, although the language was already downloaded and also it worked yesterday. Is it about my devices or code?

logcat output:

08-14 20:43:31.358 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.418 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.468 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.508 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.558 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.618 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.628 26355-26355/com.example.semra.text_to_speech_app W/System: ClassLoader referenced unknown path: /data/app/com.example.semra.text_to_speech_app-1/lib/arm64
08-14 20:43:31.638 26355-26355/com.example.semra.text_to_speech_app D/ContextRelationManager: ContextRelationManager() : FEATURE_ENABLED=true
08-14 20:43:31.638 26355-26355/com.example.semra.text_to_speech_app I/InstantRun: starting instant run server: is main process
08-14 20:43:31.738 26355-26355/com.example.semra.text_to_speech_app W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
08-14 20:43:31.878 26355-26355/com.example.semra.text_to_speech_app D/TextView: setTypeface with style : 0
08-14 20:43:31.878 26355-26355/com.example.semra.text_to_speech_app D/TextView: setTypeface with style : 0
08-14 20:43:31.918 26355-26355/com.example.semra.text_to_speech_app D/TextView: setTypeface with style : 0
    setTypeface with style : 0
08-14 20:43:31.938 26355-26355/com.example.semra.text_to_speech_app D/TextView: setTypeface with style : 0
08-14 20:43:31.998 26355-26355/com.example.semra.text_to_speech_app W/ResourcesManager: Resource getTopLevelResources for package com.samsung.SMToverlayDirs =Null
    Resource getTopLevelResources for package com.google.android.ttsoverlayDirs =Null
08-14 20:43:32.008 26355-26355/com.example.semra.text_to_speech_app I/TextToSpeech: Sucessfully bound to com.samsung.SMT
08-14 20:43:32.028 26355-26355/com.example.semra.text_to_speech_app D/SecWifiDisplayUtil: Metadata value : SecSettings2
08-14 20:43:32.028 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{6eff61d I.E...... R.....ID 0,0-0,0}
08-14 20:43:32.038 26355-26549/com.example.semra.text_to_speech_app D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
08-14 20:43:32.058 26355-26355/com.example.semra.text_to_speech_app I/TextToSpeech: Connected to ComponentInfo{com.samsung.SMT/com.samsung.SMT.SamsungTTSService}
08-14 20:43:32.058 26355-26550/com.example.semra.text_to_speech_app I/TextToSpeech: Set up connection to ComponentInfo{com.samsung.SMT/com.samsung.SMT.SamsungTTSService}
08-14 20:43:32.138 26355-26549/com.example.semra.text_to_speech_app I/Adreno: QUALCOMM build                   : f696b84, I59a6815413
    Build Date                       : 09/29/16
    OpenGL ES Shader Compiler Version: XE031.07.00.00
    Local Branch                     : 
    Remote Branch                    : quic/LA.BR.1.3.5_rb1.4
    Remote Branch                    : NONE
    Reconstruct Branch               : NOTHING
08-14 20:43:32.148 26355-26549/com.example.semra.text_to_speech_app I/OpenGLRenderer: Initialized EGL, version 1.4
08-14 20:43:32.188 26355-26355/com.example.semra.text_to_speech_app W/art: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
08-14 20:43:32.198 26355-26549/com.example.semra.text_to_speech_app D/libGLESv1: DTS_GLAPI : DTS is not allowed for Package : com.example.semra.text_to_speech_app
08-14 20:43:32.208 26355-26549/com.example.semra.text_to_speech_app E/libGLESv2: HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
08-14 20:43:32.218 26355-26549/com.example.semra.text_to_speech_app E/libGLESv2: HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
    HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
    HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
    HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
    HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
08-14 20:43:32.228 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 63 - 0, 0) vi=Rect(0, 63 - 0, 0) or=1
08-14 20:43:32.248 26355-26355/com.example.semra.text_to_speech_app I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@a201d2 time:2839061
08-14 20:43:33.128 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: ViewPostImeInputStage processPointer 0
08-14 20:43:33.178 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: ViewPostImeInputStage processPointer 1
08-14 20:43:33.368 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: MSG_RESIZED: ci=Rect(0, 63 - 0, 0) vi=Rect(0, 63 - 0, 897) or=1
08-14 20:43:33.938 26355-26355/com.example.semra.text_to_speech_app W/art: Failed to open zip archive '/system/framework/qcom.fmradio.jar': I/O Error
08-14 20:43:35.048 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: ViewPostImeInputStage processPointer 0
08-14 20:43:35.078 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: ViewPostImeInputStage processPointer 1
08-14 20:43:35.098 26355-26355/com.example.semra.text_to_speech_app E/Error: lang_missing_data
08-14 20:43:35.118 26355-26355/com.example.semra.text_to_speech_app D/SecWifiDisplayUtil: Metadata value : SecSettings2
08-14 20:43:35.118 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: #1 mView = android.widget.LinearLayout{bd95b08 V.E...... ......I. 0,0-0,0 #10203a4 android:id/toast_layout_root}
08-14 20:43:35.128 26355-26549/com.example.semra.text_to_speech_app E/libGLESv2: HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
08-14 20:43:35.188 26355-26549/com.example.semra.text_to_speech_app E/libGLESv2: HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
08-14 20:43:35.198 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
08-14 20:43:35.268 26355-26549/com.example.semra.text_to_speech_app D/OpenGLRenderer: endAllStagingAnimators on 0x7fa6613400 (RippleDrawable) with handle 0x7fac7159e0
08-14 20:43:35.528 26355-26355/com.example.semra.text_to_speech_app V/ActivityThread: updateVisibility : ActivityRecord{57862a1 token=android.os.BinderProxy@a201d2 {com.example.semra.text_to_speech_app/com.example.semra.text_to_speech_app.MainActivity}} show : false
08-14 20:43:38.598 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: #3 mView = null

Code:

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    TextToSpeech t_speech;
    int result;
    EditText edit_text;
    String text;
    Button b_sp,b_st;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        this.init();
    }
    public void init(){
        edit_text=(EditText)this.findViewById(R.id.editText);
        b_sp=(Button)this.findViewById(R.id.speak);
        b_st=(Button)this.findViewById(R.id.stop);
        b_sp.setOnClickListener(this);
        b_st.setOnClickListener(this);
        t_speech=new TextToSpeech(this, new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                if(status==TextToSpeech.SUCCESS){
                    result=t_speech.setLanguage(new Locale("tr", "TR"));
                }
                else{
                    Toast.makeText(getApplicationContext(),"Text To Speech is not supported on your device",Toast.LENGTH_LONG).show();
                }
            }
        });
    }
    @Override
    public void onClick(View v) {
        if(v.getId()==R.id.speak){
            if(result==TextToSpeech.LANG_MISSING_DATA){
                Toast.makeText(getApplicationContext(),"Text To Speech is not supported on your device",Toast.LENGTH_LONG).show();
            }
            else if( result==TextToSpeech.LANG_NOT_SUPPORTED){
                Toast.makeText(getApplicationContext(),"Text To Speech is not supported on your device",Toast.LENGTH_LONG).show();
                Log.e("Error","lang_missing_data");
                Intent installIntent = new Intent();
                installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                startActivity(installIntent);
            }
            else {
                text = edit_text.getText().toString();
                t_speech.speak(text, TextToSpeech.QUEUE_FLUSH, null);
            }
        }
        else if(v.getId()==R.id.stop){
            if(t_speech!=null){
                t_speech.stop();
                
            }
        }
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        if(t_speech!=null){
            t_speech.stop();
            t_speech.shutdown();
        }
    }
}

What could be wrong, and how do I debug this?


Solution

  • It can be both the device and the code.

    The one major thing I see is that you have if(LANG_MISSING_DATA) and if(LANG_NOT_SUPPORTED) written backwards (swapped).

    Also, although any device can use any engine, Samsung devices often use the Samsung speech engine, while emulators generally use either Google or PICO (PICO is very old and doesn't support very many languages).


    Debugging advice:

    1. Don't use the exact same phrase in all your Logs. If you do this, then it's difficult to tell what is causing the error. Do this instead:

      if(status==TextToSpeech.SUCCESS){
          result=t_speech.setLanguage(new Locale("tr", "TR"));
      }
      else{
          Toast.makeText(getApplicationContext(),"initialization of tts failed",Toast.LENGTH_LONG).show();
      }
      

      ...

      if(result==TextToSpeech.LANG_NOT_SUPPORTED){
          Toast.makeText(getApplicationContext(),"tts does not support the Locale/language specified",Toast.LENGTH_LONG).show();
      }
      

      ...

      if( result==TextToSpeech.LANG_MISSING_DATA){
          Toast.makeText(getApplicationContext(),"tts is missing the data required for the locale/language specified",Toast.LENGTH_LONG).show();
      

    Also, one other thing to note, if you are offline, the Google speech engine can give a false positive to result=t_speech.setLanguage, and then speak silence when you actually request speech.