How to build a Maven Android project in eclipse - android

I am testing the code here : https://github.com/nkzawa/socket.io-client.java. Under features there is this sweet sounding line : "Android is fully supported". But being completely new to maven I can make neither head nor tail of the instructions. How do I build a basic Android test project with this code? Simply adding the source code from the repo to my project is showing lot of errors. If there is a command line way of doing this that would be fine too.

The Android for Maven Eclipse connector is an Maven Eclipse (m2e) plug-in that adds maven support for Android Developer Tools (ADT) and the Maven Android Plugin. It brings the power of Maven dependency management into the ADT.
Before you start
You will need Eclipse Indigo or Juno installed.
Install Android Connector
You can install the Android Connector for Maven via the Eclipse Marketplace. Select Help -> Eclipse Marketplace... and search for "android m2e".
Click the Install button next to the Android Connector for Maven that appears and follow the path through the wizard dialog to install the plug-in and its dependencies (including the Android Development Toolkit and the Maven for Eclipse m2e plug-in). Accept the terms-and-conditions and click Finish.
Once you restart your Eclipse workspace you should be ready to start using the Android Connector.
Create Eclipse project
If you already have an Android project please make sure you have created a POM for your project using version 3.0.0 or greater of the maven-android-plugin.
Then right-click on your project and select Configure -> Convert to Maven Project.
If you are starting with a new project you can use the Maven Android archetypes to create Android projects completely within Eclipse:
1. Create a new Maven Project (File -> New -> Project... then select Maven -> Maven Project).
2. When prompted to Select Archetype click Add Archetype...
3. In the dialog that appears enter "de.akquinet.android.archetypes" for Archetype Group Id.
4. In Archetype Artifact Id enter "android-quickstart".
5. In Archetype Version enter "1.0.10" and continue.
6. When prompted enter your desired project group and artifact ID, version and, optionally, set the "platform" property for the Android version (defaults to '16').
7. Click Finish
Either way you should end up with an Eclipse project looking something like this:

Steps to build a Maven Android project in eclipse
Install m2e(mavel plugin) to your ecplise.
Right click Create Maven project
Click next and in Catalog select Android
Give group id com.example and Artifact id Project name
click finish.

Typically you do this by importing an "Existing Maven Project". You get this option in the Import dialog when you have installed m2e. For Android you will additionally need the Android Connector before doing the import. Here it gets nasty. You can install the connector from Window -> Preferences -> Maven -> Discovery -> Open Catalog.
To be honest I had no luck with this connector yet. So the second option is (you don't even need m2e here):
Install Maven
Open the command line and navigate to your downloaded sources where the pom.xml is located
run mvn eclipse:eclipse to create eclipse project files
Import it as "Existing Project into Workspace" in the import dialog.

install m2e plug-in your eclipse.
install android m2e plug-in.
create new maven project.
select archtype:android-quickstart by typing android in filter.
finish you will get maven android project.
and add this plugin in pom
org.eclipse.m2e
lifecycle-mapping
1.0.0
com.jayway.maven.plugins.android.generation2
android-maven-plugin
[3.8.2,)
consume-aar
finally update the project by rightclicking on project->maven->update project.

Related

Install repository and sync project

I am trying to make a new project for android wear but this error keeps showing up, I thought it was because I wasn't making new projects in the location I was making before but changing back the location didn't work.
but I when I am making a regular project for android phones there is no problem like this
Try doing the recommended steps that was provided in the SO Post.
in Android Studio, open Tools -> Android -> SDK Manager
under tab "SDK Tools" un-check the libraries causing problems
click "apply" to uninstall them
re-check the same libraries click "apply" to reinstall them
close SDK Manager and run Gradle sync / build
Need to take note the update last July 2017 as well.
Important: The support libraries are now available through Google's
Maven repository. You do not need to download the support repository
from the SDK Manager. For more information, see Support Library Setup.
Here are some important points that you needed for google maven taken from SO post:
In your root build.gradle, you have to add the google maven just like this:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Somehow the 26.0.0 Versions didn't worked for me as well.
Try to use the version 25.3.1.
first of all disable your Anti-Virus if have any.
secondly follow the steps
In Android Studio, open Tool > Android > SDK Manager
under tab "SDK Tools" un-check the libraries that are previously checked
click "apply" to uninstall them
re-check the same libraries click "apply" to reinstall them
close SDK Manager and run Gradle sync / build
if this doesn't work then one who has a working A.S take his SDK files from App data

Building Android project in Jenkins "requires Maven version 3.1.1"

I'm building an Android project in Jenkins. Everything was fine until upgrading to the lastest plugin version, but now it fails with "requires Maven version 3.1.1". Fair enough, but Jenkins seems to be stuck on Maven 3.0.4, even though I'm using the latest version (currently 1.553) of Jenkins and all its plugins. How to I make it update to a more current release of Maven?
Building in Jenkins via android-maven-plugin, which as of version 3.8.0 requires Maven 3.1.1 or higher (see http://code.google.com/p/maven-android-plugin/wiki/Changelog). Of course it can be done manually, outside Jenkins. The question is how to get Jenkins to use a current Maven; it seems to come packaged with an older one, and I'm not familiar enough with it to see where/how to update.
Update: For anyone following my footsteps, note that upgrading Maven will break the Android build until android-maven-plugin is also updated; they go together.
Jenkins does not come with Maven, but it can install it for you.
To Update Maven version used by Jenkins
Goto Manage Jenkins -> Configure System.
Scroll down till you see Maven section (not Maven Configuration or Maven Project, those are different).
Click Add Maven button.
Leave Name as default.
Checkmark Install Automatically.
Install from Apache is the default installer option.
Select the version you want installed.
Besides "Install from Apache", you can also install it from a zip or by executing a command line. Just delete the apache installer and click Add Installer button to select another option.
I would suggest to run a dummy Maven project at least once to verify this gets installed.
Jenkins doesn't come with maven as far as I am aware of. You can specify a maven installation in the Jenkins settings. I usually use a reference to a symlink (debian) and let that symlink point to my "current" or preferred Maven version.
You can alternatively install a recent maven version via Jenkins in the Jenkins settings aswell. And on my Jenkins there is a 3.1.1 via apache available.

How do you install m2e-android-plugin in Eclipse?

I am trying to get setup to use Maven and pom.xml files in Eclipse for my Android projects. I have Eclipse Indigo setup (m2e included), Android SDK installed, ADT installed. I am struggling to understand what it means to "Install the m2e-android-plugin" (I am always taken to this page which provides instructions on installing it, but which I cannot follow) Specifically, when I go through the instruction on that page, after I complete all the steps in part 2, my structure does not have "Maven Dependencies" and my pom.xml file shows the following error:
Project build error: Unresolveable build extension: Plugin
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1 or one of its dependencies could
not be resolved: The following artifacts could not be resolved:
com.jayway.maven.plugins.android.generation2:android-maven-plugin:jar:3.1.1,
com.android.ddmlib:ddmlib:jar:r16, org.sonatype.sisu:sisu-inject-bean:jar:2.1.1,
org.sonatype.sisu:sisu-guice:jar:no_aop:2.9.4, org.codehaus.plexus:plexus- archiver:jar:2.0.1, junit:junit:jar:3.8.1,
org.codehaus.plexus:plexus-io:jar:2.0.1, org.codehaus.plexus:plexus-utils:jar:3.0, commons-jxpath:commons-
jxpath:jar:1.3, commons-io:commons-io:jar:2.0.1, org.ow2.asm:asm:jar:4.0, commons-lang:commons-lang:jar:
2.6, org.sonatype.aether:aether-util:jar:1.12: Failure to transfer
com.jayway.maven.plugins.android.generation2:android-maven-plugin:jar:3.1.1 from http://repo1.maven.org/
maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central
has elapsed or updates are forced. Original error: Could not transfer artifact
com.jayway.maven.plugins.android.generation2:android-maven-plugin:jar:3.1.1 from/to central (http://
repo1.maven.org/maven2): No response received after 60000
along with:
Project build error: Unknown packaging: apk
on the line
<packaging>apk</packaging>
I have tried set up a fresh second IDE myself and everything works as expected, suppose you have installed both Android SDK and Maven properly (better to use latest version), these are the only Eclipse plugins required to work with Mavenized Android Project:
adt
m2e
m2e-android
Check out my screenshot Help -> Install New Software... -> what is already installed:
If you follow instructions from this page starting with a new project, the <packaging> error is most likely due to earlie version of maven-release-plugin (if you do not explicitly specify one). By hovering mouse on <packaging> element in pom.xml, you should get some hint like:
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.
Adding the following plugin under <plugins>:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
</plugin>
Then Right-click on new project and select Maven -> Update Project Configuration, this should fix all error and give you a working example.
I had the same problem trying to install the android m2e in eclipse JUNO.
Then tried to install through "Install new software" wizard, instead of market place.
Add the following as an update site and select "Android For Maven eclipse" from the listed softwares and install.
http://rgladwell.github.com/m2e-android/updates - Thanks to #NullNoname for providing the update site.

Android Verilook Embedded SDK integration

I am an Android Mobile Application Developer. I want to integrate Verilook Embedded SDK for face detection/recognition and fingerprint detection. I need guidance how to do this.
This is link to download SDK and Documentation PDF file and download Biometric SDKs trials.
Try this,
Step 1 : Download the Zip File
Step 2 : Unzip it
Step 3: Browse to unziped foler MegaMatcherEmbeddedFolder->Documentation->MegaMatcher.pdf.It says clearly what to do.
Steps To Run Samples(Still these steps are in the pdf)
MegaMatcher 1.1, VeriFinger 1.1, VeriLook 1.1, VeriEye 1.0 and VeriSpeak 1.0 Embedded SDK for Android Java projects (sample programs) are built and managed using Eclipse and Apache Maven tool.
Instructions for compiling Java samples using Maven:
(Note: Eclipse Indigo or later has Apache Maven integrated. If you are using Eclipse Indigo or later it is not required to perform steps 1-2).
Download (http://maven.apache.org/download.html) and integrate Apache Maven for Eclipse (http://maven.apache.org/eclipse-plugin.html). Java projects require Apache Maven version 3.0.3 or later. Downloaded Maven package contains README.txt file with installation instructions.
Integrate Apache Maven to Eclipse IDE. (http://eclipse.org/m2e/).
Run Eclipse IDE and import Java project (one of sample application provided with SDK). Select
File->Import->Maven->Existing Maven projects. Press Next button.
In the next dialog window browse for Samples root folder in SDK. Select projects pom.xml file and press Next.
In the last window just select Finish button.
In Eclipse find imported project in Package Explorer and right click on it. Select Run As -> Maven Install. It will start downloading required packages. If it will report missing dependencies (see console output) right click on the project again and choose Run As -> Maven Build. In the Main tab find Goals field and type validate.
7.To deploy and run a project right click on it and select Run As -> Maven Build... In the Main tab find Goals field and type "android:redeploy android:run".
Hope it helps.

How to disable m2e build in Eclipse Indigo?

I'm currently using Eclipse Indigo in an Android project that I'm working on and am running into problems with the built-in Maven (m2e) builder. I use the ADT plug-in to build the project, but I also have a Maven pom.xml that's used to build the project from the command line. Once I switched from Helios to Indigo, I started seeing these errors:
Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:maven-android-plugin:2.9.0-beta-5:generate-sources (execution: default-generate-sources, phase: generate-sources)
Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:maven-android-plugin:2.9.0-beta-5:unpack (execution: default-unpack, phase: process-classes)
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-jar-plugin:2.3.1:jar (execution: default-jar, phase: process-classes)
My goal is to keep the Maven build separate from the ADT Eclipse build so I'd like to simply disable m2e for the project but I can't figure out how to do that.
Is there a way to disable the m2e builder? Alternatively, is there a way to fix the above errors?
Open your POM and click on the "Plugin execution not covered by lifecycle configuration" error. This will give you the option to Discover new m2e connectors.
Select this and you should be automatically prompted to download and install the Android Connector.
Installing this should resolve your problems. You should probably uninstall the old 0.2.4 m2eclipse-android-integration as well in favour of the new 0.3.0 m2e-android version.
Please see the new site for more information:
http://rgladwell.github.com/m2e-android/
M2E official wiki documents this issue
I think you can use lifecycle-mapping plugin from m2e to silently ignore the execution for these plugins
I went into my install directory for Eclipse and manually removed all the references to m2e.
There were multiples in the "Plugin" directory and the "features" directory.
After that my android project was back to behaving like normal and I could use mvn from the command line to build.
I am using MacOSX with Eclipse 4.3 (Krepler). What I originally tried was to install Maven via the terminal using Brew. It installed correctly Maven 3.0.4. However when I tried to import any ready maven projects (File > Import > Maven) it would display the following two errors:
No marketplace entries found to handle Execution default-testResources
What I did is go to Help > Eclipse Marketplace and type "Maven" in the search bar and install the first default Maven client for Eclipse. Everything worked for me from this point.
Hope it helps to you too.

Categories

Resources