OpenCV and Android Studio: "unfortunately app has stopped"
<p>I've trying to access the android camera by using OpenCV. I had success in creating a project and it run without any problem.
I tried to use a code from the internet and check it in my project. But, the app stoped. It's seems to be a RuntimeException problem but i don't know how to solve it.
That's my code, that i copied from this website <a href="http://people.oregonstate.edu/~robinsti/CS_496/Tutorial/" rel="nofollow">http://people.oregonstate.edu/~robinsti/CS_496/Tutorial/</a>: </p>

<p>mainActivity.java</p>

<pre><code>public class MainActivity extends AppCompatActivity implements View.OnTouchListener, CameraBridgeViewBase.CvCameraViewListener2{

private CameraBridgeViewBase mOpenCvCameraView;
private Mat mRgba;

@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
    super.onCreate(savedInstanceState, persistentState);
    setContentView(R.layout.activity_main);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.Surface);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    //mOpenCvCameraView.setMaxFrameSize(176, 152);
    mOpenCvCameraView.setCvCameraViewListener(this);
}

private BaseLoaderCallback mLoaderCallBack = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        super.onManagerConnected(status);
        switch (status) {
            case LoaderCallbackInterface.SUCCESS: {
                mOpenCvCameraView.enableView();
                mOpenCvCameraView.setOnTouchListener(MainActivity.this);
            } break;
            default: {
                super.onManagerConnected(status);
            } break;
        }
    }
};

@Override
public void onPause() {
    super.onPause();
    if(mOpenCvCameraView != null) {
        mOpenCvCameraView.disableView();
    }
}

@Override
public void onResume() {
    super.onResume();
    if(mOpenCvCameraView != null) {
        mOpenCvCameraView.disableView();
    }

}


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

    if(!OpenCVLoader.initDebug()) {
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0,this, mLoaderCallBack);
    }
    else {
        mLoaderCallBack.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}

@Override
public void onCameraViewStarted(int width, int height) {

}

@Override
public void onCameraViewStopped() {

}

@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    mRgba = inputFrame.rgba();
    return mRgba;
}

@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    return false;
}
</code></pre>

<p>}</p>

<p>activity_main.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
tools:context="com.tech.te.smartrotate.MainActivity"&gt;

&lt;org.opencv.android.JavaCameraView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/Surface" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>AndroidManifest.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="                 "&gt;
&lt;uses-permission android:name="android.permission.CAMERA"/&gt;
&lt;uses-feature android:name="android.hardware.camera.autofocus"/&gt;
&lt;uses-feature android:name="android.hardware.camera.front"/&gt;
&lt;uses-feature android:name="android.hardware.camera.front.autofocus"/&gt;

&lt;application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"&gt;        &lt;!--android:theme="@style/AppTheme"&gt;--&gt;
    &lt;activity android:name=".MainActivity"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
&lt;/application&gt;
</code></pre>

<p></p>

<p>Logcat:</p>

<pre>07-29 15:54:44.066 31188-31188/com.tech.te.app W/art: Failed to find OatDexFile for DexFile /data/data/com.tech.te.app/files/instant-run/dex/slice-slice_2-classes.dex ( canonical path /data/data/com.tech.te.app/files/instant-run/dex/slice-slice_2-classes.dex) with checksum 0x7f90e189 in OatFile /data/data/com.tech.te.app/cache/slice-slice_2-classes.dex
07-29 15:54:45.836 31188-31195/com.tech.te.app W/art: Suspending all threads took: 19.602ms
07-29 15:54:45.946 31188-31188/com.tech.te.app D/DisplayManager: DisplayManager()
07-29 15:54:46.376 31188-31188/com.tech.te.app W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
07-29 15:54:46.596 31188-31188/com.tech.te.app E/VdcInflateDelegate: Exception while inflating 
                                                                             java.lang.RuntimeException: Failed to resolve attribute at index 1
                                                                                 at android.content.res.TypedArray.twGetColorStateList(TypedArray.java:437)
                                                                                 at android.content.res.TypedArray.getColorStateList(TypedArray.java:419)
                                                                                 at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:518)
                                                                                 at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:472)
                                                                                 at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:436)
                                                                                 at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:708)
                                                                                 at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:348)
                                                                                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
                                                                                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
                                                                                 at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689)
                                                                                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
                                                                                 at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
                                                                                 at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:83)
                                                                                 at android.support.v7.app.AppCompatDelegateImplV7.(AppCompatDelegateImplV7.java:146)
                                                                                 at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:28)
                                                                                 at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:41)
                                                                                 at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193)
                                                                                 at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)
                                                                                 at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)
                                                                                 at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
                                                                                 at android.app.Activity.performCreate(Activity.java:6112)
                                                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1117)
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609)
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721)
                                                                                 at android.app.ActivityThread.access$900(ActivityThread.java:168)
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                 at android.os.Looper.loop(Looper.java:135)
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5753)
                                                                                 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:1405)
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
07-29 15:54:46.596 31188-31202/com.tech.te.app I/art: Background sticky concurrent mark sweep GC freed 6652(1091KB) AllocSpace objects, 1(20KB) LOS objects, 14% free, 5MB/6MB, paused 36.125ms total 277.107ms
07-29 15:54:46.616 31188-31202/com.tech.te.app I/art: Background sticky concurrent mark sweep GC freed 274(43KB) AllocSpace objects, 0(0B) LOS objects, 14% free, 5MB/6MB, paused 7.366ms total 16.707ms
07-29 15:54:46.706 31188-31188/com.tech.te.app D/AndroidRuntime: Shutting down VM
07-29 15:54:46.716 31188-31188/com.tech.te.app E/AndroidRuntime: FATAL EXCEPTION: main
                                                                         Process: com.tech.te.app, PID: 31188
                                                                         java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tech.te.app/com.tech.te.app.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2656)
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721)
                                                                             at android.app.ActivityThread.access$900(ActivityThread.java:168)
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                             at android.os.Looper.loop(Looper.java:135)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5753)
                                                                             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:1405)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
                                                                          Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                                                                             at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:343)
                                                                             at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:312)
                                                                             at android.support.v7.app.AppCompatDelegateImplV7.onPostCreate(AppCompatDelegateImplV7.java:167)
                                                                             at android.support.v7.app.AppCompatActivity.onPostCreate(AppCompatActivity.java:98)
                                                                             at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1198)
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2638)
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721) 
                                                                             at android.app.ActivityThread.access$900(ActivityThread.java:168) 
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) 
                                                                             at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                             at android.os.Looper.loop(Looper.java:135) 
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5753) 
                                                                             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:1405) 
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200) 
07-29 15:54:50.366 31188-31188/com.tech.te.app I/Process: Sending signal. PID: 31188 SIG: 9
</pre>

<p>Thanks a lot.</p>