【问题标题】:Getting error Failed to load AppCompat ActionBar with unknown error. in Android Studio出现错误无法加载 AppCompat ActionBar,出现未知错误。在 Android Studio 中
【发布时间】:2018-12-12 07:50:27
【问题描述】:

我想以一个序言开始,告诉大家我已经看到了几乎所有关于此的主题和问题,因此没有必要将我链接到另一个主题。

所以我有这个错误,我在我的布局中看不到任何东西(在 Android 工作室中)。我已经尝试了互联网给我的几乎所有解决方案。如果有什么我可能错过的并且你们都知道,请告诉我。谢谢!

编辑: 这是xml文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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=".MainActivity"
    tools:layout_editor_absoluteY="25dp">

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textEmailAddress"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toStartOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/firstButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="firstButton"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toStartOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/testButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintEnd_toStartOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

build.gradle(模块:app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "testing.abdullah.me.testtest"
        minSdkVersion 28
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

记住:我对 gradle 了解不多,所以如果是 gradle 的问题,请不要只是告诉我要放入什么,告诉我是否要放入 dependencies、buildtypes 或其他任何东西。

【问题讨论】:

  • 你必须把代码贴出来我的朋友
  • @Psypher 代码已添加
  • @AbdullahRasheed 以及您遇到问题的代码?你能描述得更清楚吗:)
  • @Umair 我不知道,这些项目只是没有出现
  • @AbdullahRasheed 哪些项目没有出现。如果是布局编辑器,那么 android studio 在渲染布局时会产生问题。这就是为什么您需要准确找出问题发生在哪里,

标签: java android xml android-studio gradle


【解决方案1】:

使用以前的版本,alpha1 而不是 alpha3:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多