Android Studio -应用程序无法启动

o7jaxewo  于 2023-04-12  发布在  Android
关注(0)|答案(1)|浏览(267)

我是Android Studio的新手,我遇到了一个需要JAVA版本16+的问题。所以我所做的是尝试intergate一个新的JDK,我玩了Android版本。最后代码中的错误消失了,但现在应用程序甚至不再启动:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: it.wieland.abclists, PID: 7495
java.lang.RuntimeException: Unable to start activity ComponentInfo{it.test.abclists/it.test.abclists.MainActivity}: android.view.InflateException: Binary XML file line #35 in it.test.abclists:layout/abc_screen_toolbar: Binary XML file line #35 in it.test.abclists:layout/abc_screen_toolbar: Error inflating class androidx.appcompat.widget.ActionBarContainer
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3576)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3748)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2187)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:236)
    at android.app.ActivityThread.main(ActivityThread.java:8057)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
 Caused by: android.view.InflateException: Binary XML file line #35 in it.test.abclists:layout/abc_screen_toolbar: Binary XML file line #35 in it.test.abclists:layout/abc_screen_toolbar: Error inflating class androidx.appcompat.widget.ActionBarContainer
 Caused by: android.view.InflateException: Binary XML file line #35 in it.test.abclists:layout/abc_screen_toolbar: Error inflating class androidx.appcompat.widget.ActionBarContainer

我甚至没有(看到或找到)一个名为abc_screen_toolbar的布局-所以我真的被困在这里了。
我的清单看起来是这样的:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
    android:allowBackup="true"
    android:dataExtractionRules="@xml/data_extraction_rules"
    android:fullBackupContent="@xml/backup_rules"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/Theme.ABCLists"
    tools:targetApi="26">
    <activity
        android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

我的gradle.app:

plugins {
id 'com.android.application'
}

android {
namespace 'it.test.abclists'
compileSdk 33

defaultConfig {
    applicationId "it.test.abclists"
    minSdk 26
    targetSdk defaultTargetSdkVersion
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard- rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_6
    targetCompatibility JavaVersion.VERSION_1_6
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.room:room-common:2.4.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
// Room components
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
annotationProcessor "androidx.room:room-compiler:$rootProject.roomVersion"
androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
}

和我的gradle ABC列表:

// Top-level build file where you can add configuration options common to all sub- 
projects/modules.
plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
}
ext {
appCompatVersion = '1.5.1'
constraintLayoutVersion = '2.1.4'
coreTestingVersion = '2.1.0'
lifecycleVersion = '2.3.1'
materialVersion = '1.3.0'
roomVersion = '2.3.0'
// testing
junitVersion = '4.13.2'
espressoVersion = '3.4.0'
androidxJunitVersion = '1.1.2'
defaultTargetSdkVersion = 26
}

知道我做错了什么吗

kognpnkq

kognpnkq1#

尝试将appcompat版本降级到更低的版本,如1.3.1,看看它是否解决了问题,或者尝试创建一个新项目并复制代码文件,看看它是否解决了问题。

相关问题