2

This problem was not solved by the linked post. So please do not mark this one as a duplicate and ignore this post. Something else is causing the issue.

I've tried the method that was supposed to solve this problem through this post:Upgraded to AppCompat v22.1.0 and now getting IllegalArgumentException: AppCompat does not support the current theme features My problem wasn't solved and I'm not sure what else could be causing the problem

Here is my error code:

05-13 10:22:08.877: E/AndroidRuntime(21609): FATAL EXCEPTION: main
05-13 10:22:08.877: E/AndroidRuntime(21609): Process: com.commonsware.lorem, PID: 21609
05-13 10:22:08.877: E/AndroidRuntime(21609): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.commonsware.lorem/com.commonsware.lorem.Lorem}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.app.ActivityThread.access$800(ActivityThread.java:139)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.os.Handler.dispatchMessage(Handler.java:102)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.os.Looper.loop(Looper.java:136)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.app.ActivityThread.main(ActivityThread.java:5097)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at java.lang.reflect.Method.invokeNative(Native Method)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at java.lang.reflect.Method.invoke(Method.java:515)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at dalvik.system.NativeStart.main(Native Method)
05-13 10:22:08.877: E/AndroidRuntime(21609): Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at com.commonsware.lorem.Lorem.onCreate(Lorem.java:35)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.app.Activity.performCreate(Activity.java:5248)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
05-13 10:22:08.877: E/AndroidRuntime(21609):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
05-13 10:22:08.877: E/AndroidRuntime(21609):    ... 11 more

Here is my styles.xml:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

    <style name="AppTheme.NoActionBar" parent="AppTheme">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

</resources>

Here is my AndroidManifest.xml:

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

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

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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".PostActivity"
            android:label="Post" >
            <intent-filter>
                <action android:name="getextras" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".LocationActivity"
            android:label="Location" />
        <activity
            android:name=".TopicActivity"
            android:label="Topic" />
        <activity
            android:name=".LoginActivity"
            android:label="Login" />
        <activity
            android:name=".RegisterActivity"
            android:label="@string/title_activity_register" >
        </activity>
    </application>


</manifest>

Here is my Lorem (MainActivity):

package com.commonsware.lorem;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.parse.Parse;
import com.parse.ParseObject;
import com.parse.ParseUser;


public class Lorem extends ActionBarActivity {

    //private static final String="POST";
    ListView listView;
    int[] pic_thumbnail_resource = {R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher,
            R.mipmap.ic_launcher, R.mipmap.ic_launcher,};
    String[] post_ratings;
    String[] post_titles;
    PostAdapter adapter;

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

        // Enable Local Datastore.
        Parse.enableLocalDatastore(this);
        Parse.initialize(this, "wHN7DSZyAzVXT5xs5ASDFOBwOWasUExbeuePvQvL", "SsLuJ7e97FsRTCcI12XI7dlv8RilgSoFSw5waIOXM");
        //ParseObject testObject = new ParseObject("TestObject");
        //testObject.put("foo", "bar");
        //testObject.saveInBackground();

        ParseUser currentUser = ParseUser.getCurrentUser();
        if (currentUser != null) {
            // do stuff with the user


        } else {
            // show the signup or login screen
            Intent takeUsertoLogin = new Intent(this, LoginActivity.class);
            startActivity(takeUsertoLogin);
        }

        // End Parse

        listView = (ListView)findViewById(R.id.list_view);
        post_ratings = getResources().getStringArray(R.array.post_ratings);
        post_titles = getResources().getStringArray(R.array.post_titles);

        //populateListView();
        registerClickCallback();

        int i = 0;
        adapter = new PostAdapter(getApplicationContext(),R.layout.row_layout);
        listView.setAdapter(adapter);

        for(String titles: post_titles)
        {
            PostDataProvider dataProvider = new PostDataProvider(pic_thumbnail_resource[i], titles, post_ratings[i]);
            adapter.add(dataProvider);
            i++;
        }
    }


    private void registerClickCallback(){
        ListView list = (ListView) findViewById(R.id.list_view);
        list.setOnItemClickListener(new AdapterView.OnItemClickListener(){
            @Override
            public void onItemClick(AdapterView<?> parent, View viewClicked, int position, long id){
                TextView textView = (TextView) viewClicked;
                String message = "You clicked # " + position + ",which is string: " + textView.getText().toString();
                Toast.makeText(Lorem.this, message, Toast.LENGTH_LONG).show();
            }
        });
    }

/*
    @Override
    public void onActivityResult(String requestCode, String resultCode, Intent data){

        if (requestCode == "POST")
        {
            myItems.add
        }

        super.onActivityResult(requestCode, resultCode, data);
    }
*/

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_lorem, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        super.onOptionsItemSelected(item);
        switch (item.getItemId()){
            case R.id.post:
                aboutItemPost();
                break;
            case R.id.location:
                aboutItemLocation();
                break;
            case R.id.topic:
                aboutItemTopic();
                break;
            case R.id.sort:
                aboutItemSort();
                break;
            case R.id.login:
                aboutItemLogin();
            case R.id.Register:
                aboutItemRegister();
            case R.id.Logout:
                aboutItemLogout();
        }
        return true;
    }

    private void aboutItemPost(){
        Intent intent = new Intent(getApplicationContext(), PostActivity.class);
        startActivityForResult(intent, 0);
    }

    private void aboutItemLocation(){
        Intent intent = new Intent(getApplicationContext(), LocationActivity.class);
        startActivityForResult(intent, 0);
    }

    private void aboutItemTopic(){
        Intent intent = new Intent(getApplicationContext(), TopicActivity.class);
        startActivityForResult(intent, 0);

    }

    private void aboutItemSort(){
        new AlertDialog.Builder(this)
                .setTitle("Sort")
                .setMessage("This is where the user will sort what they want to see")
                .setNeutralButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                }).show();

    }

    private void aboutItemLogin(){
        Intent takeUsertoLogin = new Intent(this, LoginActivity.class);
        startActivity(takeUsertoLogin);
    }

    private void aboutItemRegister(){
        Intent intent = new Intent(getApplicationContext(), RegisterActivity.class);
        startActivityForResult(intent, 0);
    }

    private void aboutItemLogout() {
        // log the user out
        ParseUser.logOut();

        // take the user back to log in screen
        Intent takeUsertoLogin = new Intent(this, LoginActivity.class);
        startActivity(takeUsertoLogin);

    }

}

As you can see the method I tried did not solve the error code so something else is causing the error here, hopefully someone smart can figure out what is causing the issue.

If you need any more code feel free to ask.

Thank you for your time.

Community
  • 1
  • 1
gunR
  • 45
  • 1
  • 6
  • 2
    Please post your manifest and the source to the `Lorem` activity. – CommonsWare May 13 '15 at 16:37
  • the actual mistake is in your manifest. Post it soon. – Krupal Shah May 13 '15 at 16:42
  • @CommonsWare Ok, I added it. I have found your book to be incredibly helpful by the way. – gunR May 13 '15 at 16:43
  • OK, this isn't making much sense. Since you presently aren't doing anything with the custom themes, switch your `android:theme` to be `@style/Theme.AppCompat.Light.DarkActionBar` instead of `@style/AppTheme`, and see what happens. BTW, thanks for the kind words! Though, if you could move your app out of the `com.commonsware` package sometime, that'd be cool. I mean, you seem like a nice person and all, but I don't recall hiring you... :-) – CommonsWare May 13 '15 at 17:34
  • Ah, yeah to be honest I'm not actually sure how com.commonsware showed as the package up haha. I'll be sure to move it once I get the app operating again. So I added @style/Theme.AppCompat.Light.DarkActionBar in place of AppTheme in the AndroidManifest.xml but the same error still remains. – gunR May 13 '15 at 17:44

2 Answers2

0

This is an issue for Support Library 22.1

parent theme must be Theme.AppCompat.NoActionBar:

change from:

 <style name="AppTheme.NoActionBar" parent="AppTheme">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

to:

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
</style>
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
0

You have this issue because your Activity is using the AppTheme theme (check your Manifest).

Change your style files removing the parent="AppTheme".

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Then change in your Manifest the default style:

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">

Otherwise you can change your style in this way:

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

In any case, your Activity has to use the AppTheme.NoActionBar style changing your Manifest.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • hmm, I still get the same error :(. I copy and pasted in this code just to make sure there could be no confusion with entering it in. The problem may not be with the new update, I've tried pretty much every way to input the changes to fix the new update but the error hasn't changed, is there any possible way something else is the problem here? – gunR May 14 '15 at 00:21