dll - Gradle 异常无法加载 native 库 native-platform.dll

标签 dll gradle

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

$ 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。为了保护恶意软件,可以禁用从 TMP 目录加载 DLL 和执行程序。

我遇到了具有相同症状的问题,在某些情况下,我已经能够通过将 TEMP 和 TMP 环境变量设置为指向用户目录之外(例如 c:\tmp)来解决该问题。这不是一个通用的解决方案,也不适用于 gradle。可以通过将 GRADLE_OPTS 设置为指向所需位置来覆盖 Gradle 提取 DLL 的位置。这可能对您有用:

C:\mkdir C:\tmp

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

关于dll - Gradle 异常无法加载 native 库 native-platform.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36429504/

相关文章:

android - Android Instant Run Gradle错误

visual-studio - 如何在 Visual Studio 中设置 DLL 文件的路径?

c++ - 如何在 visual studio 2010 express 中将 cpp 编译为 dll

java - 您如何找到 System.loadLibrary() 在哪里查找库?

spring-boot - 引起原因:java.lang.NoSuchMethodError:org.apache.tomcat.util.res.StringManager.getManager(Ljava/lang/Class;)

android - 如何启用 stacktrace react-native run-android 命令?

android - 在如下所示的 gradle 中,我可以在发布应用程序之前从代码 testImplementation 'junit:junit:4.12' 中删除吗?

c++ - visual studio 中的 Onexit.c 错误?

c++ - 用qt制作C++库

android-studio - Gradle:一种基于另一种构建类型