0

我在设备 > 4.0 的翻译中遇到错误,而在 2.2 n 其他设备中同样适用。

我收到以下错误:

 try {
                String system_lang      =Locale.getDefault().getLanguage(); 

                Log.v("------","system_lang: "+system_lang+"Lang: "+lang_from+" to "+lang_to);

                String translatedText = Translate.DEFAULT.execute(originalMsg,lang_from, lang_to);
                Log.v("------","trnslate "+translatedText);
                messageText.setText(translatedText);
                translate_flag = true;
            } catch (GoogleAPIException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

}

    03-30 18:25:05.248: V/------(722): system_lang: enLang: nl to fr
03-30 18:25:05.248: I/System.out(722): Error: [google-api-translate-java] Error retrieving translation.
03-30 18:25:05.248: W/System.err(722): com.google.api.GoogleAPIException: java.lang.Exception: [google-api-translate-java] Error retrieving translation.
03-30 18:25:05.248: W/System.err(722):  at com.google.api.translate.TranslateV2.execute(TranslateV2.java:68)
03-30 18:25:05.248: W/System.err(722):  at com.credencys.globr.ChatActivity$2.onClick(ChatActivity.java:1018)
03-30 18:25:05.248: W/System.err(722):  at android.view.View.performClick(View.java:4198)
03-30 18:25:05.248: W/System.err(722):  at android.view.View$PerformClick.run(View.java:17158)
03-30 18:25:05.248: W/System.err(722):  at android.os.Handler.handleCallback(Handler.java:615)
03-30 18:25:05.248: W/System.err(722):  at android.os.Handler.dispatchMessage(Handler.java:92)
03-30 18:25:05.248: W/System.err(722):  at android.os.Looper.loop(Looper.java:137)
03-30 18:25:05.258: W/System.err(722):  at android.app.ActivityThread.main(ActivityThread.java:4918)
03-30 18:25:05.258: W/System.err(722):  at java.lang.reflect.Method.invokeNative(Native Method)
03-30 18:25:05.258: W/System.err(722):  at java.lang.reflect.Method.invoke(Method.java:511)
03-30 18:25:05.258: W/System.err(722):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
03-30 18:25:05.258: W/System.err(722):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
03-30 18:25:05.258: W/System.err(722):  at dalvik.system.NativeStart.main(Native Method)
03-30 18:25:05.258: W/System.err(722): Caused by: java.lang.Exception: [google-api-translate-java] Error retrieving translation.
03-30 18:25:05.258: W/System.err(722):  at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:99)
03-30 18:25:05.258: W/System.err(722):  at com.google.api.translate.TranslateV2.execute(TranslateV2.java:62)
03-30 18:25:05.258: W/System.err(722):  ... 12 more
03-30 18:25:05.258: W/System.err(722): Caused by: java.lang.NullPointerException
03-30 18:25:05.258: W/System.err(722):  at libcore.net.http.HttpEngine.writeRequestHeaders(HttpEngine.java:646)
03-30 18:25:05.258: W/System.err(722):  at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:800)
03-30 18:25:05.258: W/System.err(722):  at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
03-30 18:25:05.258: W/System.err(722):  at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
03-30 18:25:05.258: W/System.err(722):  at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:271)
03-30 18:25:05.258: W/System.err(722):  at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:93)
03-30 18:25:05.258: W/System.err(722):  ... 13 more
03-30 18:25:19.183: D/SMACK(722): 06:25:19 PM SENT (1116687320):  

我用谷歌搜索但找不到解决方案。任何提示或帮助都会被应用。谢谢

4

1 回答 1

0

这可能是因为某些默认值在 android 更改时更改了尝试设置没有默认值的东西。

于 2013-03-30T13:22:47.367 回答