`

Unity Package Android Error: Starting a Gradle Daemon, 1 incompatible and 2 stop

阅读更多

 

Unity 2020 及以上在打包 Android 应用的时候,出现以下错误:

 

 

Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details

> Configure project :launcher
WARNING: The option setting 'android.enableR8=false' is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':launcher:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':launcher:debugRuntimeClasspath'.
   > Failed to transform support-v4-25.1.0-.aar (:support-v4-25.1.0:) to match attributes {artifactType=android-manifest, org.gradle.status=integration}.
      > Execution failed for JetifyTransform: E:\xxx\Temp\gradleOut\unityLibrary\libs\support-v4-25.1.0.aar.
         > Failed to transform 'E:\xxx\Temp\gradleOut\unityLibrary\libs\support-v4-25.1.0.aar' using Jetifier. Reason: AmbiguousStringJetifierException, message: 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.)
           This is a known exception, and Jetifier won't be able to jetify this library.
           Suggestions:
            - If you believe this library doesn't need to be jetified (e.g., if it already supports AndroidX, or if it doesn't use support libraries/AndroidX at all), add android.jetifier.blacklist = {comma-separated list of regular expressions (or simply names) of the libraries that you don't want to be jetified} to the gradle.properties file.
            - If you believe this library needs to be jetified (e.g., if it uses old support libraries and breaks your app if it isn't jetified), contact the library's authors to update this library to support AndroidX and use the supported version once it is released.
           If you need further help, please leave a comment at https://issuetracker.google.com/issues/140747218.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

CommandInvokationFailure: Gradle build failed. 
D:\Program Files\Unity 2020.3.36f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "D:\Program Files\Unity 2020.3.36f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

stderr[

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':launcher:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':launcher:debugRuntimeClasspath'.
   > Failed to transform support-v4-25.1.0-.aar (:support-v4-25.1.0:) to match attributes {artifactType=android-manifest, org.gradle.status=integration}.
      > Execution failed for JetifyTransform: E:\xxx\Temp\gradleOut\unityLibrary\libs\support-v4-25.1.0.aar.
         > Failed to transform 'E:\xxx\Temp\gradleOut\unityLibrary\libs\support-v4-25.1.0.aar' using Jetifier. Reason: AmbiguousStringJetifierException, message: 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.)
           This is a known exception, and Jetifier won't be able to jetify this library.
           Suggestions:
            - If you believe this library doesn't need to be jetified (e.g., if it already supports AndroidX, or if it doesn't use support libraries/AndroidX at all), add android.jetifier.blacklist = {comma-separated list of regular expressions (or simply names) of the libraries that you don't want to be jetified} to the gradle.properties file.
            - If you believe this library needs to be jetified (e.g., if it uses old support libraries and breaks your app if it isn't jetified), contact the library's authors to update this library to support AndroidX and use the supported version once it is released.
           If you need further help, please leave a comment at https://issuetracker.google.com/issues/140747218.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details

Build completed with a result of 'Failed' in 43369 seconds (43369147 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002cc] in <786b546700bc48b68852821de5e46ca9>:0 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <786b546700bc48b68852821de5e46ca9>:0 
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

 

经项目全局搜索,Mapbox 中包含了 support-v4-25.1.0.aar 库,该库以 aar 文件的形式出现,不能在 gradle 中使用 gradle implementation 配置与 AR 中支持的 androidx 库存在冲突。

 

问题原因可以归结为 androidx 和 support-v4-25.1.0 存在冲突。MapBox 使用过时的支持库,捆绑的插件会导致与 AndroidX 冲突。

 

在 gradle 中删除 androidx 的依赖会无法构建包,android.enableJetifier=true (表示针对主工程中使用到的三方库,也会自动执行 AndroidX 的替换过程)注释掉也一样会无法 build 成功。删除 support-v4-25.1.0.aar 会重新导入。

 

1、获取 Jetifier。https://developer.android.com/studio/command-line/jetifier

 

独立的 Jetifier 工具可将依赖于支持库的库迁移为依赖于等效的 AndroidX 软件包依赖。该工具可让您直接迁移单个库,而无需使用 Android Studio 附带的 Android Gradle 插件。

其工作原理就是将 jar 或 aar 中的 support 依赖自动改为 androidx 依赖。当然也可以逆转。使用该方法,就无需使用 android studio 的 gradle 来进行迁移了。

 

2、解压并配置到系统环境变量。

 

3、Run this command:

 

写道
>jetifier-standalone -i E:\xxx\xxxExample\Assets\Mapbox\Core\Plugins\Android\support-v4-25.1.0.aar -o E:\xxx\xxxExample\Assets\Mapbox\Core\Plugins\Android\support-v4-25.1.0.aar

Exception in thread "main" com.android.tools.build.jetifier.processor.transform.bytecode.AmbiguousStringJetifierException: 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.

at com.android.tools.build.jetifier.processor.transform.bytecode.CoreRemapperImpl.rewriteString(CoreRemapperImpl.kt:91)

at com.android.tools.build.jetifier.processor.transform.bytecode.asm.CustomRemapper.mapValue(CustomRemapper.kt:75)

at org.objectweb.asm.commons.ClassRemapper.visitField(ClassRemapper.java:172)

at org.objectweb.asm.ClassReader.readField(ClassReader.java:1111)

at org.objectweb.asm.ClassReader.accept(ClassReader.java:713)

at org.objectweb.asm.ClassReader.accept(ClassReader.java:401)

at com.android.tools.build.jetifier.processor.transform.bytecode.ByteCodeTransformer.runTransform(ByteCodeTransformer.kt:40)

at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:592)

at com.android.tools.build.jetifier.processor.archive.ArchiveFile.accept(ArchiveFile.kt:59)

at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:574)

at com.android.tools.build.jetifier.processor.archive.Archive.accept(Archive.kt:78)

at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:574)

at com.android.tools.build.jetifier.processor.archive.Archive.accept(Archive.kt:78)

at com.android.tools.build.jetifier.processor.Processor.transformLibrary(Processor.kt:570)

at com.android.tools.build.jetifier.processor.Processor.transform2(Processor.kt:335)

at com.android.tools.build.jetifier.processor.Processor.transform2$default(Processor.kt:295)

at com.android.tools.build.jetifier.standalone.Main.run(Main.kt:181)

at com.android.tools.build.jetifier.standalone.Main$Companion.main(Main.kt:119)



at com.android.tools.build.jetifier.standalone.Main.main(Main.kt)

 

 

 

 

 

 

 

分享到:
评论

相关推荐

    UnityRemote4 unitypackage+android

    Unity Remote 4 是一款强大的工具,专为Unity开发人员设计,允许他们在Android设备上实时预览和测试Unity项目。这个工具极大地提高了开发效率,因为开发者可以直接在移动设备上看到游戏或应用的效果,而无需频繁地将...

    gradle-6.7.1 安装包

    Gradle 是一个强大的构建自动化工具,广泛用于Java、Android和其他多语言项目。Gradle 6.7.1是Gradle项目在2020年11月16日发布的稳定版本,提供了许多新特性和改进,旨在提升构建性能、可靠性和开发者体验。在这个...

    unity导出到android笔记.pdf

    Unity导出Android应用的基本流程包括在Unity编辑器中进行项目设置,如设置应用的包名、版本号、最小SDK版本等,然后通过Unity的构建系统导出Android项目。导出后,需在Android Studio中打开生成的项目,并进行相应的...

    Unity打包导出Gradle项目教程.rar

    1. **Unity与Gradle简介** - Unity:Unity引擎允许开发者使用C#语言编写游戏逻辑,并提供了一整套完整的编辑器工具,用于设计游戏场景、创建角色、设置动画等。 - Gradle:Gradle是一种自动化构建工具,广泛应用于...

    最新Unity插件SteamVR Plugin steamvr-2-8-0.unitypackage

    最新Unity插件SteamVR Plugin steamvr_2_8_0.unitypackage最新Unity插件SteamVR Plugin steamvr_2_8_0.unitypackage最新Unity插件SteamVR Plugin steamvr_2_8_0.unitypackage最新Unity插件SteamVR Plugin steamvr_2_...

    Kinect Wrapper Unity Package

    《Kinect Wrapper Unity Package——深度探索与应用》 在当今的游戏和交互式应用程序开发领域,Unity引擎因其强大的功能和易用性而广受欢迎。而Kinect设备,作为微软推出的一款体感控制器,以其非接触式的交互方式...

    Bluetooth LE for iOS, tvOS and Android.unitypackage

    本文将详细介绍如何在Unity中使用"Bluetooth LE for iOS, tvOS and Android.unitypackage"这一插件,实现在iOS、tvOS和Android平台上进行蓝牙连接,包括搜索设备、连接、发送与接收信息以及断开连接等关键功能。...

    Kinect for unity sdk v2.9.unitypackage

    ### Kinect for Unity SDK v2.9.unitypackage #### 知识点一:Kinect SDK 2.0 for Unity **Kinect SDK 2.0 for Unity** 是一个专为Unity游戏引擎设计的插件,它允许开发者在Unity环境中轻松地访问Kinect设备的各项...

    Unity3D插件unitypackage包外部解压器

    该插件可以外部解压.unitypackage包,可以查看.unitypackage文件内的代码,无需拖入Unity工程中查看了。

    Android Studio配合Gradle及Unity交互笔记

    ### Android Studio配合Gradle及Unity交互笔记 #### 一、Gradle安装与配置 ##### 1.1 Gradle安装步骤 根据文档中的指示,我们可以通过Scoop来安装Gradle。Scoop是一个Windows平台上的开源包管理器,它可以方便地...

    gradle-6和8的版本

    打开Android Studio,进入项目的设置或首选项,找到“Project Structure”或“项目结构”选项,然后在“Gradle Scripts”或“Gradle脚本”中编辑`build.gradle`文件,修改对应的Gradle版本号。对于Cocos Creator 3.7...

    unity 导入 android studio,使用UnitySendMessage互传消息 源码

    Android Studio会识别Unity的Gradle构建系统,你可能需要等待一会儿让Android Studio解析依赖和配置。 在Unity与Android原生代码交互时,`UnitySendMessage`是关键的通信桥梁。这是一个Unity引擎提供的API,用于从...

    atlas-unity:Unity 3D gradle插件

    2. **Gradle构建系统**:学习Gradle的基本概念,如任务、依赖管理和构建脚本,以及如何在Unity项目中设置和运行Gradle任务。 3. **资源打包(Texture Atlas)**:了解如何使用Unity的Atlas功能,将多个纹理合并成一...

    Gradle Recipes for Android Master the New Build System for Android pdf 0分

    1. Android中的Gradle构建文件基础:讲解了Gradle构建文件的基本结构,包括项目配置、任务定义以及插件应用等。 2. 配置SDK版本和其他默认设置:这部分可能会详细讲解如何在Gradle中配置项目的SDK版本,以及其他与...

    unitypackage文件解压工具

    直接解压unitypackage文件, 无需安装unity工具, 运行需要python环境, 来自 github.com/gered/extractunitypackage, 用法: extractunitypackage.py input_file [output_path]

    spine-unity-4.1.unitypackage

    常常使用 Spine 来制作一些动画,这个插件是用来让unity可以播放spine制作的动画

    Unity2Android_2018_4_30.zip

    《Unity到Android的跨平台开发详解》 Unity是一款强大的跨平台游戏引擎,广泛应用于游戏开发、虚拟现实(VR)、增强现实(AR)等领域。本文将深入探讨如何将一个Unity项目移植到Android平台,以实现Android设备上的...

    Visual Studio 2015 Tools.unitypackage

    允许你在vs中安装该插件后,可以进行对Unity进程的联调。

    .gradle替换.rar

    标题中的".gradle替换.rar"指的是一个用于替换Unity项目中原始.gradle文件的压缩包。在Unity3D游戏开发中,当开发者需要构建Android应用(APK)时,可能会遇到需要自定义或优化Gradle构建过程的情况。这通常涉及到对...

    Android Studio配合Gradle及Unity交互笔记续

    Android Studio 与 Unity 的交互技术是移动游戏开发中一个重要的环节,它允许开发者使用 Unity 来创建游戏,并通过 Android Studio 构建和发布到 Android 平台。本文档着重讲述了如何将 Unity 导出的项目与 Android ...

Global site tag (gtag.js) - Google Analytics