Failed to resolve: com.nineoldandroids:library:2.4.0 in android studio project - eclipse

I exported a project from eclipse and import it to android studio.in that I added on my project the library dependency com.nineoldandroids:library:2.4.0, from the Project Structure dialog of Android Studio, but when I build the project with gradle (with the Sync Gradle button), I get the error "Failed to resolve: com.nineoldandroids:library:2.4.0" .but when i am adding that same lib dependencies to a project which i have created in android studio,there its working fine.can anyone plz help me.what is the problem?

Open your android studio,click File->Settings,in the search box type in "gradle"
On the left side,under "Build Tools",there is "Gradle",click it
Then,on the right side,you will find "Offline work",yours maybe checked,make it unchecked
Click "OK" to finish the operation
Finally Sync Project with Gradle Files again
You can have a try

Related

Eclipse Buildship Plugin: nesting source folders

I'm using Gradle Buildship plugin in order to build my Eclipse projects.
Gradle itselft is well configured. So, I'm able to build anything from shell.
The gradle project has a root folder and other subprojects.
When I click on Gradle -> Refresh Project it tells me:
Synchronize Gradle builds with workspace failed due to an unexpected error.
Cannot nest 'living_webapi/src/main/java/com/living/persistence/entities' inside 'living_webapi/src/main/java'. To enable the nesting exclude 'com/' from 'living_webapi/src/main/java'
Java Model Exception: Java Model Status [Cannot nest 'living_webapi/src/main/java/com/living/persistence/entities' inside 'living_webapi/src/main/java'. To enable the nesting exclude 'com/' from 'living_webapi/src/main/java']
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:786)
at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3097)
at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3059)
at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3112)
at org.eclipse.buildship.core.workspace.internal.SourceFolderUpdater.updateClasspath(SourceFolderUpdater.java:234)
at org.eclipse.buildship.core.workspace.internal.SourceFolderUpdater.updateClasspath(SourceFolderUpdater.java:82)
at org.eclipse.buildship.core.workspace.internal.SourceFolderUpdater.update(SourceFolderUpdater.java:261)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeOpenJavaProject(SynchronizeGradleBuildOperation.java:223)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeOpenWorkspaceProject(SynchronizeGradleBuildOperation.java:213)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeWorkspaceProject(SynchronizeGradleBuildOperation.java:186)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:176)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleBuildWithWorkspace(SynchronizeGradleBuildOperation.java:141)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.access$000(SynchronizeGradleBuildOperation.java:106)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:123)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:724)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5521)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5478)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:120)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.synchronizeBuild(SynchronizeGradleBuildsJob.java:78)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.runToolingApiJob(SynchronizeGradleBuildsJob.java:69)
at org.eclipse.buildship.core.util.progress.ToolingApiJob$1.run(ToolingApiJob.java:73)
at org.eclipse.buildship.core.util.progress.ToolingApiInvoker.invoke(ToolingApiInvoker.java:62)
at org.eclipse.buildship.core.util.progress.ToolingApiJob.run(ToolingApiJob.java:70)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
The only thing that worked for me was un-checking the "Allow output folders for source folders" option.
Steps:
Right click on project -> Properties
Click on Java Build Path in the left side of Properties popup
Click on Source tab
Un-check the "Allow output folders for source folders" checkbox
Click Apply and Close
Right click on project -> Gradle -> Refresh Gradle Project
I got this problem too.
My solution is setting project properties.
In Java build Path -> Source,set output folder to default.
For more detail,the image below.
Project Properties -> Java build path -> Source
Source folder output location

Eclipse Maven errors when I'm only using Gradle

I began to get errors after downloading Nodeclipse and creating a Gradle project with New Gradle Project -- sample project "Java Quickstart". Whenever I re-open Eclipse, I get this error:
"Updating Maven Dependencies" has encountered a problem. An internal
error occurred during: "Updating Maven Dependencies".
org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob$1
I have never used Maven, but I tried to investigate the error. When I try to open Preferences > Maven, or most (but not all) of its subfolders, I get:
Unable to create the selected preference page. An error occurred while
automatically activating bundle org.eclipse.m2e.core.ui (545).
I looked on Maven Central and there is no m2e folder in org/eclipse. I also looked in Eclipse/features for pom.xml files and I have folders starting with org.eclipse.m2e, but no org.eclipse.m2e.core.ui.
Edit:
I created a new workspace and got the same error message as soon as I created a New Gradle Project based on Java Quickstart sample project. I did this twice and the second time Eclipse logged an error. Some relevant lines from the stack trace:
Exception:org.osgi.framework.BundleException: Exception in org.eclipse.m2e.core.internal.MavenPluginActivator.start() of bundle org.eclipse.m2e.core
Exception:java.lang.NoClassDefFoundError: org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob$1
at org.springsource.ide.eclipse.gradle.core.wizards.NewGradleProjectOperation.createProjectContents(NewGradleProjectOperation.java:106)
First try to build your project from command line.
Enide 2015 by Nodeclipse has built-in Terminal Ctrl+Alt+T
run gradle build
or right-click build.gradle Run as -> gradle build
Then see and think
You are building with Gradle, so don't look at Maven preferences, but Gradle one.
Possibly you confused Gradle and Maven and made wrong preferences, you can try again in new workspace.

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

How can I build BaseGameUtils with Gradle

I had a project that was working fine until I imported the BaseGameUtils library project for use with my project.
Is it possible to continue to use Gradle to build my project? I tried the Google Play Game Services in LibGDX instructions. Even though they are for IntelliJ - I would think the instructions would work for Eclipse but they don't.
The error I get is
A problem occurred configuring project ':android'.
Configuration with name 'default' not found.
This is from adding the line compile project(":BaseGameUtils") in my :android dependencies in build.gradle.
You don't need add this project to Gradle. Just import BaseGameUtils to Eclipse, then set it as a library
Right button on BaseGameUtils > properties > Android > check "Is a library" > click ok
Then go to your Android project (not the core project)
Properties > Android > Add library > select BaseGameUtils
Try to follow LibGDX Google Play Game Services Tutorial.

Update my gradle dependencies in eclipse

I have a simple gradle project in my eclipse. I update the build.gradle to include a few apache http jars...
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile 'org.apache.httpcomponents:httpclient:4.2.3'
compile "org.apache.httpcomponents:httpmime:4.2.3"
testCompile group: 'junit', name: 'junit', version: '4.+'
}
However in my code, where I reference some Apache HTTP stuff I get:
The import org.apache.http cannot be resolved
Any tips on what I need to do to make Eclipse see the new dependencies in my build.gradle?
I tried doing a clean but that does not work. My gradle plugin is:
Gradle IDE 3.3.0.201307040643-RELEASE org.springsource.ide.eclipse.gradle.feature.feature.group GoPivotal, Inc.
You have to select "Refresh Dependencies" in the "Gradle" context menu that appears when you right-click the project in the Package Explorer.
Follow those steps to update Gradle project in Eclipse:
First, please check you have include eclipse gradle plugin. apply plugin : 'eclipse'
Then go to your project directory in Terminal. Type gradle clean and then gradle eclipse.
Then go to project in eclipse and refresh the project (Go to Project Explorer, select root of the project and hit F5 to refresh, or right click and select refresh in context menu).
Looking at the Eclipse plugin docs I found some useful tasks that rebuilt my classpath and updated the required dependencies.
First try gradle cleanEclipse to clean the Eclipse configuration completely. If this doesn;t work you may try more specific tasks:
gradle cleanEclipseProject to remove the .project file
gradle cleanEclipseClasspath to empty the project's classpath
Finally gradle eclipse to rebuild the Eclipse configuration
You have to make sure that "Dependency Management" is enabled. To do so, right click on the project name, go to the "Gradle" sub-menu and click on "Enable Dependency Management". Once you do that, Gradle should load all the dependencies for you.
I tried all above options but was still getting error, in my case issue was I have not setup gradle installation directory in eclipse, following worked:
eclipse -> Window -> Preferences -> Gradle -> "Select Local
Installation Directory"
Click on Browse button and provide path.
Even though question is answered, thought to share in case somebody else is facing similar issue.
Cheers !
In my case, I solved weird issues in Spring Tools Suite (essentially Eclipse) after I tried to upgrade Spring Boot and the changes didn't seem to be taking effect.
Right click on your project -> Gradle -> Refresh Gradle Project