android - Android 应用程序中的 ExceptionInInitializerError?

标签 android android-webview google-spreadsheet-api

在我的 Android 应用程序中,WebView Activity 类有以下行,

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

在 JSInterface 类中,我正在初始化 Google“SpreadSheetService”,如下所示,

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 -----

当我运行应用程序时,出现以下异常,

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

它有下面的轨迹

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)

我搜索了谷歌,但没有得到任何解决方案。知道为什么我会收到这个异常吗?

彼得

最佳答案

Based on this documentation抛出 ExceptionInInitializerError 以指示在评估静态初始化程序或静态变量的初始化程序期间发生异常。检查您的代码是否有任何静态初始化逻辑。

关于android - Android 应用程序中的 ExceptionInInitializerError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8929521/

相关文章:

Android:从相机保存的 Jpeg 看起来已损坏

android - android中的"Ə"字符

google-drive-api - 使用 https ://spreadsheets. google.com/feeds/时是否需要迁移到 Drive API

java - 抽象类的ORMLite Foreign Collection

android - ScrollView 中的 NumberPicker

android - 如何修复 java.lang.AssertionError : annotationType(): unrecognized Attribute name MODULE?

android - 如何在 Web View 中使用 Android 过渡效果?

html - 当 WebView 应该适合页面时,从左到右摆动

google-sheets - Google Sheet API v4

google-apps-script - 列出 Google Sheets 中的工作表名称并跳过前两个