在Unity中为Android构建Gradle失败,称无法找到intellij-core.jar

n3h0vuf2  于 2023-03-27  发布在  Android
关注(0)|答案(5)|浏览(190)

这就是我所尝试的:

  • 创建不同的项目(相同的内容)
  • 重新安装sdk,jdk和Unity编辑器(新手gotos)

今天我也遇到了类似的问题:Android Studio - Could not find intellij-core.jar然而,我发现的唯一的gradle.build文件是在Temp文件夹中用Unity生成的,它在每次构建开始后都会覆盖自己。
统一2018.2.13f1, windows 10 x64,新鲜的Android Studio 3.2.1,jdk1.8.0_192

下面是控制台日志:

A problem occurred configuring root project 'gradleOut'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find intellij-core.jar (com.android.tools.external.com-intellij:intellij-core:26.0.1).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jar

CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Java\jdk1.8.0_192\bin\java.exe -classpath "C:\Program Files (x86)\Unity Editors\2018.2.13f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.2.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"

stderr[

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'gradleOut'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find intellij-core.jar (com.android.tools.external.com-intellij:intellij-core:26.0.1).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jar

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

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

BUILD FAILED in 1s
]
stdout[

]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
ut6juiuv

ut6juiuv1#

以下是对我有效的方法,据here报道:
1.进入播放器设置
1.在发布设置下,勾选自定义Gradle模板(Unity会为您创建一个build.gradle模板)
1.模板位于Assets〉Plugins〉Android〉mainTemplate.gradle中
1.在记事本之类的工具中打开该文件
1.更改 * 仅此 *:
repositories { jcenter() google() }repositories { google() jcenter() }
1.保存文件,然后再次尝试构建。不是一个完美的解决方案,但它应该工作,直到Unity/Android修复这个问题。我不确定是否可以通过升级Unity来撤销这个问题,但我知道它必须在每个项目中完成。

pgky5nke

pgky5nke2#

这里是唯一的解决方案,为我工作,因为我背后的代理
1.转到.gradle folder(默认在C:\Users\<name>\下)。
1.在此文件夹下创建一个名为gradle.properties的文件。
1.增加以下内容:

#http proxy setup
systemProp.http.proxyHost=<your proxy URL>
systemProp.http.proxyPort=<your proxy Port>
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost

#https proxy setup
systemProp.https.proxyHost=<your proxy URL>
systemProp.https.proxyPort=<your proxy Port>
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost

1.重新开启团结共建!

iqxoj9l9

iqxoj9l93#

如果Glen的回答对您不起作用,请再次执行他的步骤https://stackoverflow.com/a/52958384/6046022并进行一些编辑
1.将Assets > Plugins > Android > mainTemplate.gradle中的repositories更改为:

repositories {
    google()
    jcenter()
    mavenLocal()
    mavenCentral()
    maven { url 'https://maven.google.com' }
    maven { url "https://www.jitpack.io" }
    flatDir {
        dirs 'libs'
    }
}

1.**我想这是我的问题:**确保您的互联网连接到仓库是好的!在一些国家有限制。在这种情况下,你需要一个VPN。
1.最后一步重启Unity
构建花了几分钟,但它的工作
我还更新了Gradle:https://answers.unity.com/questions/1490992/change-version-of-gradle-to-46.html
但不确定有没有用

5m1hhzi4

5m1hhzi44#

在我的例子中,Assets〉Plugins〉Android〉mainTemplate.gradle已经使用jcenter()调用了,所以我只需要选中“Custom Gradle Template”就可以了!

lb3vh1jj

lb3vh1jj5#

我让它工作!得到了同样的错误,使用Firebase也是,所以这里提到的修复不会有帮助,因为Firebase不断覆盖我的gradle模板。下面是答案:
https://forum.unity.com/threads/commandinvokationfailure-gradle-build-failed.573040/
祝你好运!

相关问题