mvn 打apk包

1、sdk下载
http://tools.android-studio.org/index.php/sdk
2、mvn-sdk下载
https://github.com/mosabua/maven-android-sdk-deployer
3、9.png制作
http://romannurik.github.io/AndroidAssetStudio/nine-patches.html#&sourceDensity=320&name=example
4、pom.xml

 
<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.aj.app</groupId>
  <artifactId>demo</artifactId>
  <name>appTest</name>
  <version>20180228</version>  
  <packaging>apk</packaging> 
  <description/>
  <properties> 
    <project.build.sourceEncoding>utf-8</project.build.sourceEncoding>	
	 <!-- platform as api level (api level 19 = platform 4.4)--> 
	<android.sdk.path>${env.ANDROID_HOME}/</android.sdk.path>
	<android.sdk.platform>19</android.sdk.platform>  
	<java-version>1.8</java-version> 
    <keyFilePath>../xxx.key</keyFilePath>   
    <storePassword>xxx</storePassword>   
    <keyPassword>xxx</keyPassword>    
    <keyAlias>ajco</keyAlias>  
  </properties> 
  <!--
  <distributionManagement>
    <repository>
      <id>nexus-aliyun</id>
      <name>Android Repository</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </repository>
  </distributionManagement>
  -->
  
  <dependencies>  
  <dependency>
            <groupId>android</groupId>
            <artifactId>android</artifactId>
            <version>4.4.2_r4</version>
             <scope>provided</scope> 
        </dependency>  
<!--加本地lib-->	 
<dependency><groupId>com.aj.external</groupId><artifactId>pinyin4j</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>user_model.commons</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>gson</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>regoPrintLibV2.4</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>dom4j</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>hitom</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>License</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>commons-codec</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>glide</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>core</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>eventbus</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>JwtBean</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>ajframe.1.0b27.android</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>asmack</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>openmobileapi</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>publishSystemCommon</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>jxtCommon</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>zdqw.common.bean</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>fjdc.commons</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>com.aj.external</groupId><artifactId>android-support-v4</artifactId><version>1.0.0</version></dependency>


<!-- 添加so文件 -->
<dependency><groupId>com.autonavi</groupId><artifactId>libggpl</artifactId><version>v3</version><scope>runtime</scope><classifier>armeabi</classifier><type>so</type></dependency>
<dependency><groupId>com.autonavi</groupId><artifactId>libhello-jni</artifactId><version>v3</version><scope>runtime</scope><classifier>armeabi</classifier><type>so</type></dependency>
<dependency><groupId>com.autonavi</groupId><artifactId>libhssimkey</artifactId><version>v3</version><scope>runtime</scope><classifier>armeabi</classifier><type>so</type></dependency>
<dependency><groupId>com.autonavi</groupId><artifactId>libhsskf</artifactId><version>v3</version><scope>runtime</scope><classifier>armeabi</classifier><type>so</type></dependency>
<dependency><groupId>com.autonavi</groupId><artifactId>libiomx-gingerbread</artifactId><version>v3</version><scope>runtime</scope><classifier>armeabi</classifier><type>so</type></dependency>
<dependency><groupId>com.autonavi</groupId><artifactId>libiomx-hc</artifactId><version>v3</version><scope>runtime</scope><classifier>armeabi</classifier><type>so</type></dependency>
<dependency><groupId>com.autonavi</groupId><artifactId>libiomx-ics</artifactId><version>v3</version><scope>runtime</scope><classifier>armeabi</classifier><type>so</type></dependency>
<dependency><groupId>com.autonavi</groupId><artifactId>libvlcjni</artifactId><version>v3</version><scope>runtime</scope><classifier>armeabi</classifier><type>so</type></dependency>
<dependency><groupId>com.autonavi</groupId><artifactId>libwltdecode</artifactId><version>v3</version><scope>runtime</scope><classifier>armeabi</classifier><type>so</type></dependency>
</dependencies>  
  
 <build>  
     <!--<finalName>${project.artifactId}</finalName>   -->
	 <finalName>${project.artifactId}</finalName>
     <sourceDirectory>src</sourceDirectory>  
	    <defaultGoal>compile</defaultGoal>  
		 <resources>
		 <resource> 
						<directory>${project.basedir}</directory> 
						<filtering>true</filtering> 
						<targetPath>${project.build.directory}</targetPath> 
						<includes> 
						<include>AndroidManifest.xml</include> 
						</includes> 
		 </resource>
		 <resource>
                <directory>res</directory>
                <filtering>true</filtering>
				 <targetPath>${project.build.directory}/res</targetPath>  
                <includes>
                    <include>**/*</include>
                </includes>
                <excludes>
                    <exclude>**/env-*.properties</exclude>
                </excludes>
            </resource> 
			  <resource>  
				<directory>${project.basedir}/png/res/drawable-hdpi</directory> 
				<filtering>true</filtering>
				<targetPath>${project.build.directory}/res/drawable-hdpi</targetPath> 
				<includes>
					<include>*.9.png</include>
				</includes> 
			  </resource>
			<resource>  
				<directory>${project.basedir}/libs</directory> 
				<filtering>true</filtering>
				<targetPath>${project.build.directory}/libs</targetPath> 
				<includes>
					<include>*.jar</include>
				</includes> 
			  </resource>			  
		</resources>
     <plugins> 
	 
	 <plugin>  
        <groupId>org.apache.maven.plugins</groupId>  
        <artifactId>maven-surefire-plugin</artifactId>  
        <version>2.4.2</version>  
        <configuration> 
			<argLine> -XX:-UseSplitVerifier</argLine>		
          <skipTests>true</skipTests>  
        </configuration>  
	</plugin> 
 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.4.3</version>
    <configuration>
        <encoding>${project.build.sourceEncoding}</encoding>
    </configuration> 
	<executions>  
	<execution>
                          <phase>initialize</phase>
                          <goals>
                             <goal>resources</goal>
                          </goals>
          </execution>
		 
		</executions>
   </plugin> 
	   
	   <plugin>
			<artifactId>maven-compiler-plugin</artifactId>
			  <version>2.3.2</version>  
			<configuration>
			  <source>${java-version}</source>
			  <target>${java-version}</target>
			  <encoding>${project.build.sourceEncoding}</encoding> 
				 <compilerArguments>            
					<extdirs>libs</extdirs> 
				 </compilerArguments>   
			</configuration>
		  </plugin>
        <plugin>   
             <groupId>    
                 com.jayway.maven.plugins.android.generation2  
               </groupId>  
             <artifactId>android-maven-plugin</artifactId>   
              <version>3.9.0-rc.3</version>
			 <!-- <version>3.6.0</version>-->
			<extensions>true</extensions>
			<!--<executions>
				<execution>
                              <id>run</id>
                               <goals>
                                   <goal>deploy</goal>
                                   <goal>run</goal>
                              </goals>
                              <phase>install</phase>
                          </execution>	
			</executions>-->						  
             <configuration>
				<release>true</release>
				<androidManifestFile>${project.build.directory}/AndroidManifest.xml</androidManifestFile> 
				<assetsDirectory>${project.basedir}/assets</assetsDirectory> 
				<resourceDirectory>${project.build.directory}/res</resourceDirectory> 
				<nativeLibrariesDirectory>${project.basedir}/libs</nativeLibrariesDirectory>			 
                 
				 <sdk>    
                     <path>${android.sdk.path}</path> 					  
                     <platform>${android.sdk.platform}</platform>   
                 </sdk>   
                 <sign>    
                     <debug>false</debug>   
                 </sign>    
                 <deleteConflictingFiles>true</deleteConflictingFiles>
				 <undeployBeforeDeploy>true</undeployBeforeDeploy> 
				  <includeLibsJarsFromAar>true</includeLibsJarsFromAar>
				<includeLibsJarsFromApklib>true</includeLibsJarsFromApklib> 				 
             </configuration>    
                
             <inherited>true</inherited>    
         </plugin> 
  
        <plugin>   
             <groupId>org.apache.maven.plugins</groupId>    
             <artifactId>maven-jarsigner-plugin</artifactId>   
             <version>1.2</version>    
             <executions>    
                 <execution>   
                     <id>signing</id>   
                     <goals>    
                         <goal>sign</goal>  
                     </goals>    
                     <phase>package</phase>  
                     <inherited>true</inherited>  
                     <configuration>    
                         <archiveDirectory></archiveDirectory>   
                         <includes>   
                             <include>target/*.apk</include>  
                         </includes>    
                         <keystore>${keyFilePath}</keystore>  
                         <storepass>${storePassword}</storepass>  
                         <keypass>${keyPassword}</keypass>   
                         <alias>${keyAlias}</alias> 
						 <arguments> 
							<argument>-sigalg</argument> 
							<argument>MD5withRSA</argument> 
							<argument>-digestalg</argument> 
							<argument>SHA1</argument> 
						 </arguments>						 
                     </configuration>   
                 </execution>   
             </executions>   
         </plugin> 
		 
     </plugins>   
 </build>  
 
  
</project>

打包命令:

mvn clean install -Denforcer.skip=true -Dmaven.test.skip=true

5、maven 阿里云配置
查看setting.xml目录

mvn -X
[DEBUG] Reading global settings from /usr/share/maven/conf/settings.xml
[DEBUG] Reading user settings from /root/.m2/settings.xml
[DEBUG] Using local repository at /root/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for /root/.m2/repository
vi  /usr/share/maven/conf/settings.xml
<mirror>
      <id>nexus-aliyun</id>
      <mirrorOf>central</mirrorOf>
      <name>Nexus aliyun</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>

6、android版本升级

android update sdk --no-ui --filter android-XX > /dev/null

7、查看api与android版本对应关系

android list sdk --all

 49- SDK Platform Android 10, API 29, revision 1
  50- SDK Platform Android 9, API 28, revision 6
  51- SDK Platform Android 8.1.0, API 27, revision 3
  52- SDK Platform Android 8.0.0, API 26, revision 2
  53- SDK Platform Android 7.1.1, API 25, revision 3
  54- SDK Platform Android 7.0, API 24, revision 2
  55- SDK Platform Android 6.0, API 23, revision 3
  56- SDK Platform Android 5.1.1, API 22, revision 2
  57- SDK Platform Android 5.0.1, API 21, revision 2
  58- SDK Platform Android 4.4W.2, API 20, revision 2
  59- SDK Platform Android 4.4.2, API 19, revision 4
  60- SDK Platform Android 4.3.1, API 18, revision 3
  61- SDK Platform Android 4.2.2, API 17, revision 3
  62- SDK Platform Android 4.1.2, API 16, revision 5
  63- SDK Platform Android 4.0.3, API 15, revision 5
  64- SDK Platform Android 4.0, API 14, revision 4
  65- SDK Platform Android 3.2, API 13, revision 1
  66- SDK Platform Android 3.1, API 12, revision 3
  67- SDK Platform Android 3.0, API 11, revision 2
  68- SDK Platform Android 2.3.3, API 10, revision 2
  69- SDK Platform Android 2.3.1, API 9, revision 2
  70- SDK Platform Android 2.2, API 8, revision 3
  71- SDK Platform Android 2.1, API 7, revision 3

8、android的maven版本构建
由于在maven central中 android版本只有4.1.1.4

我们需要一个工具来安装新版的android sdk. Maven Android SDK Deployer.

根据Maven Android SDK Deployer的wiki 文案,mvn install -P 4.4 在pom.xml导入 4.4.2的安卓包.

 cd maven-android-sdk-deployer-master
 mvn install -P 4.4 -Denforcer.skip=true 

在pom.xml导入 4.4.2的安卓包
查看4.4.2包

cd  /root/.m2/repository/android/android
4.4  4.4.2  4.4.2_r3  4.4.2_r4  maven-metadata-local.xml
cat maven-metadata-local.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>android</groupId>
  <artifactId>android</artifactId>
  <versioning>
    <release>4.4.2_r4</release>
    <versions>
      <version>4.4.2_r4</version>
    </versions>
    <lastUpdated>20190819065647</lastUpdated>
  </versioning>
</metadata>

引用4.4.2安卓包

<dependency>
            <groupId>android</groupId>
            <artifactId>android</artifactId>
            <version>4.4.2_r4</version>
            <scope>provided</scope>
        </dependency>

9、第三方包导入本地库运行

javar -jar jar2mvn 

代码生成程序:
https://blog.csdn.net/tonysh_zds/article/details/99974880

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值