[Unity] [Firebase] Dex:将字节码转换为dex时出错:构建Player时出错

时间:2019-03-01 08:18:15

标签: android firebase unity3d

我正在尝试在Unity应用程序中添加Firebase Analytics和Firebase Messaging。 我正在为Firebase和Unity 2017.4.0f1使用最新的官方软件包

导入Firebase后,当我尝试进行构建时,它失败并显示以下错误

Dex: Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add 
targetCompatibility = '1.7'
sourceCompatibility = '1.7'

我到处搜索,但是找不到解决方案,人们已经在Android Studio上解决了这个问题,但是在Unity上却无法解决。我不确定该如何解决。 请帮助,将不胜感激。

2 个答案:

答案 0 :(得分:0)

相同的问题,但统一为5.6.6。 我尝试创建自定义mainTemplate.gradle并将此代码添加到“ andrond”部分和“ buildscript”部分

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
}

但这没有帮助。

我找到了解决方法!有点脏,但是可以用。

1)我使用过工具JarCheck http://mindprod.com/products1.html#JARCHECK 并发现com.google.auto.value.auto-value-annotations-1.6.jar(它是针对Java 1.8构建的)中存在什么问题,所有其他库均为1.7。 这个jar由PlayServicesResolver for Firebase添加到了版本中。

2)在“资产”->“播放服务解析器”->“ Android解析器”->“设置”中禁用“自动解析”。

3)从“资产\插件\ Android \”中删除com.google.auto.value.auto-value-annotations-1.6.jar。没有此库,Firebase看起来可以正常工作。

但是现在应该在每次手动解析GP后手动将其删除。

答案 1 :(得分:0)

以我为例。 我将Firebase从5.3更新为5.5,而统一5.6.5f1发生了相同的问题

检查此。 https://github.com/firebase/quickstart-unity/issues/321

我将Google Play游戏服务插件从0.9.5更新为0.9.62 解决了

相关问题