java.lang.RuntimeException:无法恢复活动:java.lang.NullPointerException

时间:2017-06-17 12:05:48

标签: java android augmented-reality wikitude

我的代码遇到了问题。我收到了RuntimeException.Kindly请帮帮我。

我收到以下错误日志:

06-17 18:11:32.646 13750-13750/? E/Zygote: v2 06-17 18:11:32.646 13750-13750/? E/Zygote: accessInfo : 0 06-17 18:11:33.226 13750-13750/com.example.cocol.timisoara2021 E/MotionRecognitionManager: mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@f847827 06-17 18:11:33.226 13750-13750/com.example.cocol.timisoara2021 E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@d2d3ad4 06-17 18:11:33.226 13750-13750/com.example.cocol.timisoara2021 E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@d2d3ad4 06-17 18:11:36.566 13750-14348/com.example.cocol.timisoara2021 E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. 06-17 18:11:36.666 13750-13750/com.example.cocol.timisoara2021 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.cocol.timisoara2021, PID: 13750 java.lang.RuntimeException: Unable to resume activity {com.example.cocol.timisoara2021/com.example.cocol.timisoara2021.Main2Activity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.wikitude.common.orientation.internal.a.a()' on a null object reference at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4226) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4328) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3427) at android.app.ActivityThread.access$1100(ActivityThread.java:229) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7407) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.wikitude.common.orientation.internal.a.a()' on a null object reference at com.wikitude.architect.ArchitectView.onResume(ProGuard:818) at com.example.cocol.timisoara2021.Main2Activity.onResume(Main2Activity.java:59) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1287) at android.app.Activity.performResume(Activity.java:7015) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4215) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4328)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3427)  at android.app.ActivityThread.access$1100(ActivityThread.java:229)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:7407)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)  这里是第53行:architectView.onResume();

代码:

package com.example.cocol.timisoara2021;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.wikitude.architect.ArchitectStartupConfiguration;
import com.wikitude.architect.ArchitectView;

public class Main2Activity extends AppCompatActivity {


    private ArchitectView architectView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);


        this.architectView = (ArchitectView) this.findViewById(R.id.architectView);

        final ArchitectStartupConfiguration config = new ArchitectStartupConfiguration();
        config.setLicenseKey("KKvjW60rM1+LoIdIXdMFdqLeXM8rI6uDFqScJycG9rTXI7GHrRdOx9dycHtxv8Ef6Y6jHB/abqr26X6+eqQXyb+ci4ETEEzCQAQFg3h4/+7DhpwYxY3ayzp3jh/+THcSLe2aKZPAvImpV5Ci0Y7yW891E7d+ionYP0iqJJt6mbNTYWx0ZWRfX05DoEhYDMgfmFUvxnY5fbtk7wnaNnJf4Orfhl+Zfp9DmwItjh/lTSX7MTbprDG700m7vZfWqY1j41pA5vYMiBTiiE1vn6qK66jZ8H5nxjsi3Jp3iAynh2VltO95P6CQy5IKBC9HYdWDtvL/lEmWk1lCOhs4xX8kxwsfD1rxqICVD+zP5Uv+4wnug4++E6vFSwUtDgSN+hY38QnTmh6wXKO5aO7PUm20UXC/7k2lvWNwywwX6LMwF4H4ShnIDQDdWSMSuLshIHvR4SWPNN3r+wK5ImnI/fl/yWmkpH66wB5jWSuE6PvIOSIKz+esUzxprAfQxT6bkpenU/jxNwPaYB8ZbhUHCSCN7vWvGO7z12V/B98xWCGzRdZE5VZqNEOyPA/AfvjSJBmenYpvgm4dw0hgyBQrkoc56P6jOEc8W1aSKdfXfmv0olhbapaEzSoKubZXoZ0ZgPPfjQ6eHtzSVkoOB2fHCVONXseHnjsj9+LYNx3w+DLn0PY=");
        this.architectView.onCreate(config);

    }


    protected void OnPostCreate(Bundle savedInstanceState) {

        super.onPostCreate(savedInstanceState);

        architectView.onPostCreate();

        try {
            this.architectView.load("file:///android_asset/POI/index.html");
        }catch (Exception e) {


        }
    }

    @Override
    protected void onPause() {

        super.onPause();
        architectView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        architectView.onResume();

    }

    @Override

    protected void onDestroy() {

        super.onDestroy();
        architectView.onDestroy();
    }




}

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

你的onPostCreate方法有一个大写的“O”。因此我假设它从未被调用,这意味着当您调用architectView.onResume时,ArchitectView处于无效状态。

尝试:

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    architectView.onPostCreate();
    try {
        this.architectView.load("file:///android_asset/POI/index.html");
    }catch (Exception e) {
    }
}