0

My app was working just fine. I updated Android Studio. Then I built my app again for testing and now it immediately crashes! It's like Android Studio moved around resources. I'm not sure what is causing this error. I went through the trouble of building the app from scratch AGAIN, copying and pasting the code, and I get the same error. Help from the community would be appreciated.

07-03 12:02:25.134    6167-6167/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.mystuff.test, PID: 6167
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mystuff.test/com.mystuff.test.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class com.mystuff.test.BattleView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
        at android.app.ActivityThread.access$900(ActivityThread.java:177)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:145)
        at android.app.ActivityThread.main(ActivityThread.java:5942)
        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:1399)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
 Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.mystuff.test.BattleView
        at android.view.LayoutInflater.createView(LayoutInflater.java:640)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:435)
        at android.app.Activity.setContentView(Activity.java:2267)
        at com.mystuff.test.MainActivity.onCreate(MainActivity.java:41)
        at android.app.Activity.performCreate(Activity.java:6289)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
        at android.app.ActivityThread.access$900(ActivityThread.java:177)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:145)
        at android.app.ActivityThread.main(ActivityThread.java:5942)
        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:1399)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
 Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
        at android.view.LayoutInflater.createView(LayoutInflater.java:614)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:435)
        at android.app.Activity.setContentView(Activity.java:2267)
        at com.mystuff.test.MainActivity.onCreate(MainActivity.java:41)
        at android.app.Activity.performCreate(Activity.java:6289)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
        at android.app.ActivityThread.access$900(ActivityThread.java:177)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:145)
        at android.app.ActivityThread.main(ActivityThread.java:5942)
        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:1399)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
 Caused by: java.lang.VerifyError: com.mystuff.test.BattleView$BattleThread
        at com.mystuff.test.BattleView.<init>(BattleView.java:1312)
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
        at android.view.LayoutInflater.createView(LayoutInflater.java:614)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:435)
        at android.app.Activity.setContentView(Activity.java:2267)
        at com.mystuff.test.MainActivity.onCreate(MainActivity.java:41)
        at android.app.Activity.performCreate(Activity.java:6289)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
        at android.app.ActivityThread.access$900(ActivityThread.java:177)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:145)
        at android.app.ActivityThread.main(ActivityThread.java:5942)
        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:1399)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Here's the XML file being referenced:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<com.mystuff.test.BattleView
    android:id="@+id/pea"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

</LinearLayout>

Here's the referenced constructor for the view and the thread:

//constructor gets the surface holder, assigns a callback and creates an instance of the thread
public BattleView (Context context, AttributeSet attrs) {
    super(context, attrs);
    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
    thread = new BattleThread(holder, context, new Handler() {
        @Override
        public void handleMessage(Message m) {
        }
    });
    setFocusable(true);
}
//method to return the thread in case you need to control it from the activity
public BattleThread getThread() {
    return thread;
}

class BattleThread extends Thread {
    public BattleThread(SurfaceHolder surfaceHolder, Context context, Handler handler) {
        mySurfaceHolder = surfaceHolder;
        myContext = context;
        backgroundImg = BitmapFactory.decodeResource(context.getResources(), R.drawable.nopeastitlecrackedstart);
        backgroundOrigW = backgroundImg.getWidth();
        backgroundOrigH = backgroundImg.getHeight();
    }

//the rest of the thread.  Code I haven't changed before it broke.
}
Adam
  • 1
  • 1

1 Answers1

0

Thanks to everyone who took the time to read through the code and give me some advice. After much trial and error, it turned out that my canvas draw method inside the Battle Thread had become too large and was not compiling correctly. It wasn't over the method limit size so I have no idea why it was rejecting it, but through a process of elimination, that turned out to be the solution. It was frustrating that I didn't get that specific error in any of the logs and had to go find it myself.

Adam
  • 1
  • 1