• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by GurtejKanwar · Aug 10, 2012 at 05:48 PM · android

Null Pointer Exception in SurfaceView.updateWindow()?

As background: the application I'm working on uses Unity as a library project in Eclipse. I have a native Android shell with a Unity game as one sub-activity(SlotMachineActivity) in a TabActivity.

I'm getting many reports of a NullPointerException through the Android Market for my Unity Android application. I'm seeing two distinct stack traces, but they seem related (the error is on the same line in SurfaceView.java):

STACK TRACE #1:

 java.lang.NullPointerException
 at android.view.SurfaceView.updateWindow(SurfaceView.java:473)
 at android.view.SurfaceView.access$000(SurfaceView.java:86)
 at android.view.SurfaceView$2.onScrollChanged(SurfaceView.java:137)
 at android.view.ViewTreeObserver.dispatchOnScrollChanged(ViewTreeObserver.java:607)
 at android.view.ViewRoot.draw(ViewRoot.java:1363)
 at android.view.ViewRoot.performTraversals(ViewRoot.java:1260)
 at android.view.ViewRoot.handleMessage(ViewRoot.java:1861)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:130)
 at android.app.ActivityThread.main(ActivityThread.java:3686)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:507)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
 at dalvik.system.NativeStart.main(Native Method)


STACK TRACE #2:

 java.lang.RuntimeException: Unable to destroy activity
 at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2684)
 at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2702)
 at android.app.ActivityThread.access$2100(ActivityThread.java:117)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:964)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:130)
 at android.app.ActivityThread.main(ActivityThread.java:3696)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:507)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
 at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.RuntimeException: Unable to destroy activity
 at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2684)
 at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2593)
 at android.app.LocalActivityManager.dispatchDestroy(LocalActivityManager.java:622)
 at android.app.ActivityGroup.onDestroy(ActivityGroup.java:85)
 at com.cashislandgames.cashisland.CustomTabActivity.onDestroy(CustomTabActivity.java:380)
 at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2671)
 ... 11 more
 Caused by: java.lang.NullPointerException
 at android.view.SurfaceView.updateWindow(SurfaceView.java:473)
 at android.view.SurfaceView.onDetachedFromWindow(SurfaceView.java:270)
 at android.opengl.GLSurfaceView.onDetachedFromWindow(GLSurfaceView.java:532)
 at com.unity3d.player.q.a(Unknown Source)
 at com.unity3d.player.UnityPlayer.quit(Unknown Source)
 at com.cashisland.activity.SlotMachineActivity.onDestroy(SlotMachineActivity.java:283)
 at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2671)
 ... 16 more

The first stack trace doesn't necessarily have to do with Unity, but there are no other SurfaceViews in the app, and it's having a NullPointerException on the same line as the second stack trace.

The code for my onDestroy method in SlotMachineActivity.java is here:

  @Override
  protected void onDestroy() {
      if(sUnityPlayer!=null){
          sUnityPlayer.quit();
          sUnityPlayer = null;
      }
     
      // ...
     
      super.onDestroy();
  }

It seems like calling quit() on sUnityPlayer is causing some issues, but it seems internal to Unity, so I'm not sure how to fix it.

Any thoughts? Thanks!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

HELP first person controller setup iphone/android 2 Answers

Player size statistics in Editor.log - last scene is huge even in it;s empty 0 Answers

Notification is received but not displayed using Parse Unity SDK + Android 1 Answer

OnTriggerEnter fired incorrectly (android device only) 0 Answers

Terrain Texture Black on Android 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges