maven won't compile source folder - android

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

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

Command or UI to see what is in the CrudRepository

Is there any command to execute or UI to see what is stored in my CrudRepository? I am creating a server using Spring which you can add pre-existing users or data into the database when running the server. Client (Android mobile) can also add or update the data of the repository.
Something similar to that of the client side like this:
http://www.coderzheaven.com/2012/01/23/working-with-sqlite-databases-through-command-line-in-android/
Here is my pom.xml:
<?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>
<groupId>org.springframework</groupId>
<artifactId>spring-rest-service-oauth</artifactId>
<version>0.1.0</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
<properties>
<spring-security-oauth2.version>2.0.7.RELEASE</spring-security-oauth2.version>
</properties>
<dependencies>
<dependency>
<groupId>com.squareup.retrofit</groupId>
<artifactId>retrofit</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>${spring-security-oauth2.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path-assert</artifactId>
<version>0.9.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-plugin-releases</id>
<url>https://repo.spring.io/plugins-release</url>
</pluginRepository>
</pluginRepositories>
As you can see in your pom.xml you are using HSQLDB which is an embedded database that is most likely running in-memory, started and managed automatically by your Spring Boot app.
You can visualize the content of the database using the HSQL Database Manager GUI.
See here for a HOW-TO guide: View content of HSQLDB embedded database

Importing support library appcompat to Maven project

I converted my Android project into Maven project. I have support library called appcompat_v7, which I would like to add into my Maven dependencies.
I read that I should add dependencies to pom.xml
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19.1.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19.1.0</version>
<type>jar</type>
</dependency>
Also built jar and apklib by running:
mvn install:install-file -Dfile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.aar"/ -DpomFile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.pom"/ -Dpackaging="apklib"
mvn install:install-file -Dfile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.jar"/ -DpomFile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.pom"/ -Dpackaging="jar"
My pom.xml is now following:
<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>ProjectTest</groupId>
<artifactId>ProjectTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>19.1.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>19.1.0</version>
<type>jar</type>
</dependency>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source/>
<target/>
</configuration>
</plugin>
</plugins>
</build>
</project>
I am still having error ''R cannot be resolved to a variable'' after I deleted support libraby appcompat_v7

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