Android Studio – App is not starting anymore

huangapple go评论54阅读模式
英文:

Android Studio - App is not starting anymore

问题

我是你的中文翻译,以下是你提供的代码的翻译:

我是Android Studio的新手,遇到了一个需要Java版本16+的问题。
所以我尝试集成新的JDK并尝试了Android版本的更改。
最终代码中的错误消失了,但现在应用程序甚至无法启动了:

    E/AndroidRuntime: 致命异常:主线程
    进程:it.wieland.abclists,PID:7495
    java.lang.RuntimeException:无法启动Activity ComponentInfo{it.test.abclists/it.test.abclists.MainActivity}:android.view.InflateException:在it.test.abclists:layout/abc_screen_toolbar中的二进制XML文件第35行:在it.test.abclists:layout/abc_screen_toolbar中的二进制XML文件第35行: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:在it.test.abclists:layout/abc_screen_toolbar中的二进制XML文件第35行:Error inflating class androidx.appcompat.widget.ActionBarContainer
     Caused by: android.view.InflateException:在it.test.abclists:layout/abc_screen_toolbar中的二进制XML文件第35行: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>

</manifest>

我的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 List:

    // 顶层构建文件,您可以在其中添加所有子项目/模块的常见配置选项。
    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
    }

有任何想法我做错了什么?
英文:

I'm new to Android Studio and I encontered an issue which required JAVA Version 16+.
So what I did was trying to intergate an new JDK and I played around with the android version.
Finally the error in the code was gone but now the App does not even start anymore:

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

I do not even have (see or find) a layout called abc_screen_toolbar - so I'm really stuck here.

My manifest looks like so:

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

</manifest>

My gradle.app:

plugins {
id &#39;com.android.application&#39;
}
android {
namespace &#39;it.test.abclists&#39;
compileSdk 33
defaultConfig {
applicationId &quot;it.test.abclists&quot;
minSdk 26
targetSdk defaultTargetSdkVersion
versionCode 1
versionName &quot;1.0&quot;
testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(&#39;proguard-android-optimize.txt&#39;), &#39;proguard- rules.pro&#39;
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
}
dependencies {
implementation &#39;androidx.appcompat:appcompat:1.4.1&#39;
implementation &#39;com.google.android.material:material:1.5.0&#39;
implementation &#39;androidx.constraintlayout:constraintlayout:2.1.3&#39;
implementation &#39;androidx.room:room-common:2.4.2&#39;
testImplementation &#39;junit:junit:4.13.2&#39;
androidTestImplementation &#39;androidx.test.ext:junit:1.1.3&#39;
androidTestImplementation &#39;androidx.test.espresso:espresso-core:3.4.0&#39;
implementation &#39;androidx.recyclerview:recyclerview:1.0.0&#39;
// Room components
implementation &quot;androidx.room:room-runtime:$rootProject.roomVersion&quot;
annotationProcessor &quot;androidx.room:room-compiler:$rootProject.roomVersion&quot;
androidTestImplementation &quot;androidx.room:room-testing:$rootProject.roomVersion&quot;
}

And my gradle ABC List:

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

Any ideas what I did wrong?

答案1

得分: 1

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

英文:

Try downgrading the appcompat version to a lower one such as 1.3.1 and see if it solves the issue or try creating a new project and copying the code files over to see if it solves the issue.

huangapple
  • 本文由 发表于 2023年4月11日 01:33:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979313.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定