How to integrate cucumber into android-maven test project? - android

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" />

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

Android Wear (Maven): No resource found that matches the given name: attr 'android:windowSwipeToDismiss'

I built an Android Wear app in Android Studio, but now decided to build it with Maven. There were no compilation errors when building in Android Studio. But now, I am facing the following error when building with Maven:
[INFO] [path-to-project]\target\unpacked-libs\com.google.android.support_wearable_aar_1.0.0\res\values\values.xml:127: error: Error: No resource found that matches the given name: attr 'android:windowSwipeToDismiss'.
[ERROR] Error when generating sources.
Here are the dependencies I am using:
<!-- Android -->
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.4W.2_r2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-v13</artifactId>
<version>21.0.0</version>
<type>aar</type>
<exclusions>
<exclusion>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- /Android -->
<!-- Android Wear Support -->
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services-wearable</artifactId>
<version>7.0.0</version>
<type>aar</type>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
<version>22.0.0</version>
<type>aar</type>
</dependency>
<dependency>
<groupId>com.google.android.support</groupId>
<artifactId>wearable</artifactId>
<version>1.0.0</version>
<type>aar</type>
<exclusions>
<exclusion>
<groupId>com.android.support</groupId>
<artifactId>recyclerview-v7</artifactId>
</exclusion>
<exclusion>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
</exclusion>
</exclusions>
</dependency>
Apparently android:windowSwipeToDismiss is not identifiable. I noticed that this attribute was added in API level 20 or so. But the target is set to 21 in my Manifest.xml. Thanks for your help!
The problem was due to the SDK version of the Android Maven Plugin. The error was happening because the sdk version was declared in Android Resources Plugin instead of AMP (typo).

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...

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