`

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)

 

 

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics