-1

My simple app was working fine when I suddenly started getting this error:

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bazapp.bazapp">

    <uses-permission android:name="android.permission.INTERNET" />

    <application>
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

MainActivity.java

package com.bazapp.bazapp;

import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        WebView webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl("http://www.google.com");
    }
}

What's gone wrong? I've searched SO but I can't find the solution in any of the answers.

EDIT

I've tried everything in the question that this one is accused of being a duplicate of, none of them work. The main answer suggests changing ActionBarActivity to Activity. I've done this, so I now have:

public class MainActivity extends Activity {

This gives me the error

cannot find symbol class Activity
Bazley
  • 2,699
  • 5
  • 36
  • 61
  • 1
    Possible duplicate of [You need to use a Theme.AppCompat theme (or descendant) with this activity](http://stackoverflow.com/questions/21814825/you-need-to-use-a-theme-appcompat-theme-or-descendant-with-this-activity) – Gavriel Jan 18 '16 at 00:29
  • I've looked at the answers in that question but none of them solved my problem. – Bazley Jan 18 '16 at 00:34

2 Answers2

0

All you need to do is to change the theme to android:theme="@style/Theme.AppCompat.Light" in your application tag in the AndroidManifest.xml file.

Gavriel
  • 18,880
  • 12
  • 68
  • 105
0

Your app theme has to inherit from Theme.AppCompat or its descendants.