Eclipse-Android-Maven from Integrated plugin to Created

来源:互联网 发布:若风外设淘宝店地址 编辑:程序博客网 时间:2024/06/01 09:26

There are all steps for Eclipse-Android-Maven from Integrated plugin to Created

I get an Android Project recently.And I have to use Maven and FlexboxLayout.

So I will introduce my errors in project.


1. Configure JDK Environment

please googled it.
or you can click here.

2. Configure Maven Environment

reference:myeclipse-maven configuration

**If you have been configured JDK environment,
than you can configure Maven cnvironment.**

1) download a Maven file
please click here. Version 3.0.5

2) configure it as JDK environment configured
A) new a variable:
name: “MVN_HOME”
value: the Absolute Path where the Maven file is placed

B) add “;%MVN_HOME%\bin;” into variable named “path”

3) test your configuration
run the commond “mvn -v” in “cmd”

getting as following picture, means successfully.
这里写图片描述

4) configure local repository
all *jar which project depends on will be put in local repository.
open “setting.xml” in “*\apache-maven-3.0.5\conf” and configure child node named “localRepository”.
这里写图片描述
这里写图片描述

3. Eclipse + Maven

1) start eclipse, setting the path Maven placed
“window-preference-maven-installations”
这里写图片描述

2)setting the path local repository placed
“window-preference-maven-user setting”
这里写图片描述

4. Eclipse + Android

reference:Android ADT and SDK

1) download the ADT Plugin

A) Online and Need VPN if being in china
- Start Eclipse, then select Help > Install New Software.
- Click Add, in the top-right corner.
- In the Add Repository dialog that appears, enter “ADT Plugin” for the Name and the following URL for the Location:
https://dl-ssl.google.com/android/eclipse/
- Click OK.
If you have trouble acquiring the plugin, try using “http” in the Location URL, instead of “https” (https is preferred for security reasons).
- In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
- In the next window, you’ll see a list of the tools to be downloaded. Click Next.
- Read and accept the license agreements, then click Finish.
- If you get a security warning saying that the authenticity or validity of the software can’t be established, click OK.
When the installation completes, restart Eclipse.
这里写图片描述

B) outline

  • Download the ADT Plugin zip file (do not unpack it):
    ADT-21.1.0.zip
  • Start Eclipse, then select Help > Install New Software.
    Click Add, in the top-right corner.
  • In the Add Repository dialog, click Archive.
  • Select the downloaded ADT-21.1.0.zip file and click OK.
  • Enter “ADT Plugin” for the name and click OK.
  • In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  • In the next window, you’ll see a list of the tools to be downloaded. Click Next.
  • Read and accept the license agreements, then click Finish.
  • If you get a security warning saying that the authenticity or validity of the software can’t be established, click OK.
    When the installation completes, restart Eclipse.

To update your plugin once you’ve installed using the zip file, you will have to follow these steps again instead of the default update instructions.
这里写图片描述

2) configure the ADT Plugin

Once Eclipse restarts, you must specify the location of your Android SDK directory:

  • In the “Welcome to Android Development” window that appears, select Use existing SDKs.
  • Browse and select the location of the Android SDK directory you recently downloaded and unpacked.
  • Click Next.
    这里写图片描述

Your Eclipse IDE is now set up to develop Android apps, but you need to add the latest SDK platform tools and an Android platform to your environment. To get these packages for your SDK, continue to Adding Platforms and Packages.

5. Eclipse + Android + Maven

reference: M2Eclipse

M2Eclipse
- This is the Eclipse plugin.
- The role is the bridge between ADT and Eclipse.

  • Start Eclipse, then select Help > Eclipse Marketplace.
  • Search for this keyword “android m2e”(Need VPN)
  • Click Install.

    这里写图片描述

    5. Create Eclipse-Android-Maven Project

1) If you have been had an Android Project

  • Right Click -> Configure -> Convert to Maven Project
  • Types of packaging changes to apk
<?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>Elsa</groupId>    <artifactId>AndroidTestMaven</artifactId>    <version>0.0.1-SNAPSHOT</version>    <packaging>apk</packaging>    <name>AndroidTestMaven</name>

2) Create a new Android-Maven Project

  • Create a new Maven Project
    (File -> New -> Other -> Maven Project)
  • Choose “Android” for Catalog
  • Choose “android-quickstart” in Artufact Id, Next
  • Set Group Id and Artifact Id, Finish

这里写图片描述
这里写图片描述

Best wish for you!

*If getting following error:

Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2: consume-aar (execution: default-consume-aar, phase: compile)
  • It is best to declare a plugin in the Node “build” at pom.xml:
<plugin>    <groupId>com.jayway.maven.plugins.android.generation2</groupId>    <artifactId>maven-android-plugin</artifactId>    <version>2.8.4</version>        <configuration>            <sdk>                <platform>7</platform>            </sdk>            <emulator>                <avd>21</avd>            </emulator>            <deleteConflictingFiles>true</deleteConflictingFiles>            <undeployBeforeDeploy>true</undeployBeforeDeploy>        </configuration>    <extensions>true</extensions></plugin>

**If getting following error:

org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration) pom.xml /<maven projectName>

reasons:
- The maven-jar-plugin version 3.0.2.
- Eclipse 4.5.2 started flagging the pom.xml file with the
org.apache.maven.archiver.MavenArchiver.getManifest error
and a Maven > Update Project.. would not fix it.

Easy solution: downgrade to 2.6 version
Indeed a possible solution is to get back to version 2.6, a further update of the project would then remove any error. However, that’s not the ideal scenario and a better solution is possible: update the m2e extensions (Eclipse Maven integration).

Better solution: update Eclipse m2e extensions
From Help > Install New Software.., add a new repository (via the Add.. option), pointing to any of the following URLs:

https://otto.takari.io/content/sites/m2e.extras/m2eclipse-mavenarchiver/0.17.2/N/LATEST/

http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.2/N/LATEST/

Then follow the update wizard as usual. Eclipse would then require a restart. Afterwards, a further Update Project.. on the concerned Maven project would remove any error and your Maven build could then enjoy the benefit of the latest maven-jar-plugin version.

这里写图片描述

reference:m2e error in MavenArchiver.getManifest()

阅读全文
0 0