gpt4 book ai didi

java - Android Studio 错误 : java. lang.ExceptionInInitializerError?

转载 作者:行者123 更新时间:2023-12-04 16:23:17 31 4
gpt4 key购买 nike

我正在尝试在 Android Studio 中编译一个应用程序,但我不断收到此错误:

Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.ExceptionInInitializerError
这里有一个类似的问题: Execution Failed for task :app:compileDebugJavaWithJavac in Android Studio
我尝试了上述问题中的几乎所有答案,但似乎没有任何效果!
这是我的 build.gradle (模块):
apply plugin: 'com.android.application'
apply plugin: "androidx.navigation.safeargs"

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.XXXXXXX"
minSdkVersion 18
targetSdkVersion 29
versionCode 3
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
resValue("string", "PORT_NUMBER", "8081")
}
}

dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def lifecycle_version = "2.2.0"
def room_version = "2.2.5"
def nav_version = "2.1.0-alpha02"
def dagger_version = "2.27"
def work_version = "2.4.0"

//Navigation Jetpack
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"

//Lifecycle Jetpack
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'

//ROOM DB
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"


implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

//GSON
implementation 'com.google.code.gson:gson:2.6.2'

//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'

//RXJava
implementation 'io.reactivex.rxjava2:rxjava:2.0.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'


implementation "androidx.preference:preference:1.1.0"
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'

//Dagger 2
implementation "com.google.dagger:dagger:$dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"

// Dagger Android
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"

// Reactive Streams (convert Observable to LiveData)
def reactivestreams_version = "1.1.1"
implementation "android.arch.lifecycle:reactivestreams:$reactivestreams_version"

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

//Google maps
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'org.jetbrains:annotations-java5:15.0'

//Shimmer animation
implementation 'com.facebook.shimmer:shimmer:0.5.0'

//local DB debug
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'

//floating button
implementation 'com.getbase:floatingactionbutton:1.10.1'

//lombok
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'

//swipe to delete
implementation 'it.xabaras.android:recyclerview-swipedecorator:1.2.1'

//work manager
implementation "androidx.work:work-runtime:$work_version"
implementation "androidx.work:work-rxjava2:$work_version"
implementation 'androidx.hilt:hilt-work:1.0.0-alpha01'
annotationProcessor 'androidx.hilt:hilt-compiler:1.0.0-alpha01'


//ml vision api
implementation 'com.google.android.gms:play-services-vision:20.1.3'


//maps location
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'

//jackson parser
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.1'
implementation 'com.android.support:multidex:1.0.3'

//chart
implementation 'com.mdgiitr.suyash:graphkit:0.9.0'

}
有人可以在这个问题上为我指出正确的方向和建议吗?
编辑:
我在 Mac 机器上运行最新的 Android Studio。

最佳答案

如果 也会发生此异常。喷气背包室 < 2.4.0-alpha03 用于苹果的 M1 芯片。
这可以通过将正确的依赖项添加到 gradle 文件来解决

def room_version = "2.4.0-alpha03" //Needs to be this version to build on apple M1 chips

implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
如前所述 here .

关于java - Android Studio 错误 : java. lang.ExceptionInInitializerError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69285196/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com