的ExceptionInInitializerError在Android应用程序? [英] ExceptionInInitializerError in Android app?

查看:121
本文介绍了的ExceptionInInitializerError在Android应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序中的WebView活动类有以下行,

In my Android app the WebView activity class has following line,

webView.addJavascriptInterface(new JSInterface(this), "Android");   

而在JSInterface类,我初始化谷歌S preadSheetService像下面,

And in JSInterface class, I'm initializing Google "SpreadSheetService" like below,

import com.google.gdata.client.spreadsheet.SpreadsheetService;

--- some more imports ---


public class JSInterface {
    Context mContext;

    public SpreadsheetService service;

    /** Instantiate the interface and set the context */
    JSInterface(Context c) {
        mContext = c;
        service = new SpreadsheetService("List Demo");
    }

    ------- some more code -----

当我跑我得到以下异常的应用程序,

When I run the application I'm getting the following exception,

01-19 21:38:00.652: E/AndroidRuntime(4085): java.lang.ExceptionInInitializerError

它具有以下跟踪

which has the below trace

01-19 21:38:00.652: E/AndroidRuntime(4085): FATAL EXCEPTION: main
01-19 21:38:00.652: E/AndroidRuntime(4085): java.lang.ExceptionInInitializerError
01-19 21:38:00.652: E/AndroidRuntime(4085):     at com.android.quotes.JSInterface.<init>(JSInterface.java:33)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at com.android.quotes.CHQuotesActivity.onCreate(CHQuotesActivity.java:19)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at android.app.Activity.performCreate(Activity.java:4465)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at android.app.ActivityThread.access$600(ActivityThread.java:122)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at android.os.Looper.loop(Looper.java:137)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at android.app.ActivityThread.main(ActivityThread.java:4340)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at java.lang.reflect.Method.invokeNative(Native Method)
01-19 21:38:00.652: E/AndroidRuntime(4085):     at java.lang.reflect.Method.invoke(Method.java:511)

我搜索谷歌,但没有得到任何解决方案,这个..为什么我得到这个例外,任何想法?

I searched Google, but didnt get any solution for this.. Any idea on why I'm getting this exception??

彼得·

推荐答案

在此基础上文档一个的ExceptionInInitializerError被抛出,指示静态初始化或初始化一个静态变量的评估过程中发生了异常。检查你的code有任何静态初始化逻辑。

Based on this documentation An ExceptionInInitializerError is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable. Check your code has any static initialization logic.

这篇关于的ExceptionInInitializerError在Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆