我正在尝试使用ndk-build
(而不是较新的CMAKE
)使用Bitbucket Pipelines持续集成来构建NDK Android项目。但是在调用./gradlew assembleDebug
时出现以下错误:
/opt/android-sdk-linux/ndk-bundle/build/ndk-build: 144: /opt/android-sdk-linux/ndk-bundle/build/ndk-build: file: not found
:sensorylib:ndkBuild
make: Entering directory '/opt/atlassian/pipelines/agent/build/sensorylib/src/main'
/bin/sh: 1: file: not found
make: execvp: /opt/android-sdk-linux/ndk-bundle/build/extract_manifest.py: Permission denied
make: execvp: /opt/android-sdk-linux/ndk-bundle/build/extract_manifest.py: Permission denied
[armeabi] Install : libSensoryVoiceJNI.so => libs/armeabi/libSensoryVoiceJNI.so
/opt/android-sdk-linux/ndk-bundle/build/core/build-binary.mk:797: recipe for target 'libs/armeabi/libSensoryVoiceJNI.so' failed
make: Leaving directory '/opt/atlassian/pipelines/agent/build/sensorylib/src/main'
make: /opt/android-sdk-linux/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-strip: Command not found
make: *** [libs/armeabi/libSensoryVoiceJNI.so] Error 127
make: *** Deleting file 'libs/armeabi/libSensoryVoiceJNI.so'
:sensorylib:ndkBuild FAILED
20 actionable tasks: 20 executed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sensorylib:ndkBuild'.
> Process 'command '/opt/android-sdk-linux/ndk-bundle/ndk-build'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED in 45s
到位桶-pipelines.yml
image: java:8
pipelines:
default:
- step:
caches:
- gradle
script:
# dependencies
- apt-get update
- apt-get -y install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip
# environment vars
- export SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip"
- export ANDROID_HOME="/opt/android-sdk-linux"
- export ANDROID_NDK_HOME="$ANDROID_HOME/ndk-bundle"
- export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_NDK_HOME:$PATH"
# download and unzip sdk
- wget -q $SDK_URL -O android-sdk.zip
- unzip android-sdk.zip -d $ANDROID_HOME && rm -f android-sdk.zip
# accept all licences http://stackoverflow.com/questions/38096225/automatically-accept-all-sdk-licences
- mkdir -p "$ANDROID_HOME/licenses"
- echo -e "8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
# download ndk
- sdkmanager "ndk-bundle"
# build
- chmod +x gradlew
- ./gradlew assembleDebug
ANDROID_NDK_HOME
路径似乎正确,因为我可以ls
该文件夹,它看起来是正确的。 ndk-build
上的权限也正确设置......
答案 0 :(得分:1)
错误是我在file
依赖项中缺少apt-get install
。
这是工作 bitbucket-pipelines.yml 。
(我还设法减少了整体apt-get依赖关系)
image: java:8
pipelines:
default:
- step:
caches:
- gradle
script:
# dependencies
- apt-get update && apt-get -y install file build-essential
# environment vars
- export SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip"
- export ANDROID_HOME="/opt/android-sdk-linux"
- export ANDROID_NDK_HOME="$ANDROID_HOME/ndk-bundle"
- export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_NDK_HOME:$PATH"
# download and unzip sdk
- wget -q $SDK_URL -O android-sdk.zip && unzip android-sdk.zip -d $ANDROID_HOME && rm -f android-sdk.zip
# accept all licences http://stackoverflow.com/questions/38096225/automatically-accept-all-sdk-licences
- mkdir -p "$ANDROID_HOME/licenses"
- echo -e "8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
# download ndk
- sdkmanager "ndk-bundle"
# build
- chmod +x gradlew
- ./gradlew assembleDebug
答案 1 :(得分:1)
这是简化版
image: umbrela/android-ndk-builder:latest
pipelines:
branches:
master:
- step:
caches:
- gradle
script:
# build
- chmod +x gradlew && ./gradlew assembleDebug
umbrela/android-ndk-builder:latest
FROM java:8
RUN apt-get update \
&& apt-get -y install file build-essential
ENV SDK_URL https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
ENV ANDROID_HOME /opt/android-sdk-linux
ENV ANDROID_NDK_HOME $ANDROID_HOME/ndk-bundle
ENV PATH $ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_NDK_HOME:$PATH
# accept all licences http://stackoverflow.com/questions/38096225/automatically-accept-all-sdk-licences
RUN mkdir -p "$ANDROID_HOME/licenses"
RUN echo 8933bad161af4178b1185d1a37fbf41ea5269c55 > $ANDROID_HOME/licenses/android-sdk-license
RUN echo 84831b9409646a918e30573bab4c9c91346d8abd > $ANDROID_HOME/licenses/android-sdk-preview-license
RUN ls $ANDROID_HOME/licenses
# download and unzip sdk
RUN mkdir -p $ANDROID_HOME \
&& wget -q $SDK_URL -O android-sdk.zip \
&& unzip android-sdk.zip -d $ANDROID_HOME \
&& rm -f android-sdk.zip
# download ndk
RUN sdkmanager "ndk-bundle"