Gradle异常无法加载本地库native-platform.dll [英] Gradle exception Failed to load native library native-platform.dll

查看:804
本文介绍了Gradle异常无法加载本地库native-platform.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在Windows 7机器上安装了Gradle 2.11,当我运行gradle -v时,我收到了一条失败消息。 Gradle在路径中并且dll存在。

I have just installed Gradle 2.11 on a Windows 7 machine and when I run gradle -v I get a failure message. Gradle is in the path and the dll is present.

$ gradle -v --stacktrace

FAILURE: Build failed with an exception.

* What went wrong:
Failed to load native library 'native-platform.dll' for Windows 7 amd64.

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

* Exception is:
net.rubygrapefruit.platform.NativeException: Failed to load native library 'nati                                        ve-platform.dll' for Windows 7 amd64.
        at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeL                                        ibraryLoader.java:49)
        at net.rubygrapefruit.platform.Native.init(Native.java:55)
        at org.gradle.internal.nativeintegration.services.NativeServices.initial                                        ize(NativeServices.java:74)
        at org.gradle.internal.nativeintegration.services.NativeServices.initial                                        ize(NativeServices.java:60)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(                                        CommandLineActionFactory.java:203)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(                                        CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep                                        ortingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep                                        ortingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.                                        java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces                                        sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots                                        trap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j                                        ava:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.io.IOException: The system cannot find the path specified
        at java.io.WinNTFileSystem.createFileExclusively(Native Method)
        at java.io.File.createNewFile(File.java:1012)
        at net.rubygrapefruit.platform.internal.NativeLibraryLocator.find(Native                                        LibraryLocator.java:39)
        at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeL                                        ibraryLoader.java:41)
        ... 16 more


推荐答案

这是由Windows配置引起的,可能是通过组策略。 native-platform.dll文件是从其中一个JAR文件中提取的,可能放置在用户主目录的文件夹中,如c:\ Users \\\\ USERNAME%\ Local Settings \ Temp。对于恶意软件保护,DLL的加载和从TMP目录执行程序可能被禁用。

This is cause by Windows configuration, probably through group policy. The file native-platform.dll is extracted from one of the JAR files, and probably placed in folder in the user home directory, such as c:\Users\%USERNAME%\Local Settings\Temp. For malware protection, loading of DLL's and execution of programs from TMP directories may be disabled.

我遇到同样症状的问题,我可以解决在某些情况下,通过将TEMP和TMP环境变量设置为指向用户目录之外,如c:\ tmp。这不是一个通用的解决方案,并不适用于Gradle。 Gradle提取DLL的位置可以通过将GRADLE_OPTS设置为指向所需位置来覆盖。这可能适用于你:

I have a problem with the same symptoms, and I have been able to work around it in some cases by setting TEMP and TMP environment variables to point outside the user directory, such as c:\tmp. That has not been a universal solution and did not work for gradle. The location to which Gradle extracts DLL's can be overwritten by setting the GRADLE_OPTS to point to the desired location. This may work for you:

C:\ mkdir C:\ tmp

C:\ mkdir C:\tmp

C:\设置GRADLE_OPTS = - Dorg.gradle.native.dir = / tmp

C:\ set GRADLE_OPTS="-Dorg.gradle.native.dir=/tmp"

这篇关于Gradle异常无法加载本地库native-platform.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆