Brumley Gap
Brumley Gap

Reputation: 51

Gradle exception Failed to load native library native-platform.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

Upvotes: 3

Views: 11395

Answers (4)

Abhay
Abhay

Reputation: 655

1.Open the projects gradle.properties file in android studio
2.Added this line at end of file org.gradle.jvmargs=-Xmx1024m & Save the file
3.Close & reopen the project

And you just need to restart the android studio and your system. This is getting just because you have no enough free space in ROM

Upvotes: 0

will
will

Reputation: 5061

Further to user6823564 solution above, I also came across this issue after cleaning my temporary files.

The cause is a missing native folder. Beats me why Gradle just doesn't restore it like any other bit of missing temporary/cached data.

Answer:

 md  %GRADLE_USER_HOME%\native

Which is the default location. Or use the setting given by user6823564 and Marcos... using either

 set GRADLE_OPTS="-Dorg.gradle.native.dir=%GRADLE_USER_HOME%\native"

or using

 %GRADLE_USER_HOME%\gradle.properties

good luck.

Upvotes: 1

In adition, you have to put the set sentence in the gradle.bat located in the ../gradle-2.11/bin folder.

Example:

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%..

@rem agregado por marcgaso
set GRADLE_OPTS="-Dorg.gradle.native.dir=/tmp"
**strong text**

Upvotes: 1

user6823564
user6823564

Reputation: 51

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.

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:\ set GRADLE_OPTS="-Dorg.gradle.native.dir=/tmp"

Upvotes: 5

Related Questions