Unable to initialize native-platform. Failure: net.rubygrapefruit.platform.NativeException: Failed to initialise native integration.

On Windows-7 using fresh gradle 2.3 install. GRADLE_HOME is set. GRADLE_USER_HOME setting is irrelevant:

$ gradle -v --debug --stacktrace

16:17:57.747 [DEBUG] [org.gradle.internal.nativeintegration.services.NativeServices] Unable to initialize native-platform. Failure: net.rubygrapefruit.platform.NativeException: Failed to initialise native integration. caused by: java.lang.UnsatisfiedLinkError: net.rubygrapefruit.platform.internal.jni.NativeLibraryFunctions.getVersion()I 16:17:57.772 [ERROR] [org.gradle.BuildExceptionReporter] 16:17:57.775 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception. 16:17:57.775 [ERROR] [org.gradle.BuildExceptionReporter] 16:17:57.775 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong: 16:17:57.776 [ERROR] [org.gradle.BuildExceptionReporter] com.sun.jna.Native.sizeof(I)I 16:17:57.776 [ERROR] [org.gradle.BuildExceptionReporter] 16:17:57.777 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is: 16:17:57.777 [ERROR] [org.gradle.BuildExceptionReporter] java.lang.UnsatisfiedLinkError: com.sun.jna.Native.sizeof(I)I 16:17:57.778 [ERROR] [org.gradle.BuildExceptionReporter]

at com.sun.jna.Native.sizeof(Native Method) 16:17:57.778 [ERROR] [org.gradle.BuildExceptionReporter]

at com.sun.jna.Native.(Native.java:110) 16:17:57.778 [ERROR] [org.gradle.BuildExceptionReporter]

at org.fusesource.jansi.internal.Kernel32.(Kernel32.java:33) 16:17:57.778 [ERROR] [org.gradle.BuildExceptionReporter]

at org.fusesource.jansi.WindowsAnsiOutputStream.(WindowsAnsiOutputStream.java:47) 16:17:57.779 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.internal.nativeintegration.console.WindowsConsoleDetector.getConsole(WindowsConsoleDetector.java:28) 16:17:57.779 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.logging.internal.ConsoleConfigureAction.execute(ConsoleConfigureAction.java:38) 16:17:57.779 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.logging.internal.ConsoleConfigureAction.execute(ConsoleConfigureAction.java:29) 16:17:57.779 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.logging.internal.OutputEventRenderer.attachProcessConsole(OutputEventRenderer.java:75) 16:17:57.779 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.logging.internal.DefaultLoggingManager.attachProcessConsole(DefaultLoggingManager.java:163) 16:17:57.780 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:204) 16:17:57.780 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169) 16:17:57.780 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) 16:17:57.780 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) 16:17:57.781 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.launcher.Main.doAction(Main.java:33) 16:17:57.781 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) 16:17:57.781 [ERROR] [org.gradle.BuildExceptionReporter]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 16:17:57.781 [ERROR] [org.gradle.BuildExceptionReporter]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 16:17:57.782 [ERROR] [org.gradle.BuildExceptionReporter]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 16:17:57.782 [ERROR] [org.gradle.BuildExceptionReporter]

at java.lang.reflect.Method.invoke(Method.java:606) 16:17:57.782 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54) 16:17:57.782 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35) 16:17:57.782 [ERROR] [org.gradle.BuildExceptionReporter]

at org.gradle.launcher.GradleMain.main(GradleMain.java:23) 16:17:57.783 [ERROR] [org.gradle.BuildExceptionReporter]

Hi Scott,

This is pretty strange. The fact that it’s failing to find a JDK class ‘com.sun.jna.Native.sizeof(I)I’ points to your environment being pretty messed up.

Are you doing anything custom that might contribute to this? How did you install the JDK?

I’ve been running Java 1.5, 1.6, 1.7 (default), and 1.8 on my PC for 2 years and have no other issues. I’m not sure what you mean by custom, but they were standard JDK installations. What is likely the issue is that corporate policy has access locked down on Windows 7 – for instance, installers have to be run in particular directories to succeed. But since this was just a download, unzip, and setting of environment variables, I didn’t expect such a complication.

One possibility is that your administrators are blocking the use of JNA.

Can you please check to see if your environment imposes the ‘jna.library.path’ JVM system property.

In gradle.bat, I tried setting:

set DEFAULT_JVM_OPTS=-Djna.library.path=%GRADLE_USER_HOME%\native\jna\win32-amd64

where GRADLE_USER_HOME=C:\java\gradle-2.3

Same error.

I don’t think ‘jna.library.path’ should be set at all.

Sorry, I misunderstood. But it behaves the same either way.

Can you try system the system property ‘org.gradle.native=false’ please.

Command line:

“C:\Program Files\Java\jdk1.7.0_45/bin/java.exe” “-Dorg.gradle.native=false”

“-Dorg.gradle.appname=gradle” -classpath “C:\java\gradle-2.3\bin..\lib\gradle-launcher-2.3.jar” org.gradle.launcher.GradleMain -v --debug --stacktrace

Result:

FAILURE: Build failed with an exception.
  * What went wrong:
com.sun.jna.Native.sizeof(I)I
  * Exception is:
java.lang.UnsatisfiedLinkError: com.sun.jna.Native.sizeof(I)I
       at com.sun.jna.Native.sizeof(Native Method)
       at com.sun.jna.Native.<clinit>(Native.java:110)
       at org.fusesource.jansi.internal.Kernel32.<clinit>(Kernel32.java:33)
       at org.fusesource.jansi.WindowsAnsiOutputStream.<clinit>(WindowsAnsiOutputStream.java:47)
       at org.gradle.internal.nativeintegration.console.WindowsConsoleDetector.getConsole(WindowsConsoleDetector.java:28)
       at org.gradle.logging.internal.ConsoleConfigureAction.execute(ConsoleConfigureAction.java:38)
       at org.gradle.logging.internal.ConsoleConfigureAction.execute(ConsoleConfigureAction.java:29)
       at org.gradle.logging.internal.OutputEventRenderer.attachProcessConsole(OutputEventRenderer.java:75)
       at org.gradle.logging.internal.DefaultLoggingManager.attachProcessConsole(DefaultLoggingManager.java:163)
       at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:204)
       at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
       at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
       at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.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:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:606)
       at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
       at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
       at org.gradle.launcher.GradleMain.main(GradleMain.java:23)

I moved my gradle-2.3 folder to a directory with relaxed file system restrictions and it works now. I don’t know what specifically about the Windows 7 access control interfered, but at least I can work around it.

1 Like