Published KMM android library won't sync with gradle - android

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

Related

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 fails to resolve .aar from artifactory

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

How to integrate cucumber into android-maven test project?

I would like to integrate cucumber into an android-test project which uses maven as a build system.
The test-project is separated from the main project, and it only contains the robotium-based functional tests. I followed this tutorial and the examples here, but during the testing phase I got: 0 tests found..
Any ideas? Thanks in advance.
Erik.
I don't recommend this links, but please mind that you have to make all of cucumber dependency to compile scope. Use Junit4 which going to give duplicationDependency, but use this command to build:
build command: mvn clean install -Dandroid.extractDuplicates=true
part of pom.xml
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>compile</scope>
</dependency>
<!-- cucumber -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-android</artifactId>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-html</artifactId>
<version>0.2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.1.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
part of AndroidManifest.xml content (application's id, what you want to be tested com.myproject.android):
<instrumentation
android:name="cucumber.api.android.CucumberInstrumentation"
android:targetPackage="com.myproject.android" />

maven won't compile source folder

I switched from ant to maven to build android project. But i found it quite hard to config my previous ant project with android-maven plugin. After i config this project just the same as official sample project, everything works find except the source fold under main project haven't been compiled. I have checked the pom.xml for many times, but the same pom.xml under sample project works fine but not in my own project.
I found the src not compiled by checking the classes folder in target folder.
Here is my pom.xml:
http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.jayway.maven.plugins.android.generation2.samples.libraryprojects
libraryprojects-parent
1.0.0-SNAPSHOT
com.jayway.maven.plugins.android.generation2.samples.libraryprojects
libraryprojects-mainapp
apk
Library Projects - Main App
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>lib5</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/imageloader-core.jar</systemPath>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>lib2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/baidumapapi.jar</systemPath>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>lib6</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/locSDK_3.3.jar
</systemPath>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>lib8</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/umeng_sdk.jar
</systemPath>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>androidv4</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/android-support-v4.jar
</systemPath>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>lib9</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/weibo.sdk.android.sso.jar
</systemPath>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>pulltorefresh</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>libraryprojects-lib1</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>libraryprojects-lib2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<!--<dependency>-->
<!--<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>-->
<!--<artifactId>libraryprojects-lib3</artifactId>-->
<!--<version>1.0.0-SNAPSHOT</version>-->
<!--<type>apklib</type>-->
<!--</dependency>-->
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>libraryprojects-lib4</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>libraryprojects-lib5</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<!--<dependency>-->
<!--<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>-->
<!--<artifactId>libraryprojects-lib7</artifactId>-->
<!--<version>1.0.0-SNAPSHOT</version>-->
<!--<type>apklib</type>-->
<!--</dependency>-->
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>libraryprojects-lib8</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>slidingmenu</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>libraryprojects-lib10</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>${project.baseDir}</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
It seems that is caused by the source directory hierarchy isn't suitable for maven.
For normal android project the src hierarchy is src/com/a/b, but for maven is `src/main/java/com/a/b'.

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