Unknown pattern character X while running tone analyzer in Android

566 views Asked by At

I am new to Android and IBM Watson. I am building a simple app which analyzes the tone of input text. However, while running the application, I get the following error:

05-23 15:14:04.808 25157-25157/? I/art: Late-enabling -Xcheck:jni

05-23 15:14:04.949 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.312 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.350 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.398 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.445 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.492 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.535 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.588 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.632 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.682 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.721 25157-25157/com.abhishek.speechtotextapp W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.abhishek.speechtotextapp-2/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm/data@[email protected]@[email protected]) because non-0 exit status

05-23 15:14:05.722 25157-25157/com.abhishek.speechtotextapp W/System: ClassLoader referenced unknown path: /data/app/com.abhishek.speechtotextapp-2/lib/arm

05-23 15:14:05.727 25157-25157/com.abhishek.speechtotextapp I/InstantRun: starting instant run server: is main process

05-23 15:14:05.757 25157-25157/com.abhishek.speechtotextapp I/CredentialUtils: JNDI string lookups is not available.

05-23 15:14:05.890 25157-25331/com.abhishek.speechtotextapp D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true

? 05-23 15:14:05.932 25157-25331/com.abhishek.speechtotextapp I/Adreno-EGL: : EGL 1.4 QUALCOMM build: Nondeterministic_AU_msm8974_LA.BF.1.1.3_RB1__release_AU (Ia6c73e7530) OpenGL ES Shader Compiler Version: E031.29.00.00 Build Date: 12/04/15 Fri Local Branch: mybranch17080070 Remote Branch: quic/LA.BF.1.1.3_rb1.5 Local Patches: NONE Reconstruct Branch: NOTHING

05-23 15:14:05.933 25157-25331/com.abhishek.speechtotextapp I/OpenGLRenderer: Initialized EGL, version 1.4

05-23 15:14:14.628 25157-25881/com.abhishek.speechtotextapp W/art: Verification of void okhttp3.HttpUrl.canonicalize(okio.Buffer, java.lang.String, int, int, java.lang.String, boolean, boolean, boolean, boolean) took 114.407ms

05-23 15:14:16.233 25157-25881/com.abhishek.speechtotextapp D/OkHttp: --> POST https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone?version=2016-05-19 http/1.1 (16-byte body)

05-23 15:14:16.942 25157-25881/com.abhishek.speechtotextapp D/OkHttp: <-- 200 OK https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone?version=2016-05-19 (708ms, unknown-length body)

Stack Trace:

05-23 16:25:46.706 14754-15374/com.abhishek.toneanalyzertest W/System.err: java.lang.IllegalArgumentException: Unknown pattern character 'X'

05-23 16:25:46.706 14754-15374/com.abhishek.toneanalyzertest W/System.err: at java.text.SimpleDateFormat.validatePatternCharacter(SimpleDateFormat.java:323)

05-23 16:25:46.706 14754-15374/com.abhishek.toneanalyzertest W/System.err: at java.text.SimpleDateFormat.validatePattern(SimpleDateFormat.java:312)

05-23 16:25:46.706 14754-15374/com.abhishek.toneanalyzertest W/System.err: at java.text.SimpleDateFormat.(SimpleDateFormat.java:365)

05-23 16:25:46.706 14754-15374/com.abhishek.toneanalyzertest W/System.err: at java.text.SimpleDateFormat.(SimpleDateFormat.java:258)

05-23 16:25:46.707 14754-15374/com.abhishek.toneanalyzertest W/System.err: at com.ibm.watson.developer_cloud.util.DateDeserializer.(DateDeserializer.java:52)

05-23 16:25:46.707 14754-15374/com.abhishek.toneanalyzertest W/System.err: at com.ibm.watson.developer_cloud.util.GsonSingleton.registerTypeAdapters(GsonSingleton.java:53)

05-23 16:25:46.707 14754-15374/com.abhishek.toneanalyzertest W/System.err: at com.ibm.watson.developer_cloud.util.GsonSingleton.createGson(GsonSingleton.java:42)

05-23 16:25:46.707 14754-15374/com.abhishek.toneanalyzertest W/System.err: at com.ibm.watson.developer_cloud.util.GsonSingleton.getGsonWithoutPrettyPrinting(GsonSingleton.java:76)

05-23 16:25:46.707 14754-15374/com.abhishek.toneanalyzertest W/System.err: at com.ibm.watson.developer_cloud.util.ResponseUtils.getObject(ResponseUtils.java:93)

05-23 16:25:46.707 14754-15374/com.abhishek.toneanalyzertest W/System.err: at com.ibm.watson.developer_cloud.util.ResponseConverterUtils$3.convert(ResponseConverterUtils.java:79)

05-23 16:25:46.707 14754-15374/com.abhishek.toneanalyzertest W/System.err: at com.ibm.watson.developer_cloud.util.ResponseConverterUtils$3.convert(ResponseConverterUtils.java:76)

05-23 16:25:46.707 14754-15374/com.abhishek.toneanalyzertest W/System.err: at com.ibm.watson.developer_cloud.service.WatsonService.processServiceCall(WatsonService.java:479)

05-23 16:25:46.707 14754-15374/com.abhishek.toneanalyzertest W/System.err: at com.ibm.watson.developer_cloud.service.WatsonService$2.execute(WatsonService.java:254)

05-23 16:25:46.707 14754-15374/com.abhishek.toneanalyzertest W/System.err: at com.abhishek.toneanalyzertest.MainActivity$MyThread.run(MainActivity.java:128)

05-23 16:25:46.711 14754-14754/com.abhishek.toneanalyzertest D/AndroidRuntime: Shutting down VM

05-23 16:25:46.713 14754-14754/com.abhishek.toneanalyzertest E/AndroidRuntime: FATAL EXCEPTION: main Process: com.abhishek.toneanalyzertest, PID: 14754 Theme: themes:{default=overlay:system, iconPack:system, fontPkg:system, com.android.systemui=overlay:system, com.android.systemui.navbar=overlay:system} java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {com.abhishek.toneanalyzertest/com.abhishek.toneanalyzertest.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis.toString()' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:3733) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3776) at android.app.ActivityThread.-wrap16(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5461) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis.toString()' on a null object reference at com.abhishek.toneanalyzertest.MainActivity.onActivityResult(MainActivity.java:84) at android.app.Activity.dispatchActivityResult(Activity.java:6456) at android.app.ActivityThread.deliverResults(ActivityThread.java:3729) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3776)  at android.app.ActivityThread.-wrap16(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5461)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

I have included the JAR files for Watson services and provided user permissions in the manifest file. As per the error above, I am getting a OK (200 coe) response from the API. Following is the code:

private class cognitiveService extends AsyncTask<Void, Void, Void> {
    ToneAnalyzer service = new ToneAnalyzer(ToneAnalyzer.VERSION_DATE_2016_05_19);
    service.setUsernameAndPassword("<username>", "<password>");
    @Override
    protected Void doInBackground(Void... params) {
        try {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    txtOutput.setText("analyzing tone");
                }
            });
            ToneAnalysis tone = service.getTone(txt, null).execute();
            System.out.println("Tone: " + tone);
        } catch (final Exception e) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    txtOutput.setText(e.getLocalizedMessage());
                }
            });
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        super.onPostExecute(result);
    }
}
}
1

There are 1 answers

0
Joshua Alger On BEST ANSWER

I would take a look at the following SO question:

Unknown pattern character 'X' Exception occurs connecting to IBM Watson conversation API from Android

It seems this is a known issue that has been fixed, but not released as of yet. A workaround of updating to a snapshot release was recommended while you wait for the fix to be released to Maven.