致命异常:带有Observers的java.lang.NoClassDefFoundError

时间:2017-11-23 07:06:28

标签: android observable noclassdeffounderror

我遇到了一些Android设备(从Android OS 4到6)出现上述错误的奇怪问题。我创建了一个名为Response observer的类,它进一步扩展了我的Observer类。 (附上课程):

public abstract class ResponseObserver<T extends ServerResponse> implements Observer<T> {
    private static final Handler HANDLER = new Handler();

    @Override
    public void onChanged(@Nullable final T response) {
        onResponse(response);
        if (Common.nonNull(response)) {
            if (isOk(response)) {
                if(HandlerResponseCode.STATUS_SUCCESS.equals(response.getStatus())) {
                    new Handler().post(new Runnable() {
                        @Override
                        public void run() {
                            onSuccess(response);
                        }
                    });

                } else {
                    if (Common.nonNull(response.getError()))
                        onFail(response);
                    else
                        onNonFailureResponse(response);
                }
            } else {
                onNotOk(response);
            }
        }else{
            onNullResponse(response);
        }

    }

    public void onNullResponse(T response) {

    }

    public void onNonFailureResponse(T response) {
        // empty on purpose
    }

    public void onNotOk(@Nullable T response) {
        // empty on purpose
    }

    /**
     * Called as soon as the response is received. Implementors are responsible for null checks.
     *
     * @param response response object or null
     */
    public void onResponse(@Nullable T response) {
        // empty on purpose
    }

    /**
     * By default always return true which indicates no extra checks are required.
     *
     * @param response response from server
     * @return always true
     */
    public boolean isOk(T response) {
        return true;
    }

    public abstract void onSuccess(@Nullable T response);

}

Logcat (Crash details)

Fatal Exception: java.lang.NoClassDefFoundError: com/zotopay/zoto/datamodels/ResponseObserver
       at com.zotopay.zoto.activityviews.SplashActivity.fetchSMSKeywords(SplashActivity.java:102)
       at com.zotopay.zoto.activityviews.SplashActivity.loadDashboard(SplashActivity.java:164)
       at com.zotopay.zoto.activityviews.SplashActivity.continueLaunch(SplashActivity.java:193)
       at com.zotopay.zoto.activityviews.SplashActivity.onCreate(SplashActivity.java:77)
       at android.app.Activity.performCreate(Activity.java:5442)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493)
       at android.app.ActivityThread.access$800(ActivityThread.java:166)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5584)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
       at dalvik.system.NativeStart.main(NativeStart.java)

我这样称这个观察者:

smsLiveDataModel.fetchLiveDataFromService().observe(this, new ResponseObserver<SMSResponse>() {
                @Override
                public void onSuccess(@Nullable SMSResponse response) {

                }


            });

它正在崩溃,我已经建立了新的ResponseObserver。奇怪的是,我不知道为什么会崩溃。

请帮忙

0 个答案:

没有答案