Start a new topic

Wikitude JavaScript API app Crashes

Wikitude JavaScript API app Crashes


Hi,

I have gone through the documentation, i have tested many times but it crashes. Please help.

take a look at code

 

package com.sap.sapui5;
//import android.location.LocationListener;
import android.util.Log;
//import android.view.Menu;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

import com.wikitude.architect.ArchitectView;
import com.wikitude.architect.StartupConfiguration;
//import com.sap.sapui5.*;
//import org.apache.cordova.*;
import java.io.IOException;

//import org.apache.cordova
public class MainActivity extends Activity {
protected ArchitectView architectView;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

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

final StartupConfiguration config = new StartupConfiguration("dyAFp3nNVvSqb8wi8KGMubyaRX1sT65t7+NBBENcBXGR5w3UIvRC1j/NxPEMNCZYUhz0xnZ/UMEUcqf2/ITGSUFw4eqQ1wPqugwBUI/MvYZmvFTNzTBIPevF4FPihSz7RWsEUu6kjnGlpLpAXGfKtwUc7DSIeMOLdUlBc210sDxTYWx0ZWRfX+0resbUimdl1qJtBZa9P2F/fIJb5A84+JvXlAoY98Nzae4ooEHXq1Dgu2iz4DYGoBVFi/E1Y1Y42ZWVVA6l46HnY8idW1PxbT1UeYD0YOui6wvYTDoXiWQAqRlMBIOcszhsUCB+/2pFZzr4IWSPKgwJ04IAWs8S4Sh3z5FkPlfu6zjx1YptZiSultv7MSeUD5MYWyXJdjq8cvQtbUrY8JJ/K5K7oQNxstVO8D7zPKHU3qi2iuNvtEwrTZWvu4WAq/GnD6RpP/Fgzv3gPIzaTWk+Ace3tqDgbgDtfX2oGB9UFHqP/license/. . . ");



try {
/* first mandatory life-cycle notification */
this.architectView.onCreate(config);
} catch (RuntimeException rex) {
this.architectView = null;
Toast.makeText(getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT).show();
Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex);
}

}

protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
try {
this.architectView.onPostCreate();
this.architectView.load( "index.html" );
} catch (IOException e) {
e.printStackTrace();
}
}


@Override
public void onResume() {
super.onResume();

this.architectView.onResume();
}

@Override
protected void onPause() {
super.onPause();

// call mandatory live-cycle method of architectView
if ( this.architectView != null ) {
this.architectView.onPause();


}

}

@Override
protected void onStop() {
super.onStop();
}

@Override
protected void onDestroy() {
super.onDestroy();

// call mandatory live-cycle method of architectView
if ( this.architectView != null ) {
this.architectView.onDestroy();
}
}



 

 

Hi Hilmank,

Could you please provide us with some further information regarding your issue so that we can investigate more? For example, you could start by checking the logs to see if there is any message there regarding what event/action is happening that is causing your app to crash. 

Thanks

 Hi Eva,

In the Log Cat I found this Line.

05-20 11:01:58.083: D/AndroidRuntime(2906): --------- beginning of crash

05-20 11:01:58.084: E/AndroidRuntime(2906): FATAL EXCEPTION: main

05-20 11:01:58.084: E/AndroidRuntime(2906): Process: com.sap.sapui5, PID: 2906

05-20 11:01:58.084: E/AndroidRuntime(2906): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sap.sapui5/com.sap.sapui5.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.wikitude.architect.ArchitectView.onPostCreate()' on a null object reference

05-20 11:01:58.084: E/AndroidRuntime(2906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)

05-20 11:01:58.084: E/AndroidRuntime(2906): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)

05-20 11:01:58.084: E/AndroidRuntime(2906): at android.app.ActivityThread.-wrap11(ActivityThread.java)

05-20 11:01:58.084: E/AndroidRuntime(2906): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)

05-20 11:01:58.084: E/AndroidRuntime(2906): at android.os.Handler.dispatchMessage(Handler.java:102)

05-20 11:01:58.084: E/AndroidRuntime(2906): at android.os.Looper.loop(Looper.java:148)

05-20 11:01:58.084: E/AndroidRuntime(2906): at android.app.ActivityThread.main(ActivityThread.java:5417)

05-20 11:01:58.084: E/AndroidRuntime(2906): at java.lang.reflect.Method.invoke(Native Method)

05-20 11:01:58.084: E/AndroidRuntime(2906): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)

05-20 11:01:58.084: E/AndroidRuntime(2906): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

05-20 11:01:58.084: E/AndroidRuntime(2906): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.wikitude.architect.ArchitectView.onPostCreate()' on a null object reference

05-20 11:01:58.084: E/AndroidRuntime(2906): at com.sap.sapui5.MainActivity.onPostCreate(MainActivity.java:43)

05-20 11:01:58.084: E/AndroidRuntime(2906): at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1188)

05-20 11:01:58.084: E/AndroidRuntime(2906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2398)

05-20 11:01:58.084: E/AndroidRuntime(2906): ... 9 more

05-20 11:01:58.095: W/ActivityManager(1572):   Force finishing activity 

Hi Himank,
You set the architectView member to null in the catch block of your onCreate method. If you then try to access it in onPostCreate, it's a nullptr. The question is now why you hit the catch block in onCreate. Either you have some id problems in your layout.xml file so that the ArchitectView object can never be created or a exception is thrown within the onCreate of the ArchitectView.

Can you please make sure that the architectView object can be created in onCreate or post the exception log from onCreate in case something goes wrong in onCreate.

Best regards,

Andreas
Login or Signup to post a comment