Accessing dependency from Remote Server - java

I've hosted a dependency in my gitlab repository that I'm trying to access in another project. I've provided the path of my repository in the root build.gradle of another project however for some reason the URL that is generated by gradle to fetch the dependency is invalid. I've been trying to figure out what I might be doing wrong but so far I couldn't pin point the problem.
I'm posting the gradle code for generating the aar file and the code which tries to fetch this dependency in another Android app.
Library build.gradle file:
publishing {
publications {
maven(MavenPublication) {
groupId 'com.umer' //You can either define these here or get them from project conf elsewhere
artifactId 'myLibrary'
version project.version
artifact "$buildDir/outputs/aar/myLibrary-release.aar" //aar artifact you want to publish
//generate pom nodes for dependencies
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.compile.allDependencies.each { dependency ->
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dependency.group)
dependencyNode.appendNode('artifactId', dependency.name)
dependencyNode.appendNode('version', dependency.version)
}
}
}
}
//publish to filesystem repo
repositories{
maven {
url "C:\\Users\\Umer\\AndroidStudioProjects\\android\\myLibrary\\artifacts"
}
}
}
App Level build.gradle of Android App:
dependencies {
provided ('com.umer.myLibrary:myLibrary-1.1')
}
Android app root build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
maven {
url 'http:/GIT_LAB_IP_ADDRESS/dev/myLibrary/tree/BRANCH_NAME/artifacts'
credentials {
username = "myUserName"
password = "myPassword"
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle.properties of Android App:
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyPort=12345
org.gradle.jvmargs=-Xmx1536m
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=12345
Gradle Sync Error in Android App Project:
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.umer.myLibrary:myLibrary-1.1:.
Could not resolve com.umer.myLibrary:myLibrary-1.1:.
Required by:
project :app
> Could not resolve com.umer.myLibrary:myLibrary-1.1:.
> Could not get resource 'http://GIT_LAB_IP_ADDRESS/dev/myLibrary/tree/remoteRepoPublication/artifacts/com/umer/myLibrary/myLibrary-1.1//myLibrary-1.1-.pom'.
> Could not HEAD 'http://GIT_LAB_IP_ADDRESS/dev/myLibrary/tree/remoteRepoPublication/artifacts/com/umer/myLibrary/myLibrary-1.1//myLibrary-1.1-.pom'.
> Connect to 127.0.0.1:12345 [/127.0.0.1] failed: Connection refused: connect
> Connection refused: connect
How can I fix it?
PS:
This is the malformed URL generated by Gradle in Android app.
http://GIT_LAB_IP_ADDRESS/dev/myLibrary/tree/remoteRepoPublication/artifacts/com/umer/myLibrary/myLibrary-1.1//myLibrary-1.1-.pom

By looking at the malformed url:
'http://GIT_LAB_IP_ADDRESS/dev/myLibrary/tree/remoteRepoPublication/artifacts/com/umer/myLibrary/myLibrary-1.1//myLibrary-1.1-.pom'
It looks like you have 2 issues:
1. You need to replace the GIT_LAB_IP_ADDRESS with the real host name / ip. For this you can use double quotes & the $ sign as place holder:
"http://${GIT_LAB_IP_ADDRESS}/dev/myLibrary/tree/remoteRepoPublication/artifacts/com/umer/myLibrary/myLibrary-1.1//myLibrary-1.1-.pom"
where GIT_LAB_IP_ADDRESS is either loaded from local.properties or defined in build.gradle file.
Looks like you have another // in your url, right before the last part (unless its a typo)
Hope this helps.

Related

Cannot load library from MavenLibs repository

I want to use the JNoise library. Here's what I found: https://mavenlibs.com/maven/dependency/de.articdive/jnoise
But when I try
implementation 'de.articdive:jnoise:3.0.2'
in my build.gradle I get an error that the artifact is not found. Maybe I need to connect MavenLibs?
repositories {
mavenCentral()
maven {
url "https://mavenlibs.com/maven"
}
}
It didn't help

A problem occurred configuring root project 'DaggerTest'. > Could not resolve all artifacts for configuration ':classpath'

After a while, I opened Android Studio and created a project called 'DaggerTest'. Unfortunately, when my Gradle is getting built, I face this error
A problem occurred configuring root project 'DaggerTest'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find bundletool-1.1.0.jar (com.android.tools.build:bundletool:1.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/1.1.0/bundletool-1.1.0.jar
> Could not find transform-api-2.0.0-deprecated-use-gradle-api.jar (com.android.tools.build:transform-api:2.0.0-deprecated-use-gradle-api).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/transform-api/2.0.0-deprecated-use-gradle-api/transform-api-2.0.0-deprecated-use-gradle-api.jar
> Could not find jetifier-processor-1.0.0-beta09.jar (com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta09).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/jetifier/jetifier-processor/1.0.0-beta09/jetifier-processor-1.0.0-beta09.jar
> Could not find jetifier-core-1.0.0-beta09.jar (com.android.tools.build.jetifier:jetifier-core:1.0.0-beta09).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/jetifier/jetifier-core/1.0.0-beta09/jetifier-core-1.0.0-beta09.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Here are the things that I have done and they did not work:
I allowed Android Studio(studio.exe, studio64.exe) and all java executable files in the windows firewall
I have disabled the windows firewall and it did not work.
I have tried some proxies in Android Studio HTTP proxy settings
I have changed my build Gradle file from this:
buildscript {
repositories {
google() // <-- here
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0-beta03'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
To this:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0-beta03'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Could not find com.android.tools.build:gradle:3.5.1

I'm totally new to android studio and came up to this error that says it can not download gradle-3.5.1.pom and gradle-3.5.1.jar from google or jcenter repositories. But when I tried downloading them manually it was easy and straight forward though.
Here is the error text :
ERROR: Could not find com.android.tools.build:gradle:3.5.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.pom
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.jar
Required by:
project :
Open File
I know that this is going to make me crazy because these gradle stuff always been a problem to all.
Make sure you have google() repo in your project's level build.gradle file.
Here's an example:
build.gradle
buildscript {
repositories {
google() // check if you have this
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
}
}
allprojects {
repositories {
google() // and this
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Disable Offline Work in Android studio if you have enabled the checkbox and sync project.
Once the project is synced, you can enable the checkbox and run the app as long as you do not add another dependency manually.
It will automatically download the required dependencies.
File>Settings>Build>Gradle

Gradle build failed to resolve library

I am working on android (Java) and trying to consume websockets so I thought I would use this tutorial and they are using dependency org.java-websocket:Java-WebSocket:1.3.0 from this repo which has now become 1.3.1.
So I have in my modular build.gradle
dependencies {
...
compile 'org.java-websocket:Java-WebSocket:1.3.1'
...
}
and in my project / top level build.gradle I have
repositories {
jcenter()
maven { url 'http://clojars.org/repo' }
}
and I am getting error
Error:(49, 13) Failed to resolve: org.java-websocket:Java-WebSocket:1.3.1
Try it with lowercase:
compile 'org.java-websocket:java-websocket:1.3.1'
It worked for me.
Edit:
the project level gradle file:
buildscript {
repositories {
jcenter()
maven { url 'http://clojars.org/repo' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
maven { url 'http://clojars.org/repo' }
}
}
I was also facing same issue ,I restarted Android Studio and sync again,it build successfully.

An error occurred configuring root project 'BoomMenu-master'

When I am importing the project, I am getting the following error:
Error:A problem occurred configuring root project 'BoomMenu-master'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4.
Required by: :BoomMenu-master:unspecified
> No cached version of com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4 available for offline mode.
> Could not resolve com.github.dcendents:android-maven-gradle-plugin:1.3. Required by:
:BoomMenu-master:unspecified
> No cached version of com.github.dcendents:android-maven-gradle-plugin:1.3 available for
offline mode.
There are some solution which i had applied previously that ,
1 . Try to rebuild your project for 2 to 3 times.
2 . Open your build.gradle file and then add line at top that these lines ,here you must choose build gradle version according to your sdk .
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
3. Open your library build.gradle file say in yours you must open boommenu file .
add these lines at top ,
apply plugin: 'com.android.application'
4.Try to changed proxyPort to 8080 and used jcenter instead of Maven. But i had to apply expeption to use HTTP instead of HTTPS. This is what i have in my gradle.build for build script and allprojects
buildscript {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
}
allprojects {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
}

Categories

Resources