英文:
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:
<?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>
My 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"
}
And my gradle ABC List:
// 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
}
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论