6

I am integrating BOX.COM with my android application.So I am using BoxAndroidLibraryV2 and BoxJavaLibraryV2 with my application. I could run the sample android application BoxSDKSample. So I copied necessary class and layouts from sample application.Now I am getting error message as follows.

07-23 15:51:02.230: E/AndroidRuntime(14857): Process: com.filenet.ecm, PID: 14857 
07-23 15:51:02.230: E/AndroidRuntime(14857): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.filenet.ecm/com.box.boxandroidlibv2.activities.OAuthActivity} : java.lang.NullPointerException: Attempt to invoke virtual method 'void com.box.boxandroidlibv2.views.OAuthWebView.setAllowShowingRedirectPage(boolean)' on a null object reference 
07-23 15:51:02.230: E/AndroidRuntime(14857): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at android.app.ActivityThread.access$800(ActivityThread.java:144) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at android.os.Handler.dispatchMessage(Handler.java:102) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at android.os.Looper.loop(Looper.java:155) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at android.app.ActivityThread.main(ActivityThread.java:5696) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at java.lang.reflect.Method.invoke(Native Method) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at java.lang.reflect.Method.invoke(Method.java:372) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824) 
07-23 15:51:02.230: E/AndroidRuntime(14857): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.box.boxandroidlibv2.views.OAuthWebView.setAllowShowingRedirectPage(boolean)' on a null object reference 
07-23 15:51:02.230: E/AndroidRuntime(14857): at com.box.boxandroidlibv2.activities.OAuthActivity.createOAuthWebView(OAuthActivity.java:78) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at com.box.boxandroidlibv2.activities.OAuthActivity.startOAuth(OAuthActivity.java:66) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at com.box.boxandroidlibv2.activities.OAuthActivity.onCreate(OAuthActivity.java:52) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at android.app.Activity.performCreate(Activity.java:5958) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129) 
07-23 15:51:02.230: E/AndroidRuntime(14857): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364) 
07-23 15:51:02.230: E/AndroidRuntime(14857): ... 10 more

Please suggest me to resolve this problem.

With Regards,

Babu Kaliyamoorthy.

Abhinav Singh Maurya
  • 3,313
  • 8
  • 33
  • 51
BABU K
  • 917
  • 13
  • 35

2 Answers2

0

Like the comments say, we really cannot know without more code what is wrong. But looking closer at the NullPointerException, it seems to be a pretty common problem with OAuth and WebViews. You can see that your OAuthWebView was the null object most likely. This means you probably need to create the web view as you probably never created it.

The sample you speak of might have had the webview built into Android .xml files or in another activity or you forgot that code. Just check it over carefully, and if you can post code. Post code on where you create the OAuthWebView. It seems like after setting up the custom webview OAuthWebView this error should go away.

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.box.boxandroidlibv2.views.OAuthWebView.setAllowShowingRedirectPage(boolean)' on a null object reference

When you get Attempt to invoke virtual method -blahblahblah- on a null object reference look backwards and see what the last function, AKA the virtual method, call was (in your case it was setAllowingShowingRedirectPage(boolean)) and the null object was the object that called that function, OAuthWebView.

This happens twice in your stack trace so very likely that the creation or management of your instance of OAuthWebView is the problem.

napkinsterror
  • 1,915
  • 4
  • 18
  • 27
0

I solved this problem by providing redirect_uri as http://localhost in box.com admin console OAuth2 Parameters http://developers.box.com/

BABU K
  • 917
  • 13
  • 35