Error for gradle build for my Java project - java

I am trying to build the Java project located at here: https://github.com/garlicPasta/dotServer
I'm new to Gradle. I downloaded the latest Gradle now (v4.0). I added the bin folder of Gradle (which includes gradle.bat) to the path so I can run gradle command everywhere. Looks like the project requires Google protobuf which it downloads automatically. But when I start the command gradle build, I get the following error:
> Configure project :
You are using Gradle 4.0: This version of the protobuf plugin works with Gradle version 2.12+
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'dotServer'.
> No signature of method: org.gradle.api.internal.tasks.DefaultTaskInputs.source() is applicable for argument types: (com.google.protobuf.gradle.ProtobufSourceDirectorySet_Decorated) values: [main Proto source]
Possible solutions: collect(), use([Ljava.lang.Object;)
Where is the problem coming from? Can someone try to build the project and let me know?

I just upgraded to Android Studio 3 and had the same problem when I upgrade Gradle and it's plugin.
We use Google's Protobuf which was included in build.gradle with version 0.7.6. I just changed to 0.8.3 and it builds now.
buildscript {
...
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
}
}

Related

vscode java doesn't work with multi-project layout gradle project

java vscode doesn't work well with multi-project layout gradle project. I can simply reproduce this with the sample project generated by gradle init.
The error msg looks like some building task dependency issues: Cannot use Gradle object after build has finished
I've described the issue here https://github.com/redhat-developer/vscode-java/issues/1984
Just want see if anyone have met such issue before and any idea for a workaround?
I create a demo gradle project by Spring Initializr Java Support, with build.gradle and settings.gradle generated automatically, so when i run gradle init, it would throw > Task :init SKIPPED because settings file and build file already existed.
After i delete them manually, gradle init could be executed successfully and re-generate build.gradle and settings.gradle:
I've noticed the comment below your github issue:
This issue seems similar to another one I'm seeing with eclipse
buildship, so most likely it's an issue happening in latest gradle
version
And I'm using Gradle 7.0.2, there's no error shown. You may have a try.

Gradle sync failed: Unable to make field private static final java.util.Map java.lang.ProcessEnvironment.theCaseInsensitiveEnvironment accessible

I try to build my gradle project and I get the following error:
1:36 PM Gradle sync failed: Unable to make field private static final java.util.Map java.lang.ProcessEnvironment.theCaseInsensitiveEnvironment accessible: module java.base does not "opens java.lang" to unnamed module #7d417077 (5 s 556 ms)
build.gradle file
and no, I do not know gradle and no I am not planning on learning it, but I have no chioce. Thanks in advance
I've had a similar problem with an old BungeeCord plugin, which used Gradle 4.10. In my case - it seems like that old Gradle doesn't work properly with Java 16, so I've manually changed contents of gradle/wrapper/gradle-wrapper.properties file to use Gradle 7.0.
Old file:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
New file:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
Now it works ok, no more Gradle errors.
It seems like it can be cause by different things.
I solved it changing the JDK to the embedded android JDK and adding it to the path and JAVA_HOME environement variables.
I got this error in IntellJ when opening an Android project that someone sent me. It's a Gradle error and I'm not sure of the root cause. I think it's no Gradle JVM set in the .idea folder of whoever sent me the project.
My fix was explicitly set the Gradle JVM in IntelliJ in File -> Settings -> Build, Execution & Development -> Build Tools -> Gradle and set it to 11, or whatever. It's the same fix as another answer from me over here
I faced the same error while using a download project. Here the problem is with the version compatibility of Java and Gradle. The project was using Gradle 4.10.1 and my Gradle JDK was 17 which caused the error, I just changed my Gradle JDK to version 11. This solved the error for me.
Solution:
Go to File -> Project Structure -> Project. and note your Gradle Version. Gradle Version
Now go to this link: Compatibility Matrix - Gradle User Manual and look for a close enough Java version. Compatibility Matrix
Now go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle. Under Gradle JDK click Download JDK.Gradle JDK
Select the version and Download then Apply. Select Download
Rebuild the Project now.

gradle build error when building android project

I am trying to build a simple android project on the command line using
android create project
I am following this tutorial, and using android-sdk tools version 25.2.5 which still includes the above command. However, my gradle version is 4.8.1 and java 10.0.1.
First, I cd into my project folder and use the android command to create a project:
android create project -p . -a MainActivity -k com.test.firstapp -t "android-22" -g -v 2.3.0
This gives me a project frame. I chose the android gradle plugin version 2.3.0 based on this web page, hoping it would support all newer versions of gradle as well.
Then I try to build the project with
./gradlew build
and get my first error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '10.0.1'.
So I reckoned there must be a mismatch with the gradle version and the gradle plugin version I am using because gradle 4.8.1 should definitely support java 10.0.1. I then went and looked at my build.gradle file in the project directory and changed the android plugin version to 3.1.0, as follows:
classpath 'com.android.tools.build:gradle:3.1.0'
also adding google() to the repositories. I still got the same java version error. Now, I had a look at gradle/wrapper/gradle-wrapper.properties and saw that the distributionUrl was for gradle 1.12, so I changed it to my actual version:
distributionUrl=http\://services.gradle.org/distributions/gradle-4.8.1-all.zip
After changing the gradle version in the wrapper, I call:
gradle wrapper --gradle-version 4.8.1
as advised here. Running this, I first get a warning and and error:
Configure project :
WARNING: The specified Android SDK Build Tools version (22.0.1)
is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '22.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
File /home/user/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 27.0.3 in /opt/android-sdk/licenses
License for package Android SDK Build-Tools 27.0.3 accepted.
Preparing "Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)".
Warning: Failed to read or create install properties file.
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
* Where:
Build file '/home/user/dev/android/firstapp/build.gradle' line: 18
* What went wrong:
A problem occurred evaluating root project 'firstapp'.
> Could not find method runProguard() for arguments [false] on BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType.
I'm sure it's a mismatch of versions but could someone point out what the right combination is if I want to keep working with android-sdk tools 25.2.5?
I'm doing this on Ubuntu 16.04.
Thanks.
In the end, the combination that works for me was the following:
android sdk tools 25.2.5
android build tools 26.0.2
platform-tools 28.0.0 (uncritical in any case...)
java 8 (indeed had to downgrade)
gradle 4.8.1
android gradle plugin 3.0.1
With this combination I was able to create a project using 'android create project' and build with './gradlew build':
> android create project -p . -a MainActivity -k com.test.firstapp -t "android-22" -g -v 3.0.1
> Created directory ....
The android tool still creates some deprecated input into build.gradle, such as proguard instead of minifyEnabled, and leaves out some repositories (google(), jcenter()) that I need to find the newer gradle plugin version, among other things. Also, the gradle-wrapper.properties sill contain an outdated gradle version url but that can be changed as shown in my original question. I'm a lot closer to automating project creation from the command line than before even if it's not perfect.

Unable to build my app in API23 with volley library on windows

Build log:
:volley:javadoc
FAILURE: Build failed with an exception.
What went wrong:
Failed to capture snapshot of input files for task 'javadoc' during up-to-date check. See stacktrace for details.
Could not normalize path for file 'C:\Users\JC\AppData\Local\Android\sdk\platforms\android-23\android.jar;C:\Users\JC\AppData\Local\Android\sdk\platforms\android-23\optional\org.apache.http.legacy.jar'.
This issue is occurring only on windows. With the same setup build goes fine on mac.
Please help.
Try to update your Android SDK to api v23
Removed volley project, its dependencies in settings.gradle and build.gradle
Removed apache http legacy jar dependency
Added http://mvnrepository.com/artifact/com.mcxiaoke.volley/library/1.0.0 this jar in my build dependencies.
This built my project fine. However, its not the official volley jar.

Install Plugin jar in Grails Project?

I have a grails plugin project and want to make a jar which I then include into my grails project.
Here is the plugin project: https://github.com/ticketbis/grails-groobalize
I did:
grails package-plugin --binary
To get the file: grails-plugin-groobalize-0.1.12.jar.
In my grails project's BuildConfig.groovy I did:
dependencies {
compile "com.ticketbis:groobalize:0.1.12"
}
When I run grails refresh-dependencies I get the following error:
Error |
There was an error loading the BuildConfig: Bad artifact coordinates :groobalize:0.1.12, expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version> (Use --stacktrace to see the full trace)
How do I install the locale plugin jar into ma grails project correctly?
There are a few ways of doing this.
You can use the release plugin: https://grails.org/plugin/release
Add this plugin to your grails plugin and then do a publish. The plugin will then be added to your local maven repo.
The you could add the dependency in your main grails project as you
have already done.
Other way around is to checkout the plugin project, include the location in your main grails project like below.
BuildConfig.groovy
grails.plugin.location.'your-plugin' = "<location-your-plugin>"
This line will compile your plugin every time you compile your main grails project.
There may be other ways too.

Categories

Resources