gradle fails to resolve .aar from artifactory - android

I have a project that uses my own .aar library that is uploaded on artifactory.
The .pom file seems to be correct, as I have looked at other .aar libraries available on maven central. The .pom looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>io.modum</groupId>
<artifactId>sweetblueservice</artifactId>
<version>1.15</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>27.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.android.support.constraint</groupId>
<artifactId>constraint-layout</artifactId>
<version>1.1.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.streamsupport</groupId>
<artifactId>android-retrofuture</artifactId>
<version>1.6.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.jakewharton.timber</groupId>
<artifactId>timber</artifactId>
<version>4.7.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.modum</groupId>
<artifactId>logger-utils</artifactId>
<version>0.1.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.modum</groupId>
<artifactId>sweetblue</artifactId>
<version>2.52.16</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
When I install this library in my local maven repository on my machine, I am able to get the dependency in my Android project like this:
implementation "io.modum:sweetblueservice:1.15"
But somehow, this doesn't work when the library should be resolved from Artifactory:
> Could not find sweetblueservice.jar (io.modum:sweetblueservice:1.15).
Searched in the following locations:
https://modum.jfrog.io/modum/gradle-dev/io/modum/sweetblueservice/1.15/sweetblueservice-1.15.jar
Somehow

Related

Published KMM android library won't sync with gradle

I have a KMM library for my company's project, basically it contains network API calls and userSettings, I decided to do it by using KMM mobile library project. I had no problem building and publishing it to my private maven repo but now When I want to implement the library in my android project, It gives me this error:
Failed to resolve: com.mycompany:myproject-android:0.0.1
I use MyMavenRepo for publishing and I did exactly what it said on their docs!
Here is my library's gradle configuration:
kotlin {
android {
publishLibraryVariants("release")
compilations.all {
kotlinOptions {
jvmTarget = "${Config.Jvm.target}"
useIR = true
}
}
}
...
}
publishing {
repositories.maven {
name = "myMavenRepo"
url = project.uri(Config.MyMavenRepo.url)
credentials(PasswordCredentials::class)
}
}
Here is my generated POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- This module was also published with a richer model, Gradle metadata, -->
<!-- which should be used instead. Do not delete the following line which -->
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
<!-- that they should prefer consuming it instead. -->
<!-- do_not_remove: published-with-gradle-metadata -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>myproject-android</artifactId>
<version>0.0.1</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-android</artifactId>
<version>1.4.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-android</artifactId>
<version>1.5.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-okhttp</artifactId>
<version>1.5.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>androidx.lifecycle</groupId>
<artifactId>lifecycle-viewmodel-ktx</artifactId>
<version>2.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.4.32</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core-jvm</artifactId>
<version>1.4.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-serialization-json-jvm</artifactId>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.russhwolf</groupId>
<artifactId>multiplatform-settings-no-arg-android</artifactId>
<version>0.7.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.insert-koin</groupId>
<artifactId>koin-core-jvm</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-core-jvm</artifactId>
<version>1.5.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-auth-jvm</artifactId>
<version>1.5.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-serialization-jvm</artifactId>
<version>1.5.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-logging-jvm</artifactId>
<version>1.5.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-common</artifactId>
<version>1.4.32</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-android-extensions-runtime</artifactId>
<version>1.4.32</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
Anyone knows what is the problem?
P.S: I use android studio canary 15 with AGP v7.0.0-alpha, gradle version: 7.0

No dependencies for Picasso in Android Project

I wanted to see all the dependencies in my Android project, but I came across Picasso library which does not "unfold" its dependencies.
I tried typical Gradle command among a few others
./gradlew :app:dependencies
Result is always:
+--- com.squareup.picasso:picasso:2.5.2
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.11
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.11
...
Does anybody know why there are no Picasso dependencies listed?
It is because it does not have any "compile/implementation" scoped dependencies.
You can check the pom.xml for Picasso:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.squareup.picasso</groupId>
<artifactId>picasso-parent</artifactId>
<version>2.5.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>picasso</artifactId>
<name>Picasso</name>
<dependencies>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>fest-android</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>annotations</artifactId>
<version>9.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
</plugin>
</plugins>
</reporting>
</project>
Source: https://search.maven.org/artifact/com.squareup.picasso/picasso/2.5.2/jar.
you must have exclude written in your gradle with picasso dependencies. also check if type is implementation

Gradle/Maven - Error loading aar dependency

I'm publishing an aar file to an internal maven repo, but when I try to reference it like this:
dependencies {
compile 'com.example.android:example-api:0.3-SNAPSHOT'
}
I get the following error:
A problem occurred configuring project ':sdk-sample'.
> Artifact 'com.example.android:example-api:0.3-SNAPSHOT:example-api.jar' not found.
Which is confusing to me since I do not have a jar file that I've uploaded, but an aar.
The POM file that gradle generated and uploaded looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.android</groupId>
<artifactId>example-api</artifactId>
<version>0.3-SNAPSHOT</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-rest-template</artifactId>
<version>1.0.1.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>1.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-core</artifactId>
<version>1.0.1.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
If I reference it like this:
dependencies {
compile 'com.example.android:example-api:0.3-SNAPSHOT#aar'
}
Then it finds it successfully, but then the dependencies are not downloaded properly and i get a NoClassDefFoundError at runtime when I call the methods that use the dependencies.
Any idea what's going on?
The transitive property needs to be set to true on your dependency:
compile ('com.example.android:example-api:0.3-SNAPSHOT#aar') {
transitive = true
}
It should probably be changed in Gradle to be true by default for aar dependencies (as it seems to be for jar).
I had the exact same problem. Appending "#aar" to the dependency fixed it for me. Compiling and running without problems now.

Missing artifactcom.google.android.gms:google-play-services:jar in pom.xml

I am getting below error in dependencies tag in my pom.xml file.
Missing artifact com.google.android.gms:google-play-services:jar:13.0.0
Missing artifact com.google.android.gms:google-play-services:apklib:13.0.0
Here is my Pom.xml dependencies tag, where I am getting error(Check ERROR HERE line)
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>4.1.1.4</version>
</dependency>
<dependency>
<groupId>com.google.android.maps</groupId>
<artifactId>maps</artifactId>
<version>17_r3</version>
<scope>provided</scope>
</dependency>
<dependency> //ERROR HERE
<groupId>com.google.android.gms</groupId>
<artifactId>google-play-services</artifactId>
<version>13.0.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>google-play-services</artifactId>
<version>13.0.0</version>
<type>jar</type>
</dependency>
</dependencies>
It seems that the path com.google.android.gms does not exist in the central Maven repository.
I found that I was able to resolve this by downloading the Google Repository extras package found in the Android SDK Manager. (NOTE I am using Android Studio which I believe automatically picks up this repository otherwise you may have to copy some files into your local m2 repo or configure your pom/build file accordingly :S)
It looks to install all versions of the library using an understandable semantic version (instead of their regular r13/'13.0.0` style) so you will have to set your version number accordingly (currently at version 4.2.42 at time of writing)
It would be nice if Google provided (and documented) a public repository for these artifacts, or even better had them published on maven central (as Dallas187 stated) but I'm sure there is probably some legal tarpit that they have to cross before this can happen...

How to include thridparty jars in my Android APK with android-maven?

I am using android-maven-plugin to manage my android project. But maven doesn't package the thirdparty jars when generating the apk. How should I configue the pom.xml?
I use Fat Jar, it's a eclipse plugin could help to include jar to your apk when you export.
very easy to use.
You can find it here:
http://fjep.sourceforge.net/
This example maybe can helps, on this I add ORM-Lite , ABS and JUnit libs:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>4.0.1.2</version>
<scope>provided</scope>
</dependency>
<!-- orm-lite dependecies -->
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-android</artifactId>
<version>4.35</version>
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-core</artifactId>
<version>4.35</version>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>library</artifactId>
<version>4.1.0</version>
<type>apklib</type>
</dependency>
</dependencies>
</dependencyManagement>

Categories

Resources