Travis: how to know android sdk/ndk path?

ぐ巨炮叔叔 提交于 2019-12-12 03:02:32

问题


My android project is built with Ant and i have to edit ant.properties manually file to pass sdk.path variable pointing to android sdk directory. i'm going to change it to get sdk path from environment variable to make build possible on Travis CI. What is android sdk variable for this?

Also i have some jni code to be built with android ndk, so the similar question - what is env variable for android ndk on Travis?


回答1:


Don't use the Travis's Android support; it uses the old 'android' CLI instead of the new sdkmanager CLI that supports installing the NDK. Do something like:

before_install:
 - cd $HOME
 - wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O $HOME/android-sdk.tgz
 - mkdir android
 - unzip android-sdk.tgz -d android/sdk
 - export PATH=$PATH:$HOME/android/sdk/tools:$HOME/android/sdk/tools/bin
 - cd build/<your-build-directory>

And then in the 'install' section:

install:
  - echo y | sdkmanager 'ndk-bundle'
  - echo y | sdkmanager 'cmake;3.6.3155560'
  - export ANDROID_HOME=$HOME/android/sdk
  - export ANDROID_NDK_HOME=$HOME/android/sdk/ndk-bundle

You can use the sdkmanager to install anything else you need. The benefit over the other answer is that this will grab the latest version of the NDK.

Finally, then you can set the environment variables ANDROID_HOME and ANDROID_NDK_HOME, and pass it to your specific environment.

Hope it helps.




回答2:


Travis seems to provide Android support in beta. Android SDK can be found in /usr/local/android-sdk. However it seems that Android NDK is not provided and can't be found in /usr/local/android-ndk. The simple (and expensive walkaround for Travis) is to download/extract/use it right while building like this:

  before_script:
    - export NDK_VERSION=r10e
    - curl -L http://dl.google.com/android/ndk/android-ndk-${NDK_VERSION}-linux-x86_64.bin -O
    - chmod u+x android-ndk-${NDK_VERSION}-linux-x86_64.bin
    - ./android-ndk-${NDK_VERSION}-linux-x86_64.bin > /dev/null
    - rm android-ndk-${NDK_VERSION}-linux-x86_64.bin
    - export ANDROID_NDK_HOME=`pwd`/android-ndk-${NDK_VERSION}
    - export PATH=${ANDROID_NDK_HOME}:${PATH}

Feel free to comment this solution if you have a better one.




回答3:


You can export the Android variables using this command as well as Clive Lee's method

env:
  global:
      - ANDROID_HOME=$HOME/android/sdk
      - ANDROID_NDK_HOME=$HOME/android/sdk/ndk-bundle


来源:https://stackoverflow.com/questions/38090358/travis-how-to-know-android-sdk-ndk-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!