Jenkins mac上配置原生android

1、下载gradle

shell指令:

~ builder$ brew install gradle

检查是否安装完毕:

~ builder$ gradle -version
------------------------------------------------------------
Gradle 4.2.1
------------------------------------------------------------

Build time:   2017-10-02 15:36:21 UTC
Revision:     a88ebd6be7840c2e59ae4782eb0f27fbe3405ddf

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_131 (Oracle Corporation 25.131-b11)
OS:           Mac OS X 10.12.6 x86_64

2、原生项目修改build.gradle配置

打开app目录下的build.gradle,并加上一段编译代码

apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
    .........// 有很多默认配置信息
    
    //由于国内网络情况影响,默认gradle地址无法访问,
    //编译会报错,加上此行忽略报错依旧执行build
    lintOptions{
        abortOnError false
    }
    
}

3、原生项目修改local.properties配置

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Thu Jul 27 09:49:07 CST 2017


# WIN系统下,机器编译环境地址
#ndk.dir=E\:\\sdk\\ndk-bundle
#sdk.dir=E\:\\sdk


# MAC OS下,机器编译环境地址
ndk.dir=/Users/builder/Library/Android/sdk/ndk-bundle
sdk.dir=/Users/builder/Library/Android/sdk

4、jenkins shell命令配置

说明:svn配置在此不做赘述 下图为shell命令配置

0001.png

执行构建后的效果总共分为三个步骤:下载依赖->清理项目->编译项目成APK

Started by user APPbuild
Building in workspace /Users/builder/.jenkins/workspace/AndroidDemo
Updating svn://172.16.1.202/zgcsx/android/Master at revision '2017-10-25T15:31:05.447 +0800'
Using sole credentials ke_li/****** in realm ‘<svn://172.16.1.202:3690> 545e6826-7b7a-4598-b980-8796c9348690’
U         .gitignore
D         local.properties
A         local.properties
At revision 5097

Using sole credentials ke_li/****** in realm ‘<svn://172.16.1.202:3690> 545e6826-7b7a-4598-b980-8796c9348690’
[AndroidDemo] $ /bin/sh -xe /var/folders/s3/rkpsdb0x223c37qsfp9wwzhw0000gn/T/jenkins8814663042433137266.sh


+ gradle init
Starting a Gradle Daemon (subsequent builds will be faster)
File /Users/builder/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 25 in /Users/builder/Library/Android/sdk/licenses
License for package Android SDK Build-Tools 25 accepted.
Preparing "Install Android SDK Build-Tools 25 (revision: 25.0.0)".
"Install Android SDK Build-Tools 25 (revision: 25.0.0)" ready.
Finishing "Install Android SDK Build-Tools 25 (revision: 25.0.0)"
Installing Android SDK Build-Tools 25 in /Users/builder/Library/Android/sdk/build-tools/25.0.0
"Install Android SDK Build-Tools 25 (revision: 25.0.0)" complete.
"Install Android SDK Build-Tools 25 (revision: 25.0.0)" finished.
Download ........// 这里会下很多依赖包
:init
The build file 'build.gradle' already exists. Skipping build initialization.
:init SKIPPED

BUILD SUCCESSFUL in 2m 8s

+ gradle clean
The setTestClassesDir(File) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the setTestClassesDirs(FileCollection) method instead.
The getTestClassesDir() method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the getTestClassesDirs() method instead.
The ConfigurableReport.setDestination(Object) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the method ConfigurableReport.setDestination(File) instead.
:clean
:app:clean

BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 executed

+ gradle build
The setTestClassesDir(File) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the setTestClassesDirs(FileCollection) method instead.
The getTestClassesDir() method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the getTestClassesDirs() method instead.
The ConfigurableReport.setDestination(Object) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the method ConfigurableReport.setDestination(File) instead.
...... // 这里有很多编译信息,包括没有编译通过的信息
:app:test UP-TO-DATE
:app:check
:app:build

BUILD SUCCESSFUL in 1m 24s
68 actionable tasks: 68 executed
Finished: SUCCESS

3、编译注意:

请在gradle中配置好打包的key与alias的值,否则上面的打包方式打出来的包无法安装!

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏我的小碗汤

这几个注解的你了解吗

<mvc:annotation-driven />与<context:annotation-config />

11530
来自专栏JAVA高级架构

Spring MVC工作原理

13920
来自专栏JavaEdge

@ConfigurationProperties

23060
来自专栏Danny的专栏

【EJB学习笔记】——实体Bean

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huyuyang6688/article/...

12230
来自专栏Python

linux每日命令(28):chgrp命令

在linux系统里,文件或目录的权限的掌控以拥有者及所属群组来管理。可以使用chgrp指令取变更文件与目录所属群组,这种方式采用群组名称或群组识别码都可以。Ch...

6710
来自专栏技术专栏

springcloud(一)-集成Eureka 服务注册与发现(慕课网廖师兄SpringCloud微服务实战)

让多个Eureka服务端两两注册,即一个Eureka做为另一个Eureka的客户端,然后让Client注册到每一个Eureka服务端上,这样,当一个服务端挂掉以...

1.8K10
来自专栏大闲人柴毛毛

Spring速查手册——Bean装配

Spring提供三种Bean的装配方式,分别是: 1. 自动装配Bean 2. 在Java中装配Bean 3. 在XML中装配Bean 1. 自动...

37280
来自专栏腾讯云Elasticsearch Service

Elasticsearch Rest Client实战

Elasticsearch官方推荐使用Java REST客户端连接集群并进行数据操作。

70840
来自专栏Java工程师日常干货

MyBatis+Spring MVC开发指南(三)

本系列的前面2篇文章,已经为大家介绍了MyBatis;从本篇博客开始将为大家介绍Spring MVC开发的那些事!关于Spring MVC这块将会涵盖Sprin...

8910
来自专栏码匠的流水账

使用SseEmitter不断向网页输出结果

之前写过一篇文章:springmvc不断输出文本到网页,采用的是对response不断进行write和flush实现的。在spring 4.2版本的时候提供了一...

39910

扫码关注云+社区

领取腾讯云代金券