I have main root project let's call it as A where is pom.xml with list of all modules and type of packaging pom
<?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>com.example</groupId>
<artifactId>A</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<properties>
<android.version>4.1.1.4</android.version>
<android.target.version>17</android.target.version>
<android.plugin.version>3.6.0</android.plugin.version>
<android.roboelectric.version>2.2</android.roboelectric.version>
<android.support.version.4>r7</android.support.version.4>
</properties>
<modules>
<module>AA</module>
<module>AB</module>
</modules>
This project has two children lest say project AA and AB also with poms
project AA is packaging type apklib and has nop problems with compilation installation also over android-maven-plugin (android:apklib) here is pom
<?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.example</groupId>
<artifactId>A</artifactId>
<version>0.0.1</version>
</parent>
<groupId>com.example</groupId>
<artifactId>AB</artifactId>
<packaging>apklib</packaging>
<build>
<finalName>${project.artifactId}-${project.parent.version}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>17</platform>
<path>${env.ANDROID_HOME}</path>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
project AB has dependency to project AA in pom like bellow
<?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.example</groupId>
<artifactId>A</artifactId>
<version>0.0.1</version>
</parent>
<groupId>com.example</groupId>
<artifactId>AB</artifactId>
<packaging>apklib</packaging>
<dependencies>
<dependency>
<groupId>com.examplet</groupId>
<artifactId>AA</artifactId>
<version>0.0.1</version>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>17</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
During packaging or even android:apklib I'm geeting error something like this
Failed to execute goal on project util: Could not resolve dependencies
for project com.example.AB:apklib:0.0.1: Failed to collect
dependencies for [com.example.AA:apklib:0.0.1 (provided)]: Failed to
read artifact descriptor for com.example.AA:apklib:0.0.1: Could not
find artifact com.example:A:pom:0.0.1 in central
(http://repo.maven.apache.org/maven2) -> [Help 1]
I have runned mvn install on project AA and looks that it's installed in .m2
Any ideas? Thanks in advance.
Ok I resolved the issue the problem was that I have changed root pom without installing it so I just runned once again mvn install on root project and that resolved the issue.
Related
I want to build an android application with maven. using this tutorial I create a xml file named pom.xml with this code:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hello</groupId>
<artifactId>gs-maven-android</artifactId>
<version>0.1.0</version>
<packaging>apk</packaging>
<properties>
<!-- use UTF-8 for everything -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.9.0-rc.1</version>
<configuration>
<sdk>
<platform>19</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
but in the
xmlns="http://maven.apache.org/POM/4.0.0"
and
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
I've got error:
URI not registered
what is this error for? and
how can I fix it?
Because your pom.xml isn't a Maven Project xml.
If you use IDE,notice the IDE notify,maybe it tell you what want to do.
Follow the hint,and do it.
I have started since 2 days learning Maven & using goals as deploy and install.So I hv used this command:
mvn install android:deploy
Note:clean,install commands work fine
this is what I get:
[ERROR] No plugin found for prefix 'android' in the current project
and in the plugin groups [com.cryptolog.maven.plugins,
org.apache.maven.plugins, org.codehaus.mojo] available from the
repositories [local (/home/yougostt/.m2/repository), central
and this is the 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>univer.lib.androidtestxmlrpc</groupId>
<artifactId>android_xmlrpc</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.cryptolog.rpc</groupId>
<artifactId>libxmlrpc</artifactId>
<version>${rpc.version}</version>
</dependency>
<dependency>
<groupId>com.cryptolog.rpc</groupId>
<artifactId>libxmlrpc-client</artifactId>
<version>${rpc.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<rpc.version>3.7</rpc.version>
</properties>
</project>
How can I fix it please?
Supposing you are using the com.simpligilty.maven.plugins Android Maven Plugin (but the same would also work for any other plugin), you can add to your pom the following (as also explained by its official usage page:
<build>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.4.1</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
If instead you are using the Jayway Androind Maven Plugin, the configuration would look like (as also explained by the official Spring guide:
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.9.0-rc.1</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
This is my POM.xml,and i am getting error at
line 1 and
at packaging tag as "unknown packaging : apk"
Tried every possible solution ie. installed m2e plugin,managed maven lifecycle,but of no use in eclipse.
Please help!
<?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/maven-v4_0_0.xsd">
<parent>
<groupId>org.atmosphere</groupId>
<artifactId>wasync-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.atmosphere.wasync.samples</groupId>
<artifactId>android-chat</artifactId>
<packaging>apk</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>Android Chat</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>wasync</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.3</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.2</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<run>
<debug>true</debug>
</run>
<sdk>
<platform>4.0.3</platform>
<path>D:\Android\sdk</path>
</sdk>
<emulator>
<avd>15</avd>
</emulator>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
</plugins>
</build>
</project>
http://maven-android-plugin-m2site.googlecode.com/svn/apk-mojo.html#apkMetaIncludes
Pattern for additional META-INF resources to be packaged into the apk.
The APK builder filters these resources and doesn't include them into
the apk. This leads to bad behaviour of dependent libraries relying on
these resources, for instance service discovery doesn't work. By
specifying this pattern, the android plugin adds these resources to
the final apk. The pattern is relative to META-INF, i.e. one must use:
<apkMetaIncludes>
<metaInclude>services/**</metaInclude>
</apkMetaIncludes>
The META-INF folder is under src folder
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.alpha9.teste</groupId>
<artifactId>testemvn</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<name>testemvn</name>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<path>/Applications/android-sdk-macosx</path>
<platform>13</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<apkMetaIncludes>
<metaInclude>services/**</metaInclude>
</apkMetaIncludes>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0.1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
At the end, my APK has no services folder!
This is actually wrong in the javadoc. I will fix it. In the meantime this should work
<configuration>
<apk>
<metaIncludes>
<metaInclude>services/**</metaInclude>
</metaIncludes>
</apk>
</configuration>
Of course I would also welcome feedback/confirmation that it works and potentially a pull request that updates the docs..
I am using Eclipse 3.7.2 + Android + Maven + m2e and I have a problem with Android libraries included via Maven as apklibs. I built a test scenario with two projects, mvntest1 (the main project) and mvntest2 (my library project). The pom.xml's are included after this text.
So far so good. I can build mvntest2 via console $ mvn install without any errors. Thus, I have an apklib in my local maven repository (~/.m2/repository/mvntest2/mvntest2/0.0.1-SNAPSHOT/mvntest2-0.0.1-SNAPSHOT.apklib).
But: The including does not work. Eclipse does not include the classes, etc. of mvntest2 in mvntest1. I have cleaned, updated the configuration and dependencies and nothing help.
What am I doing wrong? Please help.
If some informations are missing, just ask.
======= mvntest1/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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mvntest1</groupId>
<artifactId>mvntest1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>mvntest1</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mvntest2</groupId>
<artifactId>mvntest2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>7</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
====== mvntest2/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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mvntest2</groupId>
<artifactId>mvntest2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apklib</packaging>
<name>mvntest2</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>7</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Support for apklib dependencies in ADT Eclipse is part of ongoing work for the m2e-android project and is not yet complete. Please comment on this issue to stay updated:
https://github.com/rgladwell/m2e-android/issues/8
UPDATE 26th September 2013: Android Connector for Maven Eclipse (m2e-android) version 0.4.3 now has been released with full support for Android Libraries.