安装 android-tools

mkdir ~/android && cd ~/android

 

wget https://dl.google.com/android/repository/tools_r25.2.3-linux.zip

unzip tools_r25.2.3-linux.zip

配置环境变量

echo 'export ANDROID_HOME=~/android' >> ~/.bashrc

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

source ~/.bashrc

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

git clonehttps://github.com/drakeet/TimeMachine.git

cd 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 ofthe following SDK components:

 [Android SDK Build-Tools 25.0.2, Android SDKPlatform 25].

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

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

 

* Try:

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

 

BUILD FAILED

 

Total time: 2 mins 40.822secs

可以看出是因为缺少[Android SDK Build-Tools 25.0.2, Android SDK Platform 25]
这时执行android list sdk --all寻找匹配的序号

从上图可以看出匹配的是 3
执行android update sdk -u-a -t 3询问时输入 "y" 并耐心等待

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@hostker:~/work/TimeMachine# ./gradlew build

Checking the license for package Android SDK Platform 25in /root/android/licenses

Warning: License for package Android SDK Platform 25not accepted.

 

FAILURE: Build failed withan exception.

 

* What went wrong:

A problem occurred configuring project ':timemachine'.

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

 [Android SDK Platform 25].

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

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

 

* Try:

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

 

BUILD FAILED

 

Total time: 3.94secs

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

从上图可以看出匹配的是 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 ofthe following SDK components:

 [Android SDK Platform-Tools].

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

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

 

* Try:

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

 

BUILD FAILED

 

Total time: 4.913secs


android update sdk -u-a -t 2

Installing Archives:

 Preparing to install archives

 Downloading Android SDKPlatform-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 ofthe following SDK components:

 [Android Support Repository].

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

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

 

* Try:

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

 

BUILD FAILED


android update sdk -u-a -t 160

Installing Archives:

 Preparing to install archives

 Downloading Android SupportRepository, 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 disappearedunexpectedly (it may have been killed or may have crashed)

 

* Try:

Run with --stacktrace optiontoget the stack trace. Run with --info or --debug optiontoget more log output.

... 好像 gradle 进程被杀了,可能我内存太小了吧, 下次换个大点的再试

 

更多相关文章

  1. adb环境变量配置
  2. Mac 下面,添加android adb命令(一般环境变量的添加方法)
  3. android SDK 环境变量的设置
  4. Android及Robotium学习总结【环境变量,真机调试及根据id模拟按键
  5. Android环境变量作用--命令行操作(ADB、AVD等)
  6. android SDK 环境变量配置+ADT安装
  7. Android Studio环境变量设置
  8. Android 中配置adb环境变量

随机推荐

  1. 理解PHP中ob_flush和flush的区别
  2. PHP中的Session和Cookie
  3. PHP中date()函数输出的时间与Linux不一致
  4. PHP在页面中原样输出HTML代码的方法介绍
  5. 几个防SQL注入攻击函数的区别
  6. php如何使用curl?(用法介绍)
  7. 关于PHP的curl功能扩展基本用法
  8. php表单加入Token防止重复提交的方法
  9. php中如何使用json_decode()和json_encod
  10. 关于PHP导出Excel的优化详解