Start a new topic

Integrate Wikitude on Android project

Integrate Wikitude on Android project
1 Comment


Hi,

I have a trouble when I want access to my Activity ARView

This is my code :

package com.robonumeriqueandroid;

 

/**

 * Created by MGSnakeEater on 04/10/15.

 */

 

import android.app.Activity;

import android.os.Bundle;

import android.util.Log;

 

import com.wikitude.architect.ArchitectView;

import com.wikitude.architect.StartupConfiguration;

 

import java.io.IOException;

 

public class ARView extends Activity{

 

    public ArchitectView architectView;

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.ar2);

        String tag = "MyActivity";

 

 

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

/* pass SDK key if you have one, this one is only valid for this package identifier and must not be used somewhere else */

        //final ArchitectView.ArchitectConfig config = new ArchitectView.ArchitectConfig();

         final StartupConfiguration config = new StartupConfiguration( "hrqhup1CuCgq5kyHVMUnSkpEDtHhmJEmfzT0hfRu/heimKR3zHMKfCPfJDYB7n6wjMtP9oibRCwIx5trZTXy6HLH6qJZE5JdS3Yo1L7vMvRow0vah6nqw+aPzVExQ9IXcHRTPLDb7nEkfDb/7yOf4qBDCM/xzWEhhCY4mj/Y0NdTYWx0ZWRfX4Qo2xVitKizo83TK0cwizuxeWdE4dTy95+P/RVWZWM6HBy53loj6P1X7IFY+7ovJLj6ooJP9oS33AdPZgR4FbzS2CX4Dsno7LpGAEsfNAXMbDhi74ub2iyxKjrGlFGHhLils8q2CTD9FJVwtQq3sw+fM1enZXvxoERyoSJX0QEqqbteIsb7lyi210gkwWqOEJLVugfzAa+v838ql6CLDiXiOVJMmXtDQd2Du1eidJ7bx+CbyUZxaJCwjY1aqvP46XAVxX9DhtzUgv4Jj4mSBhlpTolt8nNkJDjLoJVwX2sK9J3l8cXKKXBmzzOjb+vK95gZSYyB7WmhXbiSFo8J0AdMZM7hQK8tMq1wtAOs6QAXbs7reZhbbngI4RLdjSvbfQIpaJruCP/Jn9kIl+KILLvma1yMq1RuBafCUpXmlQcgvSArrobCbgmHmBYvlHu1589wURG6vrXLDbe1UEAB4OXPIG9UqsesNkba+5k2WWsORd26srY9rFfw9jq9uD5w5WTt/nKLLZK7",

                 StartupConfiguration.Features.Tracking2D,

                 StartupConfiguration.CameraPosition.BACK);

 

/* first mandatory life-cycle notification */

         this.architectView.onCreate( config );

 

        Log.d(tag, "Start Camera App");

 

 

 

        this.architectView.onPostCreate();

 

        try {

            String test = "http://myURL.com/test.html";

// load content via url in architectView, ensure '<script src="architect://architect.js"></script>' is part of this HTML file, have a look at wikitude.com's developer section for API references

            this.architectView.load( test );

 

 

        } catch (IOException e1) {

            e1.printStackTrace();

        }

 

 

    }

 

    @Override

    protected void onPostCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onPostCreate(savedInstanceState);

        if ( this.architectView != null ) {

 

// call mandatory live-cycle method of architectView

 

        }

    }

}

The error comes from this line : 

This is my error : this.architectView.onCreate( config );

 Process: com.robonumeriqueandroid, PID: 2259

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.robonumeriqueandroid/com.robonumeriqueandroid.ARView}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.wikitude.architect.ArchitectView.onCreate(com.wikitude.architect.StartupConfiguration)' on a null object reference

            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)

            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)

            at android.app.ActivityThread.access$800(ActivityThread.java:151)

            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)

            at android.os.Handler.dispatchMessage(Handler.java:102)

            at android.os.Looper.loop(Looper.java:135)

            at android.app.ActivityThread.main(ActivityThread.java:5257)

            at java.lang.reflect.Method.invoke(Native Method)

            at java.lang.reflect.Method.invoke(Method.java:372)

            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.wikitude.architect.ArchitectView.onCreate(com.wikitude.architect.StartupConfiguration)' on a null object reference

            at com.robonumeriqueandroid.ARView.onCreate(ARView.java:35)

            at android.app.Activity.performCreate(Activity.java:5990)

            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)

            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)

            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)

            at android.app.ActivityThread.access$800(ActivityThread.java:151)

            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)

            at android.os.Handler.dispatchMessage(Handler.java:102)

            at android.os.Looper.loop(Looper.java:135)

            at android.app.ActivityThread.main(ActivityThread.java:5257)

            at java.lang.reflect.Method.invoke(Native Method)

            at java.lang.reflect.Method.invoke(Method.java:372)

            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

 

Thx
Login or Signup to post a comment