Your project should have a settings.gradle - flutter

Hi I'm try to build a flutter app on git lab and every time its fails and show me the Error below:
Executing Gradle tasks as part of a build without a settings file
is not supported. Make sure that you are executing Gradle from a
directory within your Gradle project. Your project should have a
'settings.gradle(.kts)' file in the root directory.
I changed the location of the file setting.gradle and not work
any help??
the root of gradle

After searching and going through various trial and error methods, I finally tried the gradle init command and it fixed the issue. Alththough the settings.gradle file was already present but somehow its not seen by gradle itself, and initializing gradle fixed the error for me.

Related

Maven dependencies are downloaded but eclipse won't resolve them

A multi-module maven project will be buit successfully from the command line using mvn clean install and is loaded successfully in vscode without any compilation errors.
When the same project is opened in Eclipse (version Version: 2022-09 (4.25.0), Build id: 20220908-1902), I see compilation errors for dependencies not resolved for example:
The import com.ibm cannot be resolved
I tried everything to resolve this error, nothing worked, for example:
Update maven project
Project / Clean
Remove maven feature, delete the project, reimport, and convert back to maven
The strange thing is that if I delete the repository folder from <user-home>\m2.\repository and make a simple change to any pom.xml file, the entire repository folder is downloaded. Also, I located the JAR file using VSCode (ctrl-click) and I can see the related JAR logEnglish-1.0.jar in the local .m2 repository folder <user-home>\.m2\repository\logEnglish\logEnglish\1.0\logEnglish-1.0.jar.
The problem is that only Eclipse is reporting compilation errors and a lot or maybe all of the maven dependencies are not resolved. This is also affecting the debugging option and it breaks due to such compilation errors.
Another thing I noticed is that the Maven Dependencies folder is not showing on the Project Explorer no in Package Explorer, but I can see Maven Dependencies entry in Project Properties -> Configure Build Path -> Libraries.
Please help resolve this issue so that I can clear the compilation errors in Eclipse.
Update 1:
I created a simple parent/child pom with one inner module. I was able to reproduce the problem right away.
See attached snapshots for details.
The compile errors will show only when you open the parent project. If you open the inner module directly as a separate project, no compile errors will show and I can run and debug the project. However, if I try to debug the parent project, I will get a warning due to compile errors, and I can run the project only and only after I added the jar of the inner module to the classpath of the debug configuration. If I don't add the jar file, I will get this error Error: Could not find or load main class training.FirstProjectClass. The project is being built successfully using mvn clean install and that's why I can run the project. If I run mvn clean then I cannot run the parent project.
Also, notice how the maven dependencies folder will show if you open the inner project directly, but, it won't show if you open the parent project.
In addition, I noticed if I add the inner project to the classpath of the debug config then it works also without building the project and without generating the jar file using mvn clean install.
Based on the above, the problem boils down to:
How we can resolve the dependencies of the inner modules when you open the project using the parent maven project?
If we can resolve the errors, then we can run without seeing the warning, and we have the assurance that the project is clear before running the mvn clean install command.

gradle.properties in project build directory not read via Eclipse/Buildship - command line works fine

I use the latest Eclipse (version 4.12) with Buildship Gradle Integration 3.0.
I can see the tasks in the Gradle Tasks view, but I cannot run the tasks successfully.
When I run a task from the command line then it works fine.
When I run a task by double clicking the task in the Gradle Tasks view then the task fails with the following error message:
java.lang.IllegalArgumentException: Pfad[src] existiert nicht.
This translates to
java.lang.IllegalArgumentException: Path[src] does not exist.
src is a directory defined in the project's gradle.properties file as follows:
GEN_ROOT_PATH=src
The project's gradle.properties file is in the same directory as the build.gradle script.
In the build.gradle file I refer to the property as project.GEN_ROOT_PATH
I believe that is what is what the exception complains about when I run the task from the Gradle Tasks view.
I do not understand, and I could not find helpful information in the internet to solve this issue.
As I said before, the tasks can be run successfully in the command line.
The tasks fail when run in Eclipse. Does anyone have an idea what the issue can be? How can I approach a possible solution?

Error while cloning flutter project from Github

I am trying to clone the following Flutter project from Github.
https://github.com/rxlabz/flutter_dropcity
But I am getting the following error in build.gradle using VS Code terminal.
What went wrong: A problem occurred evaluating root project 'android'.
A problem occurred configuring project ':app'.
Failed to notify project evaluation listener.
com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V
Please help me out here. Thanks in advance!
It seems from the discussion at https://github.com/flutter/flutter/issues/10236 that the problem can be fixed with using a newer build version.
For this go to build.gradle file in Android/gradle folder. Now change android build.gradle version from 2.2.3 (as in the original github repo) to 2.3.3 like so:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}

Running gradle tasks from a subproject with unknown root

I have a multi-project setup in gradle with a somewhat-flat structure like so:
RootProject/
build.gradle
settings.gradle
SubProjectA/
build.gradle
anotherDirectory/
SubProjectB/
build.gradle
SubProjectC/
build.gradle
The root project is really just a root build. It's there to tie all of the other projects together. SubProjectB depends on SubProjectC, and C depends on A.
Running tasks from the root project works as expected. I can run gradle :SubProjectB:build and it will build SubProjectB and its dependencies without error.
My problem is that if I try to run a task from a sub-project's directory, it fails if that sub-project depends on any of the other sub-projects because it doesn't know where any of the others are without the root project's settings file. So running A's build from its directory would work, but running B's or C's would fail.
Is there anything I can do within this structure to define what the root project actually is, so that if I run gradle build from B, it would behave the same as running gradle :SubProjectB:build from the root project's directory?
The end goals are to make it easier to use gradle from the command line, and to get functional default tasks on the sub-projects. That way I should be able to double-click a project Eclipse's Gradle tasks list, and have it run the default tasks as though it were running the tasks from root.
In this case, you can use composite builds. Let say you are at SubProjectA and want to build against SubProjectB. The you can execute the command below:
gradle --include-build ../anotherDirectory/SubProjectB run
SubProjectB will build first and then SubProjectA.

Eclipse Gradle Plugin 'could not fetch model of type'

I am running Eclipse Luna on OS X with Gradle IDE 3.6.1 and anytime I try to select a project from the gradle tasks panel I get the following error:
org.eclipse.osgi.internal.framework.EquinoxConfiguration$1
Could not fetch model of type 'EclipseProject' using Gradle distribution
'https://services.gradle.org/distributions/gradle-2.0-bin.zip'.
Has anyone else run into this error? I can get to the URL specified to download the file myself. So, network connectivity shouldn't be the problem.
The problem is for the java version configured by default on the IDE (Eclipse or Spring Tool Suite). The error is the following:
To fix it, you can set the Java version supported by the Gradle version in Configure Workspace Setting option.
Finally, you can refresh your project o continue with your creation. Later all will be perfect.
I had the same error in Eclipse Neon (version numbers were different, but otherwise same error). It looks like several different things can cause this error, but for me it was an incorrect property in [MyProject]/.settings/org.eclipse.buildship.core.prefs.
I had
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
but it needed to be
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(2.13))
2.13 should be replaced with whatever version number output you get from gradle -version.
Coming back to add this:
It turns out, the actual root problem was an incompatibility between Gradle versions. My build.gradle file worked fine with an old version of Gradle, but uses things that were deprecated and removed in later versions.
Solution is to click Finish immediately in the wizard instead of Next, and then fix the issues in the build.gradle.
Bad reference in config.
Overwrite configuration:
Project -> Properties -> Gradle -> Override workspace settings ->
Specific Gradle version -> 4.x
You need to update Gradle
Goto:
Select 'Help > About Eclipse' (on Macs this is 'Eclipse > About Eclipse').
Click the 'Installation Details' button to display the installation details dialog. Look in the 'Installed Software' tab to see all the installed plugins.
Search for Gradle(Eclipse Plug-ins for Gradle) and Update.
It might take some time for first time after that.
Reason why it happens, cause new version of gradle is available to download. Once you download new version of gradle, your error will go away.
http://gradle.org/downloads
I had the same error message using Eclipse 4.5
In my case the build file was having a error and I had to modify this line
eclipse.classpath {
plusConfigurations += configurations.providedCompile
}
into this
eclipse.classpath {
plusConfigurations += [configurations.providedCompile]
}
After that everything worked again.
I met the same problem, somebody suggested that the gradle project may be build by a old version.
I solve the problem by the following step:
modify the configuration in Eclipse, perfrence ->gradle ->gradle distribution . point it to an older version.
delete the file in ./gradle/wrapper
reload the program
In my case, I forgot to put ending apostrophe ' for a value
I ran into a similar issue recently - even blowing away the project and repulling a fresh copy from git didn't fix it. I realized it wasn't specific to the project when I reproduced it outside of Eclipse:
$ ./gradlew tasks
FAILURE: Build failed with an exception.
* What went wrong:
Expecting a stack map frame
Exception Details:
Location:
build_euvk0e0guiuwrf8fgn8svi2fy.run()Ljava/lang/Object; #16: aconst_null
Reason:
Error exists in the bytecode
Bytecode:
0x0000000: 2abb 0022 592a 2ab7 0025 ba00 3300 00b0
0x0000010: 01b0
What did fix it was removing the gradle cache:
$ rm -r ~/.gradle/caches
$ ./gradlew tasks
Somehow the version of gradle there had become corrupted (possibly related to Eclipse groovy plugin - I had this issue regularly until uninstalling it), and blowing it away forced it to get a fresh copy.
Hopefully this answer helps someone else avoid pulling out their hair.
I had a very similar issue and removing the following from my build.gradle fixed it. The same bit of config works in all other Gradle projects I have but for some reason not this one...
allprojects {
...
apply plugin: 'eclipse-wtp'
...
// remove this eclipse config to make the error go away
eclipse {
classpath { defaultOutputDir = file('build-eclipse') }
}
...
}
Open the CMD and enter there gradle --gui, change the settings of the gradle gui in the register Setup to Stack trace Output: Full Stack trace [-S] and the log level to info. Then change the current directory to the directory your build.gradle file is located and then go to the first register and let process the gui this files.
An error message should be displayed. There you find out what is wrong with your build.gradle file. In my case there was a folder missing and this causes this error.
This error can also be caused by a syntax error in the previous line of build.gradle. If so, the error has nothing to do with the Gradle or Eclipse version you are running. See this question
In my case i changed the Gradle version from 4.7.rc2 to4.6 and then it started to work.
I am on eclipse Oxygen (4.7.2), I was getting similar exception while importing the project and this worked for me:
While importing on windows Import Options
Click Configure Workspace Setting (which will take to preference window)
Select Local Installation directory (for me 'graddle wrapper' was selected)
apply, close and continue import
Below is the error I was getting
Loading Gradle project preview failed due to an error in the referenced Gradle build.
Could not fetch model of type 'GradleBuild' using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.5-bin.zip'.
_BuildScript_
org.gradle.tooling.BuildException: Could not fetch model of type 'GradleBuild' using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.5-bin.zip'.
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
at Caused by: java.lang.ClassNotFoundException: _BuildScript_
at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler$ScriptClassLoader.loadClass(DefaultScriptCompilationHandler.java:386)
... 77 more
None of the solutions worked for me and I'm having the same errors on STS 4 with eclipse Version: 2.2.600.v20190605-1800. My steps were:
Delete the project from my workspace
./gradlew cleanEclipseWtp cleanEclipse eclipseWtp eclipse
Import the project as an existing eclipse project (not an existing gradle import)
That worked!
Deleting .gradle folder from the project resolved my problem.
I got this error with Eclipse 2021-06, Java 1.8.0, gradle 4.4.
I tried deleting gradle wrapper binary folder, predefining gradle version, etc.
The thing that helped was just specifying gradle home directory and java home directory after selecting overriding workspace configuration.
Eclipse 4.4.1 broke Gradle Eclipse support with non-string values in system properties.This is fixed in the latest Gradle for the 3.6.2 release. Update your Gradle form this update-site: http://dist.springsource.com/snapshot/TOOLS/gradle/nightly