IllegalStateException when launching application after moved between computers

tl;dr

These exact files work on one workstation, and not another one.

What I get (error)

FATAL EXCEPTION: main                                                  

  java.lang.RuntimeException: Unable to start activity 
  ComponentInfo{com.example.erik.recipefriend2/com.example.erik.recipefriend2.MainActivity}: 
  java.lang.IllegalStateException: You need to use a 
  Theme.AppCompat theme (or descendant) with this activity.

The error is at line 26, which in my case is this:

setSupportActionBar(toolbar);

What I have done As the topic states, I have been moving my Android Studio project from my stationary computer onto my laptop. I have been using Git with Bitbucket to be able to work on both computers. When I pulled the project and tried to run it, I got the error message displayed above. When I zipped the project from my stationary computer and unpacked it and launched it on my laptop, I got the same error. Lastly, I pasted the indivudial files (class files, drawables and xml-files) into a newly created project, but I still get the error.

I am running out of ideas. I have also line for line checked the classes on my stationary computer and compared them to the lines on my laptop, to no avail.

I will include the classes and xmls that I think are involved in this matter.

styles.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:actionOverflowButtonStyle">@style/OverFlow</item>
</style>

<style name="ThemeOverlay.RecipesApp" parent="Theme.AppCompat.NoActionBar">
    <item name="android:colorBackground">@color/colorGreen</item>
    <item name="android:textColor">#FFFFFF</item>
</style>

<style name="OverFlow" parent="Widget.AppCompat.ActionButton.Overflow">
    <item name="android:src">@drawable/ic_menu_white_24dp</item>


</style>


</resources>

AndroidManifest.xml

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

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

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

</manifest>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout     xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.erik.recipefriend2.MainActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/ThemeOverlay.RecipesApp" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/addIngredient"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|right"
    android:layout_margin="16dp"
    app:backgroundTint="#91FF93"
    android:tint="#FFFFFF"
    android:onClick="goToAdd"
    android:scaleType="fitCenter"
    android:src="@android:drawable/ic_input_add" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/searchRecipe"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:backgroundTint="#91FF93"
    android:src="@android:drawable/ic_search_category_default"
    android:layout_margin="16dp"
    android:tint="#FFFFFF"
    android:scaleType="fitCenter"
    android:onClick="goToSearch"
    android:layout_gravity="bottom|left"
    />


</android.support.design.widget.CoordinatorLayout>

MainActivity.java

package com.example.erik.recipefriend2;

import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuInflater;
import android.view.View;
import android.view.Menu;
import java.lang.reflect.Method;

public class MainActivity extends AppCompatActivity {



   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
       Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
       toolbar.setTitleTextColor(Color.WHITE);
       setSupportActionBar(toolbar);
       android.support.v7.app.ActionBar actionBar = getSupportActionBar();
       actionBar.setLogo(R.mipmap.ic_launcher);
       actionBar.setDisplayUseLogoEnabled(true);
       actionBar.setDisplayShowHomeEnabled(true);
       FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.addIngredient);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
   }
   @Override
   public boolean onCreateOptionsMenu(Menu menu){
       MenuInflater menuInflater = getMenuInflater();
       menuInflater.inflate(R.menu.activity_main_actions, menu);
       return super.onCreateOptionsMenu(menu);
   }
   @Override
      protected boolean onPrepareOptionsPanel(View view, Menu menu) {
      if (menu != null) {
        if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method m = menu.getClass().getDeclaredMethod(
                        "setOptionalIconsVisible", Boolean.TYPE);
                m.setAccessible(true);
                m.invoke(menu, true);
            } catch (Exception e) {
                Log.e(getClass().getSimpleName(), "onMenuOpened...unable to set icons for overflow menu", e);
            }
        }
    }
    return super.onPrepareOptionsPanel(view, menu);
   }
   public void goToAdd(View view){

   }
   public void goToSearch(){

   }


}

What can the problem be? Also, if more files are needed, I will be happy to display them as well.

Answers


On you're activity you define android:theme="@style/AppTheme.NoActionBar" while you don't define AppTheme.NoActionBar anywhere in your styles. It's confusing that this compiles, but would explain why there's an error.


Need Your Help

apache rewrite POST request SSL https mod_rewrite

apache mod-rewrite redirect ssl https

I am using secure https for checkout and viewing the cart, while the front end of the store where the products are is not secure - standard http. The transfer from http to https achieved via the

Append method doesn't work in StringBuilder

java android string android-widget stringbuilder

I'm trying to create a small calculator widget but I can not concatenate the input string using StringBuilder, because the widget at every click on the button only displays the string corresponding...