Android 4.0>错误:[google-api-translate-java]检索翻译时出错

时间:2013-03-30 13:07:48

标签: android google-translate

我在设备翻译时遇到错误> 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):  
我用谷歌搜索但找不到解决方案。 任何提示或帮助都是适当的。 感谢

1 个答案:

答案 0 :(得分:0)

可能是因为某些默认值在Android更改时尝试设置somthing而没有默认值。