gpt4 book ai didi

android - 无法使用 Android Studio 4.2 将 Gradle 与 Firebase Crashlytic 2.6.0 同步

转载 作者:行者123 更新时间:2023-12-04 23:36:57 26 4
gpt4 key购买 nike

项目级 build.gradle

buildscript {
addRepos(repositories)
dependencies {

classpath 'com.google.gms:google-services:4.3.5'

// Crashlytic
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.6.0'

}
}
应用级 build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

dependencies {

// Crashlytic
implementation 'com.google.firebase:firebase-crashlytics:18.0.0'

}
使用 gradle 4.3.5 和 Firebase crashlytic 2.6.0 我的应用程序停止编译并出现以下错误
class org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar$2 cannot be cast to class org.gradle.api.file.Directory (org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar$2 and org.gradle.api.file.Directory are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @68be2bc2)
class org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar$2 cannot be cast to class org.gradle.api.file.Directory (org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar$2 and org.gradle.api.file.Directory are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @68be2bc2)

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
但是如果我将 Firebase crashlytic 版本更改为 2.3.0 ,一切正常
你们知道为什么会这样吗?

最佳答案

更新答案:
编译问题的原因是 Gradle 和 Crashlytics Gradle 插件的版本不兼容。
如所述here ,从 Crashlytics Gradle 插件版本 2.5.0 开始:

The CrashlyticsGradle plugin is compatible with Gradle v5.6.4+ and the Android Gradleplugin v3.4.2+. Support for previous Gradle and Android Gradle pluginversions have been removed.


所以, 解决方案是用最新的 Gradlefirebase-crashlytics-gradle版本。感谢@Mher 描述了兼容的最新版本 here .按照他的回答更新版本。不要忘记将应用级别 build.gradle 中的 compileOptions 更改为:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
警告:我在下面的旧答案是为那些还没有准备好更新 Gradle 版本的人修复 Gradle 和 Crashlytics 兼容性的解决方法。正确的解决方案是更新 Gradle 版本。在下面的旧答案中,提到的 firebase-crashlytics-gradle:2.4.1对我来说是错误的,它无法将映射文件上传到对崩溃报告进行去混淆处理的 Firebase 控制台。因此,请尝试遵循上述更新的答案,而不是降级 Crashlytics Gradle 版本。
无法更新 GRADLE 版本的旧答案:
我遇到了完全相同的问题。似乎最新的 crashlytics-gradle 插件与某些东西不兼容。使用较低版本的 crashlytics-gradle 插件会有所帮助。而不是 firebase-crashlytics-gradle:2.6.0尝试使用此版本:
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
这对我有用......如果这对你不起作用,你也许可以尝试更低的版本。可以在此处找到版本列表:
https://firebase.google.com/support/release-notes/android#crashlytics_gradle_plugin_v2-0-0
当您搜索“Crashlytics Gradle 插件版本”时,您可以看到 Crashlytics Gradle 插件的所有已发布版本。
我还必须将应用级别 build.gradle 中的 compileOptions 更改为:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
当目标和源兼容性未设置为 1_8 时,项目已编译但在尝试运行应用程序时崩溃:
    --------- beginning of crash
2021-06-09 17:22:28.765 29519-29519/com.resmed.myair.cpl E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.resmed.myair.cpl, PID: 29519
java.lang.BootstrapMethodError: Exception from call site #45 bootstrap method
at com.google.firebase.components.ComponentDiscovery.discoverLazy(ComponentDiscovery.java:112)
at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:418)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:299)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1917)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1892)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NoClassDefFoundError: Invalid descriptor: minimize.
at com.google.firebase.components.ComponentDiscovery.discoverLazy(ComponentDiscovery.java:112) 
at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:418) 
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:299) 
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267) 
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252) 
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:1917) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:1892) 
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45) 
at android.app.ActivityThread.installProvider(ActivityThread.java:6239) 
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722) 
at android.app.ActivityThread.-wrap1(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494)

关于android - 无法使用 Android Studio 4.2 将 Gradle 与 Firebase Crashlytic 2.6.0 同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67499392/

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