Gradle error: Could not find org.apache.httpcomponents:httpclient-android:4.3.5.1 - maven

I'm trying do use the Apache httpclient for Android in my Gradle project and I don't understand why I get this error when running ./gradle build:
Could not find org.apache.httpcomponents:httpclient-android:4.3.5.1.
My top-level build.gradle contains:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
My project build.gradle starts with:
apply plugin: 'com.android.application'
dependencies {
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':workspace:google_play_services:libproject:google-play-services_lib')
}
What's wrong with that?
In The Central Repository Browser of Maven the package I need is listed:
http://search.maven.org/#browse|-305040853

You have to add in your project build.gradle
repositories {
mavenCentral()
}
If you would like to put it in the top level file you can add this in the top level build.gradle:
allprojects {
repositories {
mavenCentral()
}
}

Related

Trying to add timber to Kotlin project results in multiple 'Unable to resolve dependency for...' Gradle errors

I have added implementation 'com.jakewharton.timber:timber:4.7.1' to my Kotlin project and now I get the following Gradle errors:
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.jakewharton.timber:timber:4.7.1.
Open File
Show Details
Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve com.jakewharton.timber:timber:4.7.1.
Open File
Show Details
Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve com.jakewharton.timber:timber:4.7.1.
Open File
Show Details
Unable to resolve dependency for ':app#release/compileClasspath': Could not resolve com.jakewharton.timber:timber:4.7.1.
Open File
Show Details
Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve com.jakewharton.timber:timber:4.7.1.
Open File
Show Details
Strangely though I can see it downloading as Gradle syncs:
I also tried adding timberkt but got a similar error.
My whole app/build.gradle file looks like this:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlinx-serialization'
android {
compileSdkVersion 26
defaultConfig {
applicationId "uk.co.davechambers.pegboard"
targetSdkVersion 26
minSdkVersion 21
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary= true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
google()
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx" }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:26.0.0-beta2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-vector-drawable:26.0.0-beta2'
implementation 'com.jakewharton.timber:timber:4.7.1'
compile "org.jetbrains.anko:anko:$anko_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
}
kotlin {
experimental {
coroutines "enable"
}
}
androidExtensions {
experimental = true
}
Clearly I'm doing something wrong. Can anybody point me in the right direction?
I added an additional Maven url to build.gradle (Module: app):
repositories {
google()
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "http://jcenter.bintray.com"}
}
and to build.gradle (Project: projectName):
buildscript {
ext.kotlin_version = '1.2.40'
ext.anko_version = '0.10.5'
ext.serialization_version = '0.4.1'
repositories {
google()
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "http://jcenter.bintray.com"}
}
.....
After that, everything worked.

Plugin with id 'com.wonbin.myplugin' not found

I wrote a demo for learning gradle for android . i used the JAR
1) project root dir build.gradle
buildscript {
repositories {
jcenter()
flatDir {dirs 'build_libs'}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.wonbin.myplugin:MyPlugin:1.0'
}
}
apply plugin: 'com.wonbin.myplugin'
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have leanrd that the plugin id is the properties filename in the plugin project. But still when I run ./gradlew assemble , it happens:
Build file '/home/wonbin/MyApp/build.gradle' line: 13
What went wrong: A problem occurred evaluating root project 'MyApp'.
Plugin with id 'com.wonbin.myplugin' not found.
what should i do ?
Probably your build_dir doesn't correspond to the correct file structure. You can reference your jar in the classpath directly instead, like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath file('/path/to/your/plugin.jar')
}
}
apply plugin: 'com.wonbin.myplugin'

Building a fully executable Spring Boot 1.3 war from a Gradle multi project build

I'm trying to build a fully executable WAR using Spring Boot 1.3 as per https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html. If I build a single Gradle project, it all works fine, but I havea multi project build, where I have a "root" project and then several projects underneath it, and I cannot get it to build anything but a standard, "fat" WAR file, without the providedRuntime of Jetty and without the scripts to make it run.
Does anyone know how to do this?
In my root project, I have the following (abridged):
buildscript {
repositories {
mavenCentral()
}
ext {
springBootVersion = '1.3.0.RELEASE'
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
}
}
allprojects {
//Put instructions for all projects
repositories {
mavenCentral() // jcenter is missing spring-orm.4.1.6.RELEASE jar file so try mavenCentral first
jcenter {
url "http://jcenter.bintray.com/"
}
maven { url 'http://repo.opensourceagility.com/release' }
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'spring-boot'
}
and then in the subproject which is a web project, and which I'm trying to build, I have:
apply plugin: 'war'
dependencies {
// Include related projects
compile project(':project-model')
compile project(':project-dynamoDB')
// Core Spring Boot - note version is set in main build.gradle file
compile 'org.springframework.boot:spring-boot-starter-web'
// Remove Tomcat (included in -web) and include Jetty instead
providedRuntime 'org.springframework.boot:spring-boot-starter-jetty'
// Other Spring modules
compile 'org.springframework.boot:spring-boot-starter-social-facebook'
compile 'org.springframework.boot:spring-boot-starter-social-linkedin'
compile 'org.springframework.social:spring-social-google:1.0.0.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-devtools'
compile 'org.springframework:spring-context'
compile 'org.springframework:spring-context-support'
}
configurations {
providedRuntime.exclude group: 'org.springframework.boot', module:'spring-boot-starter-tomcat'
all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' // exclude when using log4j
}
springBoot {
mainClass = 'rs.web.Weblication'
executable = true
}
bootRun {
addResources = true
}
processResources {
// exclude resources if they look like they're profile dependent but don't match the current env/profile
eachFile { d ->
if(d.name.endsWith('.xml') || d.name.endsWith('.yaml') || d.name.endsWith('.properties')) {
//def fname = d.name.replaceFirst(~/\.[^\.]+$/, '')
//if(fname.indexOf("-") > -1 && ! fname.endsWith("-" + environment)) {
// d.exclude()
//} else {
// replace #variables# listed below in properties/config files
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [
activeProfiles: environment
])
//}
}
}
}
war {
baseName = 'project-web'
version = '1.0.0'
manifest {
attributes 'Implementation-Title': baseName,
'Implementation-Version': version
}
webXml = file('src/main/resources/web.xml')
// rename the war task which has profiles appended from warName-profile,profile2.war
// to warName-profile.profile2.war
classifier = environment.replaceAll(',','-')
}
but when I build it (./gradlew build, or ./gradlew subprojectname:build), all is well and a working WAR is created, but not an executable one.
With a single project, I have it working fine.
Ah ha, right well I build a test multi-project build and it worked OK, so it was clearly the configuration above.
I worked through a process of elimination and it turns out that the problematic area was the line
classifier = environment.replaceAll(',','-')
which is intended to rename files with environment variables as part of the name. This process seems to get in the way of the script addition; perhaps it could be applied afterwards if it's really necessary.

gradle Could not resolve all dependencies for configuration ':compile'

I have a dependencies problem I need help with.
I can build EGLSource fin on its own.
But when i try to build EGL2JS then I get this error:
Error message:
:compileJava
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not find :swt-64:.
Searched in the following locations:
https://repo1.maven.org/maven2//swt-64//swt-64-.pom
https://repo1.maven.org/maven2//swt-64//swt-64-.jar
Required by:
:EGL2JS:unspecified > EGL2JS:EGLSource:unspecified
Build and settings files for the two projects: EGLSource and EGL2JS.
EGL2JS: settings.gradle
include ':EGLSource'
project(':EGLSource').projectDir = new File(settingsDir, '../EGLSource')
EGL2JS: build.gradle
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile project(':EGLSource')
}
sourceSets {
main {
java.srcDirs = ['src', 'target/generated-sources']
}
}
EGLSource: build.gradle
apply plugin: 'java'
repositories {
flatDir {
dirs 'lib'
}
}
dependencies {
compile name: 'swt-64'
}
sourceSets {
main {
java.srcDirs = ['src', 'target/generated-sources/antlr4']
}
}
Why is EGL2JS complaining about a dependency in EGLSource?
I could add the swt-64.jar to EGL2JS. But EGL2JS does not directly depend on swt-64.jar so I don't like that solution.
Are there other ways to resolve this dependency?
For reasons I don't understand this makes a difference.
Removing flatFile from repositories
and changing dependencies
from:
compile name: 'swt-64'
to:
dependencies {
compile fileTree(dir: 'lib', include: 'swt-64.jar')
}
Also gradle dependencies not longer shows swt-64 failed.

Gradle fails to create Eclipse project files

I am trying to start a new Java EE project with Gradle. I have everything close to the way I want it, and im trying to build the eclipse files. The problem is when i run the command gradle eclipse the eclipse plugin creates the eclipse files for the bottom level project, but not the subprojects.
my folders look like this
foobar
--ear
--ejb
--spring
--web
build.gradle
settings.gradle
even if i do gradle ejb:eclipse everything appears to run correctly, i get the notices that the eclipse tasks ran in the console, but no files in the ejb project.
here is my build.gradle. What am i doing wrong?
configure(allprojects){ project ->
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.6
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: "C:/IBM/WebSphere/AppServer/8.5/plugins/", include: [
'com.ibm.ws.runtime.jar',
'com.ibm.ws.wsadie/marshall.jar'
])
compile fileTree(dir: "C:/IBM/WebSphere/AppServer/8.5/runtimes/", include: [
'com.ibm.jaxrs.thinclient_8.5.0.jar',
'com.ibm.jaxws.thinclient_8.5.0.jar',
'com.ibm.ws.ejb.embeddableContainer_8.5.0.jar',
'com.ibm.ws.ejb.thinclient_8.5.0.jar',
'com.ibm.ws.jpa.thinclient_8.5.0.jar',
'com.ibm.ws.orb_8.5.0.jar'
])
}
ext {
easymockVersion = '3.3.1'
jeeVersion = '6.0'
junitVersion = '4.12'
springVersion = '4.1.5.RELEASE'
swaggerVersion = '1.3.12'
}
}
project('ear'){
description = "The EAR Project"
apply plugin: 'ear'
dependencies {
deploy project(':ejb')
deploy project(':spring')
deploy project(path: ':web', configuration: 'archives')
}
}
project('ejb'){
description = "The EJB Project"
dependencies {
compile project(':spring')
}
}
project('spring'){
description = "The Spring BL Logic"
dependencies {
runtime "org.springframework:spring-jdbc:$springVersion"
testCompile "junit:junit:$junitVersion"
testCompile "org.easymock:easymock:$easymockVersion"
testCompile "org.springframework:spring-test:$springVersion"
}
}
project('web'){
description = "The REST layer"
apply plugin: 'war'
dependencies {
compile project(':ejb')
runtime "com.wordnik:swagger-annotations:$swaggerVersion"
runtime "com.wordnik:swagger-core_2.10:$swaggerVersion"
runtime "com.wordnik:swagger-jaxrs_2.10:$swaggerVersion"
}
}
This is the output i get. It tells me the plugin fired for the subprojects but i can't figure out why it doesn't create any files
$ gradle eclipse
:eclipseClasspath
:eclipseJdt
:eclipseProject
:eclipse
:ear:eclipseClasspath
:ear:eclipseJdt
:ear:eclipseProject
:ear:eclipse
:ejb:eclipseClasspath
:ejb:eclipseJdt
:ejb:eclipseProject
:ejb:eclipse
:spring:eclipseClasspath
:spring:eclipseJdt
:spring:eclipseProject
:spring:eclipse
:web:eclipseClasspath
:web:eclipseJdt
:web:eclipseProject
:web:eclipse

Resources