2.在服务器上使用 gradle 打包 android 源码

 

https://segmentfault.com/a/1190000008395219

 

安装 android-tools

mkdir ~/android && cd ~/androidwget https://dl.google.com/android/repository/tools_r25.2.3-linux.zipunzip tools_r25.2.3-linux.zip

 

配置环境变量

echo 'export ANDROID_HOME=~/android' >> ~/.bashrcecho 'export PATH=${ANDROID_HOME}/tools/bin:$PATH' >> ~/.bashrcsource ~/.bashrc

以编译 https://github.com/drakeet/Ti... 为例

git clone https://github.com/drakeet/TimeMachine.gitcd TimeMachine./gradlew build

漫长的等待后错误如下:

FAILURE: Build failed with an exception.


 

* What went wrong:A problem occurred configuring project ':timemachine'.> You have not accepted the license agreements of the following SDK components:  [Android SDK Build-Tools 25.0.2, Android SDK Platform 25].  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.BUILD FAILEDTotal time: 2 mins 40.822 secs

可以看出是因为缺少 [Android SDK Build-Tools 25.0.2, Android SDK Platform 25]

 

这时执行android list sdk --all 寻找匹配的序号

2.在服务器上使用 gradle 打包 android 源码_第1张图片

 

从上图可以看出匹配的是 3 

 

执行 android update sdk -u -a -t 3 询问时输入 "y" 并耐心等待可以看出安装成功,再次执行 ./gradlew build 尝试编译, 报错如下:

Installing Archives:  Preparing to install archives  Downloading Android SDK Build-tools, revision 25.0.2  Installing Android SDK Build-tools, revision 25.0.2    Installed Android SDK Build-tools, revision 25.0.299%)  Done. 1 package installed.

可以看出安装成功,再次执行 ./gradlew build 尝试编译, 报错如下:

root:~/work/TimeMachine# ./gradlew buildChecking the license for package Android SDK Platform 25 in /root/android/licensesWarning: License for package Android SDK Platform 25 not accepted.FAILURE: Build failed with an exception.* What went wrong:A problem occurred configuring project ':timemachine'.> You have not accepted the license agreements of the following SDK components:  [Android SDK Platform 25].  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.BUILD FAILEDTotal time: 3.94 secs

 

可以看出是缺少 '[Android SDK Platform 25]',重复上次的过程

 

2.在服务器上使用 gradle 打包 android 源码_第2张图片

 

从上图可以看出匹配的是 33 

 

执行 android update sdk -u -a -t 33 询问时输入 "y" 并耐心等待

Installing Archives:  Preparing to install archives  Downloading SDK Platform Android 7.1.1, API 25, revision 3  Installing SDK Platform Android 7.1.1, API 25, revision 3    Installed SDK Platform Android 7.1.1, API 25, revision 396%)  Done. 1 package installed.可以看出安装成功,再次执行 ./gradlew build 尝试编译, 报错如下:FAILURE: Build failed with an exception.* What went wrong:A problem occurred configuring project ':timemachine'.> You have not accepted the license agreements of the following SDK components:  [Android SDK Platform-Tools].  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.BUILD FAILEDTotal time: 4.913 secs

2.在服务器上使用 gradle 打包 android 源码_第3张图片

 

android update sdk -u -a -t 2

Installing Archives:

  Preparing to install archives

  Downloading Android SDK Platform-tools, revision 25.0.3

  Installing Android SDK Platform-tools, revision 25.0.3

  Stopping ADB server failed (code -1).

    Installed Android SDK Platform-tools, revision 25.0.397%)

    Stopping ADB server succeeded.

    Starting ADB server succeeded.

  Done. 1 package installed.

FAILURE: Build failed with an exception.

 

* What went wrong:

A problem occurred configuring project ':timemachine'.

> You have not accepted the license agreements of the following SDK components:

  [Android Support Repository].

  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.

  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

 

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

 

BUILD FAILED

 

2.在服务器上使用 gradle 打包 android 源码_第4张图片

 

android update sdk -u -a -t 160

Installing Archives:

  Preparing to install archives

  Downloading Android Support Repository, revision 43

  Installing Android Support Repository, revision 43

    Installed Android Support Repository, revision 4399%)

  Done. 1 package installed.

再次尝试编译 ./gradlew build

 

FAILURE: Build failed with an exception.

 

* What went wrong:

Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

 

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

更多相关文章

  1. Android截屏及图片解析
  2. Android 源码分析 —— 从 Toast 出发
  3. [转]Eclipse 查看Android SDK源码
  4. Android 利用animation-list自定义progressbar动画出现图片平铺
  5. Android Q : 安卓源码、水滴屏适配状态栏图标(图标过多时显示一个
  6. android-RadioButton背景使用图片
  7. Android之网络请求7————OkHttp源码4:网络操作

随机推荐

  1. android audio系统的概况
  2. 简单实现Android文件上传
  3. Android实现延迟退出主界面功能
  4. GitHub上受欢迎的Android(安卓)UI 库2
  5. android LayoutInflater实例化的方法
  6. android监控应用(app)前后台切换(状态)
  7. Android实现简单的电子词典
  8. Android上关于view的事件问题
  9. (Linux平台)在Android中调用JNI
  10. PhoneGap0.9.5 for Android源码