android studio에서 알 수없는 오류로 AppCompat ActionBar를로드하지 못했습니다.

아래는 내 xml 파일입니다. 미리보기에는 ‘알 수없는 오류로 AppCompat ActionBar를로드하지 못했습니다’및 ‘두 개 이상의 클래스를 설치하지 못했습니다’라는 두 가지 오류가 있습니다. 앱을 실행할 수는 있지만 앱이 충돌하고 Logcat에 오류가 표시되지 않습니다.

이것은 나의 미리보기 스크린 샷입니다여기에 이미지 설명을 입력하십시오

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">


    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="506dp" />

    <LinearLayout
        android:id="@+id/layout_main"
        android:orientation="vertical"
        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:weightSum="1"
        tools:context=".Activity.MainActivity">


    <LinearLayout
        android:id="@+id/main_layout"
        android:orientation="vertical"
        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:layout_weight="0.7"
        tools:context=".Activity.MainActivity">

        <!-- our tablayout to display tabs  -->
        <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            app:tabMode="scrollable"
            app:tabSelectedTextColor="@color/colorBlack"
            app:tabTextColor="@color/colorWhite"
            android:background="@color/colorOran"
            android:minHeight="?attr/actionBarSize"
            />

        <!-- View pager to swipe views -->
        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </LinearLayout>

        <LinearLayout
            android:id="@+id/ll"
            android:layout_width="match_parent"
            android:layout_height="64dp"
            android:layout_alignParentBottom="true"
            android:background="#ffffff"
            android:orientation="horizontal"
            android:layout_weight="0.3"
            android:weightSum="4"
            tools:layout_editor_absoluteX="8dp"
            android:layout_marginBottom="8dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true">

            <ImageView
                android:id="@+id/btn_home"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:src="@drawable/ta_home_icon"
                android:background="@color/colorOran"
                android:layout_marginRight="1dp"
                android:scaleType="fitCenter"/>

            <ImageView
                android:id="@+id/btn_new"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:src="@drawable/ta_todaydeals_icon"
                android:background="@color/colorOran"
                android:layout_marginRight="1dp"
                android:scaleType="fitCenter"/>

            <ImageView
                android:id="@+id/btn_fav"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:src="@drawable/ta_fav_icon"
                android:background="@color/colorOran"
                android:layout_marginRight="1dp"
                android:scaleType="fitCenter"/>

            <ImageView
                android:id="@+id/btn_auth"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:src="@drawable/ta_franchie_icon"
                android:background="@color/colorOran"
                android:scaleType="fitCenter"
                android:layout_marginRight="1dp"
                />

        </LinearLayout>

    </LinearLayout>


    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />


</android.support.v4.widget.DrawerLayout>

아래는 appbar_main입니다

<?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"
    tools:context="com.jeyashri.kitchen.jeyashriskitchen.Activity.MainActivity">

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


        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorOran"
            app:popupTheme="@style/AppTheme.PopupOverlay">

            <ImageView
                android:id="@+id/app_logo"
                android:layout_width="80dp"
                android:layout_height="match_parent"
                android:src="@drawable/img"/>

            <ImageView
                android:id="@+id/btn_social"
                android:layout_width="75dp"
                android:layout_height="35dp"
                android:layout_marginRight="1dp"
                android:src="@drawable/share_icon" />

    </android.support.v7.widget.Toolbar>

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

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


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


답변

이 문제점에 대한 솔루션은 사용중인 Android 지원 라이브러리의 버전에 따라 다릅니다.

지원 라이브러리 26.0.0-beta2

이 안드로이드 지원 라이브러리 버전은 언급 된 문제를 일으키는 버그가 있습니다

Gradle 빌드 파일에서 다음을 사용하십시오.

compile 'com.android.support:appcompat-v7:26.0.0'

와:

buildToolsVersion '26.0.0' 

classpath 'com.android.tools.build:gradle:3.0.0-alpha8'

이제 모든 것이 잘 작동합니다.


라이브러리 버전 28 (베타)

이 새로운 버전들은 다시 비슷한 어려움을 겪고있는 것 같습니다.

당신 res/values/styles.xmlAppTheme스타일을 수정

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

(추가 참고 Base.)

또는 문제가 해결 될 때까지 라이브러리를 다운 그레이드하십시오.

implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'

답변

이 사이트에서 찾았습니다. 다음에서 /res/values/styles.xml을 수정하십시오.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>

에:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
</style>

답변

다른 appcompact 버전을 사용하여 2018 년 6 월 문제가 해결되었습니다. 이 코드를 프로젝트 종속성에 사용하십시오 …

build.gradle (Module : app)에서이 의존성을 추가하십시오

implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'

행복한 코딩 … 🙂


답변

방법 1 :

위치하고 있다 /res/values/styles.xml

변화

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

방법 2 :

수정 템플릿 파일 (위치 : android-studio/plugins/android/lib/templates/gradle-projects/NewAndroidModule/root/res/values/styles.xml.ftl)

변화

backwardsCompatibility!true>Theme.AppCompat<#else><#if

backwardsCompatibility!true>Base.Theme.AppCompat<#else><#if

YouTube에서 솔루션보기


답변

나는 또한이 문제가 있었고 res / values ​​/ styles.xml의 변경 라인으로 해결되었습니다.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

  1. <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
  2. <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

두 솔루션 모두 작동


답변

미리보기 모드 열기

아래 링크를 따라 문제를 해결하십시오.

수정-렌더링 문제 다음 클래스를 찾을 수 없습니다. android.support.v7.internal

appTheme —-> Holo Theme 선택 —> 새로 고침

https://www.youtube.com/watch?v=4MxBnwpcUjA


답변

Android Studio 3.1.3 에서 동일한 문제에 직면했습니다.

style.xml 파일 로 이동 하십시오.

테마 이름을 바꿉니다

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

그런 다음 프로젝트를 정리 하고 다시 빌드 하면 오류가 해결됩니다.