Unity-Gradle Build错误:无法解析配置“:releaseCompileClasspath”的所有文件

时间:2019-11-02 15:37:49

标签: android unity3d gradle android-gradle-plugin facebook-unity-sdk

我正在Unity上为Android手机开发游戏。我最近更新了我的facebook SDK,由于在构建应用程序时出现合并冲突,这是由于Play服务解析器必须将额外的库添加到项目中而导致的,因此我必须编辑Gradle.properties文件,如下所示。

org.gradle.jvmargs=-Xmx4096M
 android.useAndroidX=true
 android.enableJetifier=true

我这样做主要是因为某些支持库是合并冲突的原因。但是现在我继续收到以下错误,并且我不知道如何解决。我已经尝试过多次导入SDK,但是仍然遇到相同的问题。我也曾尝试在Unity论坛上提问,但尚未收到任何回复。任何帮助将不胜感激。

 * What went wrong:
     Execution failed for task ':preReleaseBuild'.
     > Could not resolve all files for configuration ':releaseCompileClasspath'.
        > Failed to transform artifact 'com.android.support.support-v4-27.0.2.aar (:com.android.support.support-v4-27.0.2:)' to match attributes {artifactType=android-manifest}
           > Execution failed for JetifyTransform: D:\Unity\Projects\Mzito-NewBG\2017.3\Mzito - Unity 2018.1.2f1 - GameTrove\Mzito\Temp\gradleOut\libs\com.android.support.support-v4-27.0.2.aar.
              > Failed to transform 'D:\Unity\Projects\Mzito-NewBG\2017.3\Mzito - Unity 2018.1.2f1 - GameTrove\Mzito\Temp\gradleOut\libs\com.android.support.support-v4-27.0.2.aar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.v4' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)

2 个答案:

答案 0 :(得分:0)

  1. 右键单击资产文件夹
  2. 选择 Play服务解析器
  3. Android解析器
  4. 解决

它将解决问题,但请确保已设置Java环境变量,否则可能无法正常工作

enter image description here

答案 1 :(得分:0)

转到Assets \ Plugins \ Android,然后删除所有内容 在Assets菜单中的unity编辑器中,转到Play服务解析器(或外部播放解析器)> Android Resolver>解析 现在一切都很好!