Canvas, SurfaceHolder, and Panels. Oh My!


Last Updated:

  1. cmh0114

    cmh0114 Well-Known Member This Topic's Starter

    Joined:
    Jan 10, 2010
    Messages:
    116
    Likes Received:
    7
    I'm having some huge troubles with accessing my Panels and SurfaceHolders and Canvases in my program. The code is below (three separate classes), and the program will crash before it even displays anything. Any tips someone can give would be awesome. This is pretty much copy-and-paste from Google's Lunar Lander, but I apparently messed something up.

    Code (Text):
    1.  
    2. public class myActivity extends Activity
    3. {
    4.     LinearLayout mLinearLayout;
    5.  
    6.    
    7.     /** Called when the activity is first created. */
    8.     @Override
    9.     public void onCreate(Bundle savedInstanceState)
    10.     {
    11.         Panel panel = new Panel(getApplicationContext());
    12.     }
    13. }
    14.  
    and

    Code (Text):
    1.  
    2. public class Panel extends SurfaceView implements SurfaceHolder.Callback {
    3.  
    4.     private CanvasThread canvasThread;
    5.    
    6.     public Panel(Context context) {
    7.         super(context);
    8.        
    9.         getHolder().addCallback(this);
    10.         canvasThread = new CanvasThread(getHolder(),getContext(),getHandler());
    11.         setFocusable(true);
    12. }
    13.    
    14.     @Override
    15.     public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
    16.         // TODO Auto-generated method stub
    17.     }
    18.  
    19.     @Override
    20.     public void surfaceCreated(SurfaceHolder holder) {
    21.         // TODO Auto-generated method stub
    22.         canvasThread.setRunning(true);
    23.         canvasThread.start();
    24.     }
    25.  
    26.     @Override
    27.     public void surfaceDestroyed(SurfaceHolder holder) {
    28.         // TODO Auto-generated method stub
    29.        
    30.         boolean retry = true;
    31.         canvasThread.setRunning(false);
    32.         while (retry) {
    33.                 try {
    34.                         canvasThread.join();
    35.                         retry = false;
    36.                 } catch (InterruptedException e) {
    37.                         // we will try it again and again...
    38.                 }
    39.         }
    40.     }
    41.     @Override
    42.     public void onDraw(Canvas canvas) {
    43.            
    44.             Paint paint = new Paint();
    45.            
    46.  
    47.             Bitmap icon = BitmapFactory.decodeResource(getResources(),
    48.                             R.drawable.icon);
    49.             canvas.drawColor(Color.BLACK);
    50.             canvas.drawBitmap(icon, 10, 10, null);
    51.            
    52.     }
    53.  
    54. }
    55.  
    and

    Code (Text):
    1.  
    2. package com.mst.Splat;
    3.  
    4. import android.content.Context;
    5. import android.graphics.Bitmap;
    6. import android.graphics.BitmapFactory;
    7. import android.graphics.Canvas;
    8. import android.os.Handler;
    9. import android.view.SurfaceHolder;
    10.  
    11. public class CanvasThread extends Thread {
    12.  
    13.     private SurfaceHolder mSurfaceHolder;
    14.     private Context mContext;
    15.     private Handler mHandler;
    16.     private boolean mRun;
    17.    
    18.     public CanvasThread(SurfaceHolder surfaceHolder, Context context,
    19.             Handler handler)
    20.     {
    21.         mSurfaceHolder = surfaceHolder;
    22.         mHandler = handler;
    23.         mContext = context;
    24.     }
    25.     public void setRunning(boolean b)
    26.     {
    27.         mRun = b;
    28.     }
    29.     public void run()
    30.     {
    31.        while (mRun) {
    32.            Canvas c = null;
    33.            try {
    34.                c = mSurfaceHolder.lockCanvas(null);
    35.                synchronized (mSurfaceHolder) {
    36.                    //if (mMode == STATE_RUNNING) updatePhysics();
    37.                    //Later, I'll use the original code -- this is just temp
    38.                    //this should only be implemented when the game is running
    39. //                 if(true) updatePhysics();
    40.                    doDraw(c);
    41.                }
    42.            } finally {
    43.                // do this in a finally so that if an exception is thrown
    44.                // during the above, we don't leave the Surface in an
    45.                // inconsistent state
    46.                if (c != null) {
    47.                    mSurfaceHolder.unlockCanvasAndPost(c);
    48.                }
    49.            }
    50.        }
    51.     }
    52.     public void doDraw(Canvas canvas)
    53.     {
    54.         // Draw the background image. Operations on the Canvas accumulate
    55.         // so this is like clearing the screen.      
    56.         Bitmap mBackgroundImage = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.background);
    57.         canvas.drawBitmap(mBackgroundImage, 0, 0, null);
    58.         Bitmap mIcon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.icon);
    59.         canvas.drawBitmap(mIcon, 0, 0, null);
    60.     }
    61. }
    62.  
    63.  
     

    Advertisement
  2. blundell

    blundell Well-Known Member

    Joined:
    Apr 23, 2010
    Messages:
    125
    Likes Received:
    17
  3. cmh0114

    cmh0114 Well-Known Member This Topic's Starter

    Joined:
    Jan 10, 2010
    Messages:
    116
    Likes Received:
    7
    Ok, so I found a cut-down version of the Lunar Lander that has less code, but still most of the stuff that LL has to run. Here's that:

    Main class:
    Code (Text):
    1.  
    2. package com.mst.Splat;
    3.  
    4.  
    5. import android.app.Activity;
    6. import android.content.Intent;
    7. import android.os.Bundle;
    8. import android.view.View;
    9. import android.view.View.OnClickListener;
    10. import android.widget.AdapterView;
    11. import android.widget.Button;
    12. import android.widget.GridView;
    13. import android.widget.ImageButton;
    14. import android.widget.ImageView;
    15. import android.widget.LinearLayout;
    16. import android.widget.Toast;
    17. import android.widget.AdapterView.OnItemClickListener;
    18.  
    19.  
    20.  
    21. public class SplatActivity extends Activity
    22. {
    23.     public SplatActivity act = this;
    24.     LinearLayout mLinearLayout;
    25.  
    26.    
    27.     /** Called when the activity is first created. */
    28.     @Override
    29.     public void onCreate(Bundle savedInstanceState)
    30.     {
    31.  
    32.         setContentView(R.layout.main);
    33.        
    34.         setTitle("Splat");
    35.        
    36.         super.onCreate(savedInstanceState);
    37.         //setContentView(R.layout.main);
    38.        
    39.         GridView gridview = (GridView)findViewById(R.id.gridview);
    40.         gridview.setAdapter(new ImageAdapter(this));
    41.         gridview.setPadding(1,300,1,1);
    42.  
    43.        
    44.         gridview.setOnItemClickListener(new OnItemClickListener()
    45.         {
    46.      
    47.               public void onItemClick(AdapterView<?> parent, View v, int position, long id)
    48.               {
    49.                 //Toast.makeText(SplatActivity.this, "" + position, Toast.LENGTH_SHORT).show();
    50.                 switch(position)
    51.                 {
    52.                     case 0: //Play
    53.                         Toast.makeText(SplatActivity.this, "Play", Toast.LENGTH_SHORT).show();
    54.                         startActivity(new Intent(SplatActivity.this, Play.class));
    55.                         break;
    56.                     case 1: //Instructions
    57.                         Toast.makeText(SplatActivity.this, "Instructions", Toast.LENGTH_SHORT).show();
    58.                         setContentView(R.layout.instructions_layout);
    59.                         ImageView instructions = (ImageView)findViewById(R.id.instructions);
    60.                         ImageButton backButton = (ImageButton)findViewById(R.id.backButton);
    61.                         backButton.setBackgroundColor(0);
    62.                         backButton.setOnClickListener(new View.OnClickListener() {
    63.                             public void onClick(View v) {
    64.                                 startActivity(new Intent(SplatActivity.this, SplatActivity.class));
    65.                                 SplatActivity.this.finish();
    66.                             }
    67.                         });
    68.                         break;
    69.                     case 2: //High Scores
    70.                         HighScores highScore = new HighScores(SplatActivity.this);
    71.                         Toast.makeText(SplatActivity.this, "High Scores", Toast.LENGTH_SHORT).show();
    72.                         break;
    73.                     case 3: //Quit
    74.                         Toast.makeText(SplatActivity.this, "Quit", Toast.LENGTH_SHORT).show();
    75.                         SplatActivity.this.finish();
    76.                         break;
    77.                 }
    78.               }
    79.         });  
    80.          
    81.  
    82.    
    83.     }  
    84. }
    85.  
    Play Class:
    Code (Text):
    1.  
    2. package com.mst.Splat;
    3.  
    4. import java.io.IOException;
    5. import java.util.ArrayList;
    6.  
    7. import org.xmlpull.v1.XmlPullParser;
    8. import org.xmlpull.v1.XmlPullParserException;
    9.  
    10. import android.app.Activity;
    11. import android.content.Context;
    12. import android.content.Intent;
    13. import android.content.pm.ActivityInfo;
    14. import android.content.res.Resources;
    15. import android.content.res.XmlResourceParser;
    16. import android.graphics.Bitmap;
    17. import android.graphics.BitmapFactory;
    18. import android.graphics.Color;
    19. import android.os.Bundle;
    20. import android.util.AttributeSet;
    21. import android.view.Display;
    22. import android.view.SurfaceHolder;
    23. import android.view.View;
    24. import android.view.Window;
    25. import android.view.WindowManager;
    26. import android.view.View.OnClickListener;
    27. import android.widget.ImageButton;
    28. import android.widget.Toast;
    29.  
    30. public class Play extends Activity
    31. {
    32.    
    33.     private Context layout;
    34.     private Character character;
    35.     private ImageButton blueButton, redButton, yellowButton;
    36.     private int paintColor;
    37.     public static ArrayList<Tile> tiles = new ArrayList<Tile>();
    38.    
    39.     public static Play play;
    40.     public static Display display;
    41.     public static int width;
    42.     public static int height;
    43.    
    44.     public void onCreate(Bundle savedInstanceState)
    45.     {
    46.         super.onCreate(savedInstanceState);
    47.        
    48.         startActivity(new Intent(Play.this, GameTemplate.class));
    49.            }
    50.  
    51. }
    52.  
    and the GameTemplate Class:
    Code (Text):
    1.  
    2. package com.mst.Splat;
    3. import android.app.Activity;
    4. import android.os.Bundle;
    5. import android.util.Log;
    6. import android.view.Menu;
    7. import android.view.MenuItem;
    8. import android.view.Window;
    9.  
    10. import com.mst.Splat.PlayView.GameThread;
    11.  
    12. public class GameTemplate extends Activity {
    13.     private static final int MENU_PAUSE = Menu.FIRST;
    14.  
    15.     private static final int MENU_RESUME = Menu.FIRST + 1;
    16.  
    17.     private static final int MENU_START = Menu.FIRST + 2;
    18.  
    19.     private static final int MENU_STOP = Menu.FIRST + 3;
    20.  
    21.     /** A handle to the thread that's actually running the animation. */
    22.     private GameThread mGameThread;
    23.  
    24.     /** A handle to the View in which the game is running. */
    25.     private PlayView mGameView;
    26.  
    27.     /**
    28.      * Invoked during init to give the Activity a chance to set up its Menu.
    29.      *
    30.      * @param menu the Menu to which entries may be added
    31.      * @return true
    32.      */
    33.     @Override
    34.     public boolean onCreateOptionsMenu(Menu menu) {
    35.         super.onCreateOptionsMenu(menu);
    36.  
    37.         menu.add(0, MENU_START, 0, R.string.menu_start);
    38.         menu.add(0, MENU_STOP, 0, R.string.menu_stop);
    39.         menu.add(0, MENU_PAUSE, 0, R.string.menu_pause);
    40.         menu.add(0, MENU_RESUME, 0, R.string.menu_resume);
    41.  
    42.         return true;
    43.     }
    44.  
    45.     /**
    46.      * Invoked when the user selects an item from the Menu.
    47.      *
    48.      * @param item the Menu entry which was selected
    49.      * @return true if the Menu item was legit (and we consumed it), false
    50.      *         otherwise
    51.      */
    52.     @Override
    53.     public boolean onOptionsItemSelected(MenuItem item) {
    54.         switch (item.getItemId()) {
    55.             case MENU_START:
    56.                 mGameThread.doStart();
    57.                 return true;
    58.             case MENU_STOP:
    59.                 mGameThread.setState(GameThread.STATE_LOSE);
    60.                 return true;
    61.             case MENU_PAUSE:
    62.                 mGameThread.pause();
    63.                 return true;
    64.             case MENU_RESUME:
    65.                 mGameThread.unpause();
    66.                 return true;
    67.         }
    68.  
    69.         return false;
    70.     }
    71.  
    72.     /**
    73.      * Invoked when the Activity is created.
    74.      *
    75.      * @param savedInstanceState a Bundle containing state saved from a previous
    76.      *        execution, or null if this is a new execution
    77.      */
    78.     @Override
    79.     protected void onCreate(Bundle savedInstanceState) {
    80.         //super.onCreate(savedInstanceState);
    81. //
    82. //        // turn off the window's title bar
    83. //        requestWindowFeature(Window.FEATURE_NO_TITLE);
    84. //
    85. //        // tell system to use the layout defined in our XML file
    86. //        setContentView(R.layout.main);
    87. //
    88. //        // get handles to the LunarView from XML, and its LunarThread
    89. //        mGameView = (PlayView) findViewById(R.id.game);
    90. //        mGameThread = mGameView.getThread();
    91. //
    92. //        // set up a new game
    93. //        mGameThread.setState(GameThread.STATE_READY);
    94. //        Log.w(this.getClass().getName(), "SIS is null");
    95.     }
    96.  
    97.     /**
    98.      * Invoked when the Activity loses user focus.
    99.      */
    100.     @Override
    101.     protected void onPause() {
    102.         super.onPause();
    103.         mGameView.getThread().pause(); // pause game when Activity pauses
    104.     }
    105. }
    106.  

    And to be honest, I have absolutely no clue what any of the logcat stuff means, so I'm just going to copy and paste all of that in as well. I've never used it before.

    Code (Text):
    1.  
    2. 08-19 19:17:05.149: DEBUG/AndroidRuntime(654): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
    3. 08-19 19:17:05.169: DEBUG/AndroidRuntime(654): CheckJNI is ON
    4. 08-19 19:17:06.269: DEBUG/AndroidRuntime(654): --- registering native functions ---
    5. 08-19 19:17:10.929: DEBUG/AndroidRuntime(654): Shutting down VM
    6. 08-19 19:17:10.948: DEBUG/dalvikvm(654): DestroyJavaVM waiting for non-daemon threads to exit
    7. 08-19 19:17:10.958: DEBUG/dalvikvm(654): DestroyJavaVM shutting VM down
    8. 08-19 19:17:10.958: DEBUG/dalvikvm(654): HeapWorker thread shutting down
    9. 08-19 19:17:10.970: ERROR/AndroidRuntime(654): ERROR: thread attach failed
    10. 08-19 19:17:10.989: DEBUG/dalvikvm(654): HeapWorker thread has shut down
    11. 08-19 19:17:10.989: DEBUG/jdwp(654): JDWP shutting down net...
    12. 08-19 19:17:10.989: INFO/dalvikvm(654): Debugger has detached; object registry had 1 entries
    13. 08-19 19:17:11.028: DEBUG/dalvikvm(654): VM cleaning up
    14. 08-19 19:17:11.210: DEBUG/dalvikvm(654): LinearAlloc 0x0 used 627556 of 5242880 (11%)
    15. 08-19 19:17:13.530: DEBUG/AndroidRuntime(662): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
    16. 08-19 19:17:13.549: DEBUG/AndroidRuntime(662): CheckJNI is ON
    17. 08-19 19:17:15.628: DEBUG/AndroidRuntime(662): --- registering native functions ---
    18. 08-19 19:17:16.369: INFO/ActivityManager(61): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/.Launcher }
    19. 08-19 19:17:20.000: WARN/InputManagerService(61): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@43d9e648 (uid=10026 pid=645)
    20. 08-19 19:17:26.249: INFO/ActivityManager(61): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.mst.Splat/.SplatActivity }
    21. 08-19 19:17:26.519: DEBUG/AndroidRuntime(662): Shutting down VM
    22. 08-19 19:17:26.530: DEBUG/dalvikvm(662): DestroyJavaVM waiting for non-daemon threads to exit
    23. 08-19 19:17:26.538: DEBUG/dalvikvm(662): DestroyJavaVM shutting VM down
    24. 08-19 19:17:26.569: ERROR/AndroidRuntime(662): ERROR: thread attach failed
    25. 08-19 19:17:26.620: DEBUG/dalvikvm(662): HeapWorker thread shutting down
    26. 08-19 19:17:26.629: DEBUG/dalvikvm(662): HeapWorker thread has shut down
    27. 08-19 19:17:26.639: DEBUG/jdwp(662): JDWP shutting down net...
    28. 08-19 19:17:26.649: INFO/dalvikvm(662): Debugger has detached; object registry had 1 entries
    29. 08-19 19:17:26.710: DEBUG/dalvikvm(662): VM cleaning up
    30. 08-19 19:17:27.468: DEBUG/dalvikvm(662): LinearAlloc 0x0 used 637524 of 5242880 (12%)
    31. 08-19 19:17:30.679: DEBUG/dalvikvm(248): GC freed 165 objects / 6608 bytes in 5168ms
    32. 08-19 19:17:35.260: DEBUG/dalvikvm(128): GC freed 2427 objects / 139560 bytes in 655ms
    33. 08-19 19:17:37.459: INFO/NotificationService(61): enqueueToast pkg=com.mst.Splat callback=android.app.ITransientNotification$Stub$Proxy@43ce7850 duration=0
    34. 08-19 19:17:37.648: INFO/ActivityManager(61): Starting activity: Intent { cmp=com.mst.Splat/.Play }
    35. 08-19 19:17:38.579: INFO/ActivityManager(61): Starting activity: Intent { cmp=com.mst.Splat/.GameTemplate }
    36. 08-19 19:17:38.680: DEBUG/AndroidRuntime(645): Shutting down VM
    37. 08-19 19:17:38.720: WARN/dalvikvm(645): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
    38. 08-19 19:17:38.769: ERROR/AndroidRuntime(645): Uncaught handler: thread main exiting due to uncaught exception
    39. 08-19 19:17:38.948: ERROR/AndroidRuntime(645): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mst.Splat/com.mst.Splat.Play}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.mst.Splat/com.mst.Splat.GameTemplate}; have you declared this activity in your AndroidManifest.xml?
    40. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
    41. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
    42. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
    43. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
    44. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.os.Handler.dispatchMessage(Handler.java:99)
    45. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.os.Looper.loop(Looper.java:123)
    46. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.ActivityThread.main(ActivityThread.java:4363)
    47. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at java.lang.reflect.Method.invokeNative(Native Method)
    48. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at java.lang.reflect.Method.invoke(Method.java:521)
    49. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    50. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    51. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at dalvik.system.NativeStart.main(Native Method)
    52. 08-19 19:17:38.948: ERROR/AndroidRuntime(645): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.mst.Splat/com.mst.Splat.GameTemplate}; have you declared this activity in your AndroidManifest.xml?
    53. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
    54. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
    55. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.Activity.startActivityForResult(Activity.java:2749)
    56. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.Activity.startActivity(Activity.java:2855)
    57. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at com.mst.Splat.Play.onCreate(Play.java:47)
    58. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    59. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
    60. 08-19 19:17:38.948: ERROR/AndroidRuntime(645):     ... 11 more
    61. 08-19 19:17:39.079: INFO/Process(61): Sending signal. PID: 645 SIG: 3
    62. 08-19 19:17:39.099: INFO/dalvikvm(645): threadid=7: reacting to signal 3
    63. 08-19 19:17:39.469: INFO/dalvikvm(645): Wrote stack trace to '/data/anr/traces.txt'
    64. 08-19 19:17:42.720: INFO/Process(645): Sending signal. PID: 645 SIG: 9
    65. 08-19 19:17:43.280: INFO/ActivityManager(61): Process com.mst.Splat (pid 645) has died.
    66. 08-19 19:17:43.390: INFO/WindowManager(61): WIN DEATH: Window{43da07d8 com.mst.Splat/com.mst.Splat.SplatActivity paused=false}
    67. 08-19 19:17:43.489: INFO/WindowManager(61): WIN DEATH: Window{43da55d8 Toast paused=false}
    68. 08-19 19:17:44.210: INFO/ActivityManager(61): Start proc com.mst.Splat for activity com.mst.Splat/.SplatActivity: pid=670 uid=10026 gids={}
    69. 08-19 19:17:46.259: DEBUG/ddm-heap(670): Got feature list request
    70. 08-19 19:17:46.810: INFO/UsageStats(61): Unexpected resume of com.mst.Splat while already resumed in com.mst.Splat
    71. 08-19 19:17:47.919: WARN/ActivityManager(61): Launch timeout has expired, giving up wake lock!
    72. 08-19 19:17:50.740: DEBUG/dalvikvm(670): GC freed 548 objects / 48176 bytes in 1235ms
    73. 08-19 19:17:56.740: WARN/InputManagerService(61): Got RemoteException sending setActive(false) notification to pid 645 uid 10026
    74. 08-19 19:17:56.849: WARN/ActivityManager(61): Activity idle timeout for HistoryRecord{43cbb118 com.mst.Splat/.SplatActivity}
    75. 08-19 19:17:58.460: INFO/ActivityManager(61): Displayed activity com.mst.Splat/.SplatActivity: 14515 ms (total 20284 ms)
    76.  
    Anyways, sorry for throwing so much code at you, lol, but I'm pretty new at this and don't know which code will help you help me and which code is just garbage atm, so I'm just giving you all of it in hopes that you can sort through it, seeing as you know what you're doing. :p

    If you're actually going to go through all of that and try to help me figure out what the problem is, I'll be extremely grateful. XD
     
  4. blundell

    blundell Well-Known Member

    Joined:
    Apr 23, 2010
    Messages:
    125
    Likes Received:
    17
    Definetly read up on Java console output and Logcat as this is how you find out where your errors are.

    Here is your error:
    Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.mst.Splat/com.mst.Splat.GameTemplate}; have you declared this activity in your AndroidManifest.xml?

    And it actual tells you what to do to fix it, et voila
     
  5. cmh0114

    cmh0114 Well-Known Member This Topic's Starter

    Joined:
    Jan 10, 2010
    Messages:
    116
    Likes Received:
    7
    Ok, so I tried that, and it still won't run. It ends at the same place. Here's the logcat:

    Code (Text):
    1.  
    2. 08-19 19:57:51.155: DEBUG/AndroidRuntime(218): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
    3. 08-19 19:57:51.174: DEBUG/AndroidRuntime(218): CheckJNI is ON
    4. 08-19 19:57:52.365: DEBUG/AndroidRuntime(218): --- registering native functions ---
    5. 08-19 19:57:57.594: DEBUG/PackageParser(62): Scanning package: /data/app/vmdl29185.tmp
    6. 08-19 19:57:59.245: INFO/PackageManager(62): Removing non-system package:com.mst.Splat
    7. 08-19 19:57:59.264: DEBUG/PackageManager(62): Removing package com.mst.Splat
    8. 08-19 19:57:59.284: DEBUG/PackageManager(62):   Activities: com.mst.Splat.SplatActivity com.mst.Splat.Play com.mst.Splat.GameTemplate
    9. 08-19 19:57:59.624: DEBUG/PackageManager(62): Scanning package com.mst.Splat
    10. 08-19 19:57:59.645: INFO/PackageManager(62): /data/app/vmdl29185.tmp changed; unpacking
    11. 08-19 19:57:59.764: DEBUG/installd(32): DexInv: --- BEGIN '/data/app/vmdl29185.tmp' ---
    12. 08-19 19:58:01.694: DEBUG/dalvikvm(224): DexOpt: load 281ms, verify 516ms, opt 12ms
    13. 08-19 19:58:01.795: DEBUG/installd(32): DexInv: --- END '/data/app/vmdl29185.tmp' (success) ---
    14. 08-19 19:58:01.824: DEBUG/ActivityManager(62): Uninstalling process com.mst.Splat
    15. 08-19 19:58:01.844: DEBUG/PackageManager(62):   Activities: com.mst.Splat.SplatActivity com.mst.Splat.Play com.mst.Splat.GameTemplate
    16. 08-19 19:58:02.216: INFO/installd(32): move /data/dalvik-cache/data@app@vmdl29185.tmp@classes.dex -> /data/dalvik-cache/data@app@com.mst.Splat.apk@classes.dex
    17. 08-19 19:58:02.244: DEBUG/PackageManager(62): New package installed in /data/app/com.mst.Splat.apk
    18. 08-19 19:58:02.684: DEBUG/AndroidRuntime(218): Shutting down VM
    19. 08-19 19:58:02.704: DEBUG/dalvikvm(218): DestroyJavaVM waiting for non-daemon threads to exit
    20. 08-19 19:58:02.745: ERROR/AndroidRuntime(218): ERROR: thread attach failed
    21. 08-19 19:58:02.754: DEBUG/dalvikvm(218): DestroyJavaVM shutting VM down
    22. 08-19 19:58:02.814: DEBUG/dalvikvm(218): HeapWorker thread shutting down
    23. 08-19 19:58:02.845: DEBUG/dalvikvm(218): HeapWorker thread has shut down
    24. 08-19 19:58:02.845: DEBUG/jdwp(218): JDWP shutting down net...
    25. 08-19 19:58:02.865: INFO/dalvikvm(218): Debugger has detached; object registry had 1 entries
    26. 08-19 19:58:02.904: DEBUG/dalvikvm(218): VM cleaning up
    27. 08-19 19:58:03.215: DEBUG/ActivityManager(62): Uninstalling process com.mst.Splat
    28. 08-19 19:58:03.244: DEBUG/dalvikvm(218): LinearAlloc 0x0 used 621940 of 5242880 (11%)
    29. 08-19 19:58:03.835: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f0700e5
    30. 08-19 19:58:03.874: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f020031
    31. 08-19 19:58:03.874: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f020030
    32. 08-19 19:58:03.895: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f050000
    33. 08-19 19:58:04.125: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f060001
    34. 08-19 19:58:04.565: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f060000
    35. 08-19 19:58:05.005: INFO/ActivityManager(62): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=229 uid=10019 gids={}
    36. 08-19 19:58:05.784: DEBUG/dalvikvm(110): GC freed 1918 objects / 102064 bytes in 1827ms
    37. 08-19 19:58:07.405: DEBUG/dalvikvm(62): GC freed 14887 objects / 906360 bytes in 2367ms
    38. 08-19 19:58:07.425: DEBUG/ddm-heap(229): Got feature list request
    39. 08-19 19:58:10.384: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f0700e5
    40. 08-19 19:58:10.405: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f020031
    41. 08-19 19:58:10.415: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f020030
    42. 08-19 19:58:10.434: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f050000
    43. 08-19 19:58:10.785: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f060001
    44. 08-19 19:58:11.125: WARN/ResourceType(62): Resources don't contain package for resource number 0x7f060000
    45. 08-19 19:58:12.084: DEBUG/AndroidRuntime(233): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
    46. 08-19 19:58:12.125: DEBUG/AndroidRuntime(233): CheckJNI is ON
    47. 08-19 19:58:14.684: DEBUG/AndroidRuntime(233): --- registering native functions ---
    48. 08-19 19:58:20.154: INFO/ActivityManager(62): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.mst.Splat/.SplatActivity }
    49. 08-19 19:58:20.425: DEBUG/AndroidRuntime(233): Shutting down VM
    50. 08-19 19:58:20.435: DEBUG/dalvikvm(233): DestroyJavaVM waiting for non-daemon threads to exit
    51. 08-19 19:58:20.496: DEBUG/dalvikvm(233): DestroyJavaVM shutting VM down
    52. 08-19 19:58:20.505: DEBUG/dalvikvm(233): HeapWorker thread shutting down
    53. 08-19 19:58:20.525: DEBUG/dalvikvm(233): HeapWorker thread has shut down
    54. 08-19 19:58:20.525: DEBUG/jdwp(233): JDWP shutting down net...
    55. 08-19 19:58:20.564: INFO/dalvikvm(233): Debugger has detached; object registry had 1 entries
    56. 08-19 19:58:20.585: DEBUG/dalvikvm(233): VM cleaning up
    57. 08-19 19:58:20.595: ERROR/AndroidRuntime(233): ERROR: thread attach failed
    58. 08-19 19:58:21.285: DEBUG/dalvikvm(233): LinearAlloc 0x0 used 637524 of 5242880 (12%)
    59. 08-19 19:58:21.344: INFO/ActivityManager(62): Start proc com.mst.Splat for activity com.mst.Splat/.SplatActivity: pid=244 uid=10026 gids={}
    60. 08-19 19:58:22.504: DEBUG/ddm-heap(244): Got feature list request
    61. 08-19 19:58:23.174: INFO/ARMAssembler(62): generated scanline__00000177:03515104_00000001_00000000 [ 73 ipp] (95 ins) at [0x303cf8:0x303e74] in 3566095 ns
    62. 08-19 19:58:24.495: DEBUG/dalvikvm(244): GC freed 546 objects / 48088 bytes in 454ms
    63. 08-19 19:58:26.834: INFO/ActivityManager(62): Displayed activity com.mst.Splat/.SplatActivity: 6427 ms (total 6427 ms)
    64. 08-19 19:58:27.044: INFO/ARMAssembler(62): generated scanline__00000077:03545404_00000A04_00000000 [ 29 ipp] (51 ins) at [0x303e78:0x303f44] in 1562769 ns
    65. 08-19 19:58:31.704: INFO/NotificationService(62): enqueueToast pkg=com.mst.Splat callback=android.app.ITransientNotification$Stub$Proxy@43ccc540 duration=0
    66. 08-19 19:58:31.764: INFO/ActivityManager(62): Starting activity: Intent { cmp=com.mst.Splat/.Play }
    67. 08-19 19:58:32.274: INFO/ActivityManager(62): Starting activity: Intent { cmp=com.mst.Splat/.GameTemplate }
    68. 08-19 19:58:32.585: INFO/ARMAssembler(62): generated scanline__00000177:03515104_00001A01_00000000 [ 73 ipp] (98 ins) at [0x3bb590:0x3bb718] in 2394159 ns
    69. 08-19 19:58:33.065: DEBUG/AndroidRuntime(244): Shutting down VM
    70. 08-19 19:58:33.085: WARN/dalvikvm(244): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
    71. 08-19 19:58:33.114: ERROR/AndroidRuntime(244): Uncaught handler: thread main exiting due to uncaught exception
    72. 08-19 19:58:33.165: ERROR/AndroidRuntime(244): android.app.SuperNotCalledException: Activity {com.mst.Splat/com.mst.Splat.GameTemplate} did not call through to super.onCreate()
    73. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2461)
    74. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
    75. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
    76. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
    77. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.os.Handler.dispatchMessage(Handler.java:99)
    78. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.os.Looper.loop(Looper.java:123)
    79. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.app.ActivityThread.main(ActivityThread.java:4363)
    80. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at java.lang.reflect.Method.invokeNative(Native Method)
    81. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at java.lang.reflect.Method.invoke(Method.java:521)
    82. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    83. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    84. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at dalvik.system.NativeStart.main(Native Method)
    85. 08-19 19:58:33.234: INFO/Process(62): Sending signal. PID: 244 SIG: 3
    86. 08-19 19:58:33.244: INFO/dalvikvm(244): threadid=7: reacting to signal 3
    87. 08-19 19:58:33.344: INFO/dalvikvm(244): Wrote stack trace to '/data/anr/traces.txt'
    88. 08-19 19:58:41.834: WARN/ActivityManager(62): Launch timeout has expired, giving up wake lock!
    89. 08-19 19:58:42.014: WARN/ActivityManager(62): Activity idle timeout for HistoryRecord{43cc16b8 com.mst.Splat/.Play}
    90. 08-19 19:58:42.735: WARN/ActivityManager(62): Activity idle timeout for HistoryRecord{43ce73d8 com.mst.Splat/.GameTemplate}
    91. 08-19 19:58:48.244: DEBUG/dalvikvm(110): GC freed 2444 objects / 140264 bytes in 467ms
    92.  
    I think the problem is this, but I don't know how to fix it:
    Code (Text):
    1.  
    2. 08-19 19:58:02.745: ERROR/AndroidRuntime(218): ERROR: thread attach failed
    3. 08-19 19:58:20.595: ERROR/AndroidRuntime(233): ERROR: thread attach failed
    4. 08-19 19:58:33.114: ERROR/AndroidRuntime(244): Uncaught handler: thread main exiting due to uncaught exception
    5. 08-19 19:58:33.165: ERROR/AndroidRuntime(244): android.app.SuperNotCalledException: Activity {com.mst.Splat/com.mst.Splat.GameTemplate} did not call through to super.onCreate()
    6. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2461)
    7. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
    8. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
    9. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
    10. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.os.Handler.dispatchMessage(Handler.java:99)
    11. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.os.Looper.loop(Looper.java:123)
    12. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at android.app.ActivityThread.main(ActivityThread.java:4363)
    13. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at java.lang.reflect.Method.invokeNative(Native Method)
    14. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at java.lang.reflect.Method.invoke(Method.java:521)
    15. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    16. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    17. 08-19 19:58:33.165: ERROR/AndroidRuntime(244):     at dalvik.system.NativeStart.main(Native Method)
    18.  
     
  6. blundell

    blundell Well-Known Member

    Joined:
    Apr 23, 2010
    Messages:
    125
    Likes Received:
    17
    ERROR/AndroidRuntime(244): android.app.SuperNotCalledException: Activity {com.mst.Splat/com.mst.Splat.GameTemplate} did not call through to super.onCreate()

    Please don't use me as your code monkey. Just learn to read the logcat and google the error.

    Your Class GameTemplate does not call it's super on the onCreate method. It tells you!

    In eclipse press the big E button on the logcat window that will help you
     
  7. cmh0114

    cmh0114 Well-Known Member This Topic's Starter

    Joined:
    Jan 10, 2010
    Messages:
    116
    Likes Received:
    7
    I'm sorry, I really don't mean to use you as a "code monkey." I appreciate your helping me and trying to explain everything. I thought the problem was with the "Uncaught handler: thread main exiting due to uncaught exception," and I didn't know what that was. I'll make sure I look through everything before I post any more error logs.
     
  8. blundell

    blundell Well-Known Member

    Joined:
    Apr 23, 2010
    Messages:
    125
    Likes Received:
    17
    Always just scan an exception log until you see your package name in this case "com.mst." then read the lines around that, they are the important thing
     

Share This Page

Loading...