简体   繁体   English

Unity Android 构建错误 - 此构建中使用了已弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容

[英]Error on Unity Android Build - Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0

This question have been asked before but I am looking for solution for Unity platform.之前有人问过这个问题,但我正在寻找 Unity 平台的解决方案。 I tried to export project, had it opened on Android Studio but Gradle sync failed there too.我尝试导出项目,如果它在 Android Studio 上打开,但 Gradle 同步也在那里失败。

I have been using GoogeAds and Firebase in my project.我一直在我的项目中使用 GoogeAds 和 Firebase。 The project builds well for IOS but for Android it gives me error "Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0".该项目为 IOS 构建良好,但对于 Android,它给我错误“此构建中使用了弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容”。

I tried to delete everything in Plugins folder (except Template.gradle) but still got the same error.我试图删除插件文件夹中的所有内容(Template.gradle 除外)但仍然出现相同的错误。

So neither I am able to debug it on Android studio nor it is building on Unity.所以我既不能在 Android studio 上调试它,也不能在 Unity 上构建它。 Any help or direction will be very beneficial.任何帮助或指导都会非常有益。

I am using unity 2018.4.5f1我正在使用统一 2018.4.5f1

Thanks谢谢

The problem here is that specific versions of Unity are tied to specific versions of gradle, and since later versions of gradle are not necessarily backward-compatible, you might not be able to build if you don't have the same one installed as your system-default version.这里的问题是 Unity 的特定版本与 gradle 的特定版本相关联,并且由于 gradle 的更高版本不一定向后兼容,如果您没有安装与系统相同的版本,您可能无法构建-默认版本。

I solved this issue by making a reference to the internal versions of Java and gradle that Unity uses.我通过参考 Unity 使用的 Java 和 gradle 的内部版本解决了这个问题。 For example, I was using Unity 2018.4.18 on a Mac for a recent project.例如,我在 Mac 上使用 Unity 2018.4.18 进行最近的项目。 This requires gradle 5.1.1, whereas my system gradle was 6.6.这需要 gradle 5.1.1,而我的系统 gradle 是 6.6。 I noticed while building that it also used a number of command-line options.我在构建时注意到它还使用了许多命令行选项。

So I just copied them into a new command: alias gradle511='/Applications/Unity2018.4.18/PlaybackEngines/AndroidPlayer/Tools/OpenJDK/MacOS/bin/java -classpath "/Applications/Unity2018.4.18/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m"'所以我只是将它们复制到一个新命令中: alias gradle511='/Applications/Unity2018.4.18/PlaybackEngines/AndroidPlayer/Tools/OpenJDK/MacOS/bin/java -classpath "/Applications/Unity2018.4.18/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m"'

On Windows you could do something similar.在 Windows 你可以做类似的事情。 For example, I found a copy of gradle at this location: C:\Program Files\Unity\Hub\Editor\2019.3.15f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib比如我在这个位置找到了一份gradle: C:\Program Files\Unity\Hub\Editor\2019.3.15f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib

Then, I could build by project successfully by finding the gradle project that Unity exported and running: gradle511 assembleRelease然后,我可以通过找到 Unity 导出并运行的 gradle 项目成功按项目构建: gradle511 assembleRelease

Try to change dependencies { classpath 'com.android.tools.build.gradle:3.4.0'尝试更改依赖项 { classpath 'com.android.tools.build.gradle:3.4.0'

to: dependencies { classpath 'com.android.tools.build.gradle:3.4.3' to: dependencies { classpath 'com.android.tools.build.gradle:3.4.3'

... worked for me somehow ...以某种方式为我工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我执行 gradle lint 时出现错误“此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容” - Error "Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0" When I do gradle lint React-Native Android Studio 项目构建失败,显示“此构建中使用了弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容。” - React-Native Android Studio Project Build failed showing "Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0." 此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容。 - 反应原生 - Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. - React native 此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 6 不兼容 - Deprecated Gradle features were used in this build, making it incompatible with Gradle 6 此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 5.0 不兼容 - Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 此版本中使用了已弃用的 Gradle 功能,使其与 Gradle X 不兼容 - Deprecated Gradle features were used in this build, making it incompatible with Gradle X 更新后无法构建 android 项目,错误:此构建中使用了已弃用的 Gradle 功能,使其与 Gradle 5.0 不兼容 - Cannot build android project after updating, error: Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Cordova - Android - 此版本中使用了已弃用的 Gradle 功能,使其与 Z7B5CC4FB56E11DC7520F701EC 不兼容 - Cordova - Android - Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0 “此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容。” -反应原生 - "Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0." -REACT-NATIVE Task:app:mergeReleaseResources FAILED, Deprecated Gradle features used in this build, 使其与 Gradle 7.0 不兼容 - Task :app:mergeReleaseResources FAILED, Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM