failed to build some targets for AOSIP - android

my question is similar to #### failed to build some targets (1 seconds) #### but there were no further updates.
I'm trying to compile the image for AOSIP branch ten for OnePlus 7T and I used the following commands:
repo init -u git://github.com/AOSiP/platform_manifest.git -b ten
repo sync --force-sync --no-tags --no-clone-bundle
git clone https://github.com/AOSiP-Devices/device_oneplus_hotdogb.git
git clone https://github.com/AOSiP-Devices/device_oneplus_hotdogb.git ./device/oneplus/hotdogb
source build/envsetup.sh
lunch aosip_hotdogb-userdebug
make api-stubs-docs-update-current-api
Initially, when I did the lunch, I realised that the /prebuilts/go/darwin-x86 was missing and so I did "git clone https://android.googlesource.com/platform/prebuilts/go/darwin-x86". That allowed me to lunch successfully. However, when I run the make command I was met with the build failure with the following messages.
/bin/bash: nproc: command not found
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=10
AOSIP_VERSION=10-Quiche-hotdogb-20201220
TARGET_PRODUCT=aosip_hotdogb
TARGET_BUILD_VARIANT=userdebug
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-2a
TARGET_CPU_VARIANT=generic
BUILD_ID=QQ3A.200805.001
============================================
[ 29% 50/170] link out/soong/.bootstrap/gotestrunner/obj/a.out
FAILED: out/soong/.bootstrap/gotestrunner/obj/a.out
GOROOT='prebuilts/go/darwin-x86' prebuilts/go/darwin-x86/pkg/tool/darwin_amd64/link -o out/soong/.bootstrap/gotestrunner/obj/a.out.tmp out/soong/.bootstrap/gotestrunner/obj/gotestrunner.a && if cmp --quiet out/soong/.bootstrap/gotestrunner/obj/a.out.tmp out/soong/.bootstrap/gotestrunner/obj/a.out; then rm out/soong/.bootstrap/gotestrunner/obj/a.out.tmp; else mv -f out/soong/.bootstrap/gotestrunner/obj/a.out.tmp out/soong/.bootstrap/gotestrunner/obj/a.out; fi
runtime.main_main·f: function main is undeclared in the main package
[ 30% 51/170] link out/soong/.bootstrap/soong_env/obj/a.out
FAILED: out/soong/.bootstrap/soong_env/obj/a.out
GOROOT='prebuilts/go/darwin-x86' prebuilts/go/darwin-x86/pkg/tool/darwin_amd64/link -o out/soong/.bootstrap/soong_env/obj/a.out.tmp -L out/soong/.bootstrap/soong-env/pkg out/soong/.bootstrap/soong_env/obj/soong_env.a && if cmp --quiet out/soong/.bootstrap/soong_env/obj/a.out.tmp out/soong/.bootstrap/soong_env/obj/a.out; then rm out/soong/.bootstrap/soong_env/obj/a.out.tmp; else mv -f out/soong/.bootstrap/soong_env/obj/a.out.tmp out/soong/.bootstrap/soong_env/obj/a.out; fi
runtime.main_main·f: function main is undeclared in the main package
[ 30% 52/170] link out/soong/.bootstrap/loadplugins/obj/a.out
FAILED: out/soong/.bootstrap/loadplugins/obj/a.out
GOROOT='prebuilts/go/darwin-x86' prebuilts/go/darwin-x86/pkg/tool/darwin_amd64/link -o out/soong/.bootstrap/loadplugins/obj/a.out.tmp out/soong/.bootstrap/loadplugins/obj/loadplugins.a && if cmp --quiet out/soong/.bootstrap/loadplugins/obj/a.out.tmp out/soong/.bootstrap/loadplugins/obj/a.out; then rm out/soong/.bootstrap/loadplugins/obj/a.out.tmp; else mv -f out/soong/.bootstrap/loadplugins/obj/a.out.tmp out/soong/.bootstrap/loadplugins/obj/a.out; fi
runtime.main_main·f: function main is undeclared in the main package
[ 31% 53/170] link out/soong/.bootstrap/gotestmain/obj/a.out
FAILED: out/soong/.bootstrap/gotestmain/obj/a.out
GOROOT='prebuilts/go/darwin-x86' prebuilts/go/darwin-x86/pkg/tool/darwin_amd64/link -o out/soong/.bootstrap/gotestmain/obj/a.out.tmp out/soong/.bootstrap/gotestmain/obj/gotestmain.a && if cmp --quiet out/soong/.bootstrap/gotestmain/obj/a.out.tmp out/soong/.bootstrap/gotestmain/obj/a.out; then rm out/soong/.bootstrap/gotestmain/obj/a.out.tmp; else mv -f out/soong/.bootstrap/gotestmain/obj/a.out.tmp out/soong/.bootstrap/gotestmain/obj/a.out; fi
runtime.main_main·f: function main is undeclared in the main package
22:33:57 soong bootstrap failed with: exit status 1
#### failed to build some targets (2 seconds) ####
Thank you.

Can you please state the system you are building it on, moreover whenever you clone anything from https://android.googlesource.com/ , always specify the branch name using -b else you will end up cloning the default branch of the repo. For ex, if you are cloning darwin for a Android Q/10 Rom, clone it like
git clone https://android.googlesource.com/platform/prebuilts/go/darwin-x86 -b android-security-10.0.0_r49
You can find the branch names on left bottom of the website.

Related

GithubAction SelfHosted Runner launch error SocketException: Connection reset

We are configuring a self-hosted android runner for GithubActions, but when we run some command of gradlew, it crashes/stops sending an error connection reset.
Our docker file contains the basic for a android runner (few lines of code for gradle and sdk installation. the tools are also installed properly).
# Gradle
ENV GRADLE_VERSION 7.0.2
ENV GRADLE_HOME="/opt/gradle"
ENV GRADLE_SDK_URL https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
RUN curl -sSL "${GRADLE_SDK_URL}" -o gradle-${GRADLE_VERSION}-bin.zip \
&& unzip -q gradle-${GRADLE_VERSION}-bin.zip -d ${GRADLE_HOME} \
&& rm -rf gradle-${GRADLE_VERSION}-bin.zip \
&& chmod +775 /opt/gradle
ENV PATH ${GRADLE_HOME}/bin:$PATH
# Install Android SDK
RUN echo "SDK tools ${ANDROID_SDK_TOOLS_VERSION}" \
&& cd /opt \
&& chmod +775 . \
&& wget -q "https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip" -O android-commandline-tools.zip \
&& mkdir -p ${ANDROID_SDK_HOME}/cmdline-tools \
&& unzip -q android-commandline-tools.zip -d /tmp/ \
&& mv /tmp/cmdline-tools/ ${ANDROID_SDK_HOME}/cmdline-tools/latest \
&& rm android-commandline-tools.zip && ls -la ${ANDROID_SDK_HOME}/cmdline-tools/latest/
Then when in the workflow we do some ./gradlew command it crashes.
some example commands that crash:
> ./gradlew --version
> ./gradlew app:assembleBetaRelease --offline
Always same Error log:
Run ./gradlew --version
Downloading https://services.gradle.org/distributions/gradle-7.0.2-all.zip
Exception in thread "main" java.lang.RuntimeException: java.net.SocketException: Connection reset
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.net.SocketException: Connection reset
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:478)
at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472)
at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:160)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:111)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1426)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1336)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:450)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:421)
at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:572)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:197)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1592)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
at org.gradle.wrapper.Download.downloadInternal(Download.java:59)
at org.gradle.wrapper.Download.download(Download.java:45)
at org.gradle.wrapper.Install$1.call(Install.java:60)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
... 3 more
Error: Process completed with exit code 1.
It seems that tries to download Gradle, but it exist previously in dockerfile.
Did we forget some configuration in dockerfile or something similar?

AOSP version 11 build on Ubuntu 18.04 failed (getting segfaults)

I tried to build AOSP using the following commands:
repo init -u https://android.googlesource.com/platform/manifest -b android-11.0.0_r27
repo sync
. build/envsetup.sh
lunch aosp_x86_64-eng
make -j8
It runs for about 1.5 hours before erroring out. Here is what I see in the log:
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=11
TARGET_PRODUCT=aosp_x86_64
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=x86_64
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=x86_64
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-67-generic-x86_64-Ubuntu-18.04.5-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=RQ1A.210105.003
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl hardware/google/camera hardware/google/camera/devices/EmulatedCamera device/generic/goldfish device/generic/goldfish-opengl
============================================
ninja: no work to do.
ninja: no work to do.
No need to regenerate ninja file
No need to regenerate ninja file
No need to regenerate ninja file
Starting ninja...
[ 0% 1/4863] //external/apache-xml:apache-xml javac [common com.android.art.debug]
FAILED: out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/apache-xml.jar
rm -rf "out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/classes" "out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/anno" "out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/srcjars" && mkdir -p "out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/classes" "out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/anno" "out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/srcjars" && out/soong/host/linux-x86/bin/zipsync -d out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/srcjars -l out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/srcjars/list -f "*.java" && (if [ -s out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/srcjars/list ] || [ -s out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/apache-xml.jar.rsp ] ; then out/soong/host/linux-x86/bin/soong_javac_wrapper prebuilts/jdk/jdk11/linux-x86/bin/javac -J-Xmx2048M -J-XX:OnError="cat hs_err_pid%p.log" -J-XX:CICompilerCount=6 -J-XX:+UseDynamicNumberOfGCThreads -Xmaxerrs 9999999 -encoding UTF-8 -sourcepath "" -g -XDskipDuplicateBridges=true -XDstringConcat=inline -proc:none -Xlint:-dep-ann --system=out/soong/.intermediates/libcore/core-all-system-modules/android_common/system -source 1.9 -target 1.9 -d out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/classes -s out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/anno #out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/apache-xml.jar.rsp #out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/srcjars/list ; fi ) && out/soong/host/linux-x86/bin/soong_zip -jar -o out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/apache-xml.jar -C out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/classes -D out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/classes && rm -rf "out/soong/.intermediates/external/apache-xml/apache-xml/android_common_com.android.art.debug/javac/srcjars"
external/apache-xml/src/main/java/org/apache/xalan/extensions/ExpressionContext.java:23: error: package javax.xml.transform is not visible
import javax.xml.transform.ErrorListener;
^
(package javax.xml.transform is declared in module java.base, which does not export it)
external/apache-xml/src/main/java/org/apache/xalan/extensions/ExpressionContext.java:26: error: package org.w3c.dom is not visible
import org.w3c.dom.Node;
^
...
...
and it shows a long list of import errors just like the above two...
and
build/soong/scripts/jars-to-module-info-java.sh: line 29: 33922 Segmentation fault (core dumped) zipinfo -1 $j
Here is the shell script:
if [ -z "$1" ]; then
echo "usage: $0 <module name> <jar1> [<jar2> ...]" >&2
exit 1
fi
module_name=$1
shift
echo "module ${module_name} {"
for j in "$#"; do zipinfo -1 $j ; done \ # this is the line that segfaults
| grep -E '/[^/]*\.class$' \
| sed 's|\(.*\)/[^/]*\.class$| exports \1;|g' \
| sed 's|/|.|g' \
| sort -u
echo "}"
My system has 64 gb of RAM and I tried lowering the j value but get the same results. Repo sync is successful.
I'm not an usual contributor to S/O but I spent a lot of time fixing this particular problem for someone so I thought it'd be nice if I gave you my solution for this.
zipinfo is likely crashing because there is a preloaded library called libAppProtection, installed in /usr/local, that crashes under the conditions imposed by the AOSP build. I had found a workaround for this particular problem but if the cause of the problem is the same as what I faced, you will have further problems down the line for which you won't find a workaround.
GDB stacktrace of 'fec' another program crashing the same way
In Firefox shows only blank pages - even about:config is just white it describes that the library is related to Citrix Workspace App SDK.
If you observe the same thing I did when running zipinfo or fec (in my case) with GDB, I can only recommend that you remove this program while you deal with building the AOSP sources. I know this has worked and did not cause any drawbacks for the client. Maybe just disabling the preloaded library in /etc/ld.so.preload would work but I have not tried that and since I don't know anything about Citrix, I would advise against doing that.

Android NDK CI using Bitbucket Pipelines

I am trying to build an NDK Android project using Bitbucket Pipelines continuous integration using ndk-build (not the newer CMAKE). But I am getting the following error when calling ./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
bitbucket-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
The ANDROID_NDK_HOME path seems correct as I can ls the folder and it looks correct. The permission on ndk-build also looks correctly set...
The error was that I was missing file in the apt-get install dependencies.
Here is the working bitbucket-pipelines.yml.
(I also managed to reduce the overall apt-get dependencies)
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
Here is a simplified version
image: umbrela/android-ndk-builder:latest
pipelines:
branches:
master:
- step:
caches:
- gradle
script:
# build
- chmod +x gradlew && ./gradlew assembleDebug
Where umbrela/android-ndk-builder:latest is
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"

Continuous Integration with Jenkins for React Native (iOS + Android) project

It is possible to implement Continuous Integration for a React Native app using Jenkins? I haven't found a guide to do this. If there are also other solution, what is the best one? Also, a Mac OS machine is mandatory for iOS project?
Yes, it is totally possible. You only have to execute all actions from the command line instead of XCode or the IDE of your choice. In the case of iOS, have a look at the react-native bundle command to create the JS bundle and xcodebuild and xcrun for compiling the native code. In Android it is a bit easier, since you have the gradle assembleRelease task. Before that you have to run npm install to get all your dependencies, but that should roughly be it.
As for iOS development, unfortunately there is no way around it, you do need an OS X machine.
The first thing is to get a command line build working for both Android and iOS. You can peak at the Xcode or Android Studio logs and copy some of the commands.
I put a build.sh script in the ios and android folders that I can call from a Jenkins job to build respective targets. You could have a build.sh in your project root that calls both.
Todo: I want to figure out how to run eslint airbnb in a Jenkins job and generate a report?
Here is my iOS build.sh script that works with Xcode 9:
#!/bin/sh
############################################
# File: build.sh
# -----------------------
# Author: edOfTheMountain#acme.com
#
# Command line build:
# 1) clean
# 2) build
# 3) archive
# 4) export IPA
#
# http://shashikantjagtap.net/xcodebuild-deploy-ios-app-command-line/
# https://help.apple.com/itc/apploader/e3#/apdATD1E53-D1E1A1303-D1E53A1126
#
isInPath=$(which xcodebuild)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error xcodebuild not found in path"
exit 1
fi
isInPath=$(which xcrun)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error xcrun not found in path"
exit 1
fi
echo "### Start: Cleaning ###############################################################"
rm -rf build
xcodebuild -project MyApp.xcodeproj -scheme MyApp -destination generic/platform=iOS clean
echo "### Done: Cleaning ###############################################################"
# Analyze
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -sdk iphoneos clean analyze
echo "### Start: Building ###############################################################"
# xcodebuild -project MyApp.xcodeproj -target MyApp -showBuildSettings
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -destination generic/platform=iOS build
# Run pod install once before building workspace
pod install
# Now using a Podfile so have to build workspace not build project
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -destination generic/platform=iOS build
echo "### Done: Building ###############################################################"
CFBundleShortVersionString=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" ./MyApp/Info.plist`
CFBundleVersion=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" ./MyApp/Info.plist`
echo "CFBundleShortVersionString: ${CFBundleShortVersionString}"
echo "CFBundleVersion: ${CFBundleVersion}"
ipaFileName=MyApp.ipa
renameIpaFileName="field-scout-${CFBundleShortVersionString}.${CFBundleVersion}.ipa"
echo "### Start: Archiving ###############################################################"
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MyApp.xcarchive
# Now using a Podfile so have to build workspace not build project
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MyApp.xcarchive
echo "### Done: Archiving ###############################################################"
echo "### Start: Exporting ###############################################################"
xcodebuild -exportArchive -archivePath $PWD/build/MyApp.xcarchive -exportOptionsPlist MyApp/ExportOptions.plist -exportPath $PWD/build
ls -al build
echo "### Done: Exporting ###############################################################"
appArchiveFile=build/${ipaFileName}
if [ ! -f "${appArchiveFile}" ]; then
echo "*** Error file not found: ${appArchiveFile}"
exit 1
fi
# Extract and verify archive contents
echo "### Unzip: ${ipaFileName} ###############################################################"
( cd build; unzip -q ${ipaFileName} )
( cd build/Payload; xcrun codesign -dv MyApp.app/ )
outputFile=build/Payload/MyApp.app
if [ ! -d "${outputFile}" ]; then
echo "*** Error file not found: ${outputFile}"
exit 1
fi
rm -rf ./build/Payload
rm -rf ./build/Symbols
# altool is used to verify iOS IPA files
altool_path=/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/Current/Support
isInPath=$(which altool)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error altool not found in path"
echo "Expected altool path:\n ${altool_path}"
exit 1
fi
# altool validate will trigger a user dialog first time it is run.
# On a jenkins slave you will need to execute manually in a console once, to allow keychain access.
# $ altool --validate-app -f file -u username [-p password] [--output-format xml]
# $ altool --upload-app -f file -u username [-p password] [--output-format xml]
altool --validate-app -f build/${ipaFileName} -u edOfTheMountain#acme.com -p #keychain:"Application Loader: edOfTheMountain#acme.com"
altool --validate-app -f build/${ipaFileName} -u edOfTheMountain#acme.com -p #keychain:"Application Loader: edOfTheMountain#acme.com" --output-format xml > build/validate.xml
altoolValidate=$?
if [ ${altoolValidate} -ne 0 ]; then
echo "*** Error IPA failed to validate: build/${ipaFileName}"
echo "See: build/validate.xml"
exit 1
fi
echo "Rename build/${ipaFileName} to build/${renameIpaFileName}"
mv ./build/${ipaFileName} ./build/${renameIpaFileName}
echo ##############################
echo Done
echo ##############################
echo Ready to upload archive to iTunes:
echo " ${appArchiveFile}"
echo
uploadExample="$( echo altool --upload-app -f build/${renameIpaFileName} -u edOfTheMountain#acme.com -p #keychain:"Application Loader: edOfTheMountain#acme.com" )"
echo "Upload Example:\n ${uploadExample}"
echo

Android valgrind build fails

Hello I'm trying to build valgrind for android-arm. On Linux Mint 13 it fails with:
$ make
echo "# This is a generated file, composed of the following suppression rules:" > default.supp
echo "# " exp-sgcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp >> default.supp
cat exp-sgcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp >> default.supp
make all-recursive
make[1]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1'
Making all in include
make[2]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/include'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/include'
Making all in VEX
make[2]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
make all-am
make[3]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../include -I../VEX/pub -DVGA_arm=1 -DVGO_linux=1 -DVGP_arm_linux=1 -DVGPV_arm_linux_vanilla=1 -Ipriv -m32 -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wno-format-zero-length -fno-strict-aliasing -fno-builtin -marm -mcpu=cortex-a8 -Wbad-function-cast -Wcast-qual -Wcast-align -fstrict-aliasing -Wno-long-long -Wno-pointer-sign -fno-stack-protector -MT libvex_arm_linux_a-main_globals.o -MD -MP -MF .deps/libvex_arm_linux_a-main_globals.Tpo -c -o libvex_arm_linux_a-main_globals.o `test -f 'priv/main_globals.c' || echo './'`priv/main_globals.c
gcc: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
cc1: error: unrecognised command line option ‘-marm’
priv/main_globals.c:1:0: error: bad value (cortex-a8) for -mtune= switch
make[3]: *** [libvex_arm_linux_a-main_globals.o] Error 1
make[3]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1'
make: *** [all] Error 2
I am using ndk-r8e and valgrind 3.8.1. The configure ends with:
Maximum build arch: arm
Primary build arch: arm
Secondary build arch:
Build OS: linux
Primary build target: ARM_LINUX
Secondary build target:
Platform variant: vanilla
Primary -DVGPV string: -DVGPV_arm_linux_vanilla=1
Default supp files: exp-sgcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp
What can I do to fix this? Alternatively, are there any pre-built android-arm valgrind binaries that I can use?
For building and installing Valgrind for Android use the bash script below, which I prefer to call build_valgrind.sh
To run with RUN_HELLO_JNI_THROUGH_VALGRIND=true you need two additional scripts (bootstrap_valgrind.sh, start_valgrind.sh) in the directory you run the script below from.
Running the script with the RUN_HELLO_JNI_THROUGH_VALGRIND=true flag will build the hello-jni application from the samples directory inside the Android NDK HOME, deploy it to the phone and run it through Valgrind, using either callgrind or memcheck tool, which you can specify in the start_valgrind.sh script.
The other two scripts are described here: https://stackoverflow.com/a/19235439/313113
Here's my directory structure:
|-- build_valgrind.sh (the script below)
|-- bootstrap_valgrind.sh (second script from https://stackoverflow.com/a/19235439/313113)
|-- start_valgrind.sh (first script from https://stackoverflow.com/a/19235439/313113)
|-- valgrind-3.10.0 (will be extracted by build_valgrind.sh)
`-- valgrind-3.10.0.tar.bz2 (will be downloaded by build_valgrind.sh)
I've tested that its working (memcheck and callgrind tools) on a Samsung Galaxy Nexus device with CyanogenMod 10.2.1 and Android 4.3.1 and CyanogenMod 11 20140804 snapshot, Android 4.4.4
You can see the file size of the generated output with: adb shell ls -lR "/sdcard/*grind*"
The build_valgrind.sh script:
#!/usr/bin/env bash
#set -x
function extract()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xvjf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xvf "$1" ;;
*.tbz2) tar xvjf "$1" ;;
*.tgz) tar xvzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "$1 cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
RUN_HELLO_JNI_THROUGH_VALGRIND=true
VALGRIND_VERSION="3.10.0"
VALGRIND_EXTENSION=".tar.bz2"
VALGRIND_DIRECTORY="valgrind-${VALGRIND_VERSION}"
VALGRIND_TARBALL="valgrind-${VALGRIND_VERSION}${VALGRIND_EXTENSION}"
# Only download Valgrind tarball again if not already downloaded
if [[ ! -f "${VALGRIND_TARBALL}" ]]; then
wget -v -nc "http://valgrind.org/downloads/${VALGRIND_TARBALL}"
fi
# Only extract Valgrind tarball again if not already extracted
if [[ ! -d "$VALGRIND_DIRECTORY" ]]; then
extract "$VALGRIND_TARBALL"
fi
# Ensure ANDROID_NDK_HOME is set
if [[ ! -z "$ANDROID_NDK_HOME" ]]; then
export ANDROID_NDK_HOME="$HOME/Software/Android/android-ndk-r10c"
fi
# Ensure ANDOID_SDK_HOME is set
if [[ ! -z "$ANDROID_SDK_HOME" ]]; then
export ANDROID_SDK_HOME="$HOME/Software/Android/android-sdk/"
fi
if [[ ! -d "$VALGRIND_DIRECTORY" ]];
then
echo "Problem with extracting Valgrind from $VALGRIND_TARBALL into $VALGRIND_DIRECTORY!!!"
exit -1
fi
# Move to extracted directory
cd "$VALGRIND_DIRECTORY"
# ARM Toolchain
ARCH_ABI="arm-linux-androideabi-4.9"
export AR="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar"
export LD="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld"
export CC="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc"
export CXX="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++"
[[ ! -d "$ANDROID_NDK_HOME" || ! -f "$AR" || ! -f "$LD" || ! -f "$CC" || ! -f "$CXX" ]] && echo "Make sure AR, LD, CC, CXX variables are defined correctly. Ensure ANDROID_NDK_HOME is defined also" && exit -1
# Configure build
export HWKIND="nexus_s"
ANDROID_PLATFORM=android-18
export CPPFLAGS="--sysroot=$ANDROID_NDK_HOME/platforms/${ANDROID_PLATFORM}/arch-arm -DANDROID_HARDWARE_$HWKIND"
export CFLAGS="--sysroot=$ANDROID_NDK_HOME/platforms/${ANDROID_PLATFORM}/arch-arm"
# BUG: For some reason file command is unable to detect if the file does not exist with ! -f , it says it doesn't exist even when it does!!!
BUILD=false
if [[ "${VALGRIND_DIRECTORY}/Inst/data/local/Inst/bin/valgrind" = *"No such file or directory"* ]]; then
BUILD=true
fi
if [[ "$BUILD" = true ]];
then
./configure --prefix="/data/local/Inst" \
--host="armv7-unknown-linux" \
--target="armv7-unknown-linux" \
--with-tmpdir="/sdcard "
[[ $? -ne 0 ]] && echo "Can't configure!" && exit -1
# Determine the number of jobs (commands) to be run simultaneously by GNU Make
NO_CPU_CORES=$(grep -c ^processor /proc/cpuinfo)
if [ $NO_CPU_CORES -le 8 ]; then
JOBS=$(($NO_CPU_CORES+1))
else
JOBS=${NO_CPU_CORES}
fi
# Compile Valgrind
make -j "${JOBS}"
[[ $? -ne 0 ]] && echo "Can't compile!" && exit -1
# Install Valgrind locally
make -j "${JOBS}" install DESTDIR="$(pwd)/Inst"
[[ $? -ne 0 ]] && echo "Can't install!" && exit -1
fi
# Push local Valgrind installtion to the phone
if [[ $(adb shell ls -ld /data/local/Inst/bin/valgrind) = *"No such file or directory"* ]];
then
adb root
adb remount
adb shell "[ ! -d /data/local/Inst ] && mkdir /data/local/Inst"
adb push Inst /
adb shell "ls -l /data/local/Inst"
# Ensure Valgrind on the phone is running
adb shell "/data/local/Inst/bin/valgrind --version"
# Add Valgrind executable to PATH (this might fail)
adb shell "export PATH=$PATH:/data/local/Inst/bin/"
fi
if [ $RUN_HELLO_JNI_THROUGH_VALGRIND = true ]; then
PACKAGE="com.example.hellojni"
# The location of the Hello JNI sample application
HELLO_JNI_PATH="$ANDROID_NDK_HOME/samples/hello-jni"
pushd "$HELLO_JNI_PATH"
# Update build target to the desired Android SDK version
ANDROID_PROJECT_TARGET="android-18"
android update project --target "$ANDROID_PROJECT_TARGET" --path . --name hello-jni --subprojects
# Enable Android NDK build with Ant
echo '<?xml version="1.0" encoding="utf-8"?>
<project name="HelloJni" basedir="." default="debug">
<target name="-pre-build">
<exec executable="${ndk.dir}/ndk-build" failonerror="true"/>
</target>
<target name="clean" depends="android_rules.clean">
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="clean"/>
</exec>
</target>
</project>
' > "custom_rules.xml"
# Set NDK HOME for Ant (only if not already set)
if ! grep -P -q "ndk.dir=.+" "local.properties" ; then
echo -e "\nndk.dir=$ANDROID_NDK_HOME" >> "local.properties"
fi
# Fix for Java 8 warning (warning: [options] source value 1.5 is obsolete and will be removed in a future release)
echo "java.compilerargs=-Xlint:-options" >> "ant.properties"
# Workaround INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES error
adb uninstall "$PACKAGE"
# Build Hello JNI project in debug mode and install it on the device
ant clean && ant debug && ant installd
popd
cd ..
# Start HelloJNI app
adb shell am start -a android.intent.action.MAIN -n $PACKAGE/.HelloJni
# Make the script executable
chmod a+x bootstrap_valgrind.sh
# Run application through Valgrind on the phone
/usr/bin/env bash bootstrap_valgrind.sh
adb shell ls -lR "/sdcard/*grind*"
adb shell ls -lR "/storage/sdcard0/*grind*"
adb shell ls -lR "/storage/sdcard1/*grind*"
fi
exit 0
This gets valgrind to compile for me on linux. (using android-ndk-r8e and valgrind-3.8.1)
There was no need to run autogen.sh since I downloaded the tar ball from the website.
Also make sure the TOOLCHAIN= line points to a valid toolchain.
export NDK_HOME=$HOME/Downloads/android-ndk-r8e
export HWKIND=generic
export TOOLCHAIN=$NDK_HOME/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi
export AR=$TOOLCHAIN-ar
export LD=$TOOLCHAIN-ld
export CC=$TOOLCHAIN-gcc
CPPFLAGS="--sysroot=$NDK_HOME/platforms/android-14/arch-arm -DANDROID_HARDWARE_$HWKIND" \
CFLAGS="--sysroot=$NDK_HOME/platforms/android-14/arch-arm" \
./configure --prefix=/data/local/Inst \
--host=armv7-unknown-linux --target=armv7-unknown-linux \
--with-tmpdir=/sdcard
make
It eventually came up with a compile error saying
$NDK_HOME/platforms/android-14/arch-arm/usr/include/elf.h:58:3: error: unknown type name 'uint32_t'
It seem like someone forgot to add #include <stdint.h> somewhere. To fix this I edited $NDK_HOME/platforms/android-14/arch-arm/usr/include/elf.h and added #include <stdint.h> to the include section of this header. NOTE: This is probably not the best fix but it is the one that I came up with that fixed the compilation errors.
On mac I was able to get it to compile up until the unknown type uint32_t part by changing how the configure script checks the kernel version.
Inside the configure script search of a line kernel=`uname -r` and change it to kernel=3.9.2. (There are two kernel=`uname -r` lines replace the first one or both if you feel like it)
This stops the configure script from looking at the host kernel when deciding how it should build valgrind. (uname -r grabs the host kernel)
I believe adding the #include <stdint.h> to elf.h should work on mac to but I have not tested it.
in android tutorial one option is missed
RANLIB, after I set it - I finally compiled valgrind-3.11.0 on osx for android
#/bin/sh
echo "NKDROOT: " $NDKROOT
export ANRDOID_TOOLCHAIN="arm-linux-androideabi-4.9"
# Set up toolchain paths.
#
# For ARM
export AR=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar
export LD=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ld
export CC=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc
export CXX=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++
export RANLIB=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ranlib
echo "AR: " $AR
echo "LD: " $LD
echo "CC: " $CC
echo "CXX: " $CXX
[[ ! -d "$NDKROOT" || ! -f "$AR" || ! -f "$LD" || ! -f "$CC" || ! -f "$CXX" ]] && echo "Make sure AR, LD, CC, CXX variables are defined correctly. Ensure NDKROOT is defined also" && exit -1
./autogen.sh
#if [ $? -ne 0 ]
#then
# exit 1
#else
# echo "autogen success!"
#fi
# for ARM
ANDROID_PLATFORM=android-3
ANDROID_SYSROOT="$NDKROOT/platforms/${ANDROID_PLATFORM}/arch-arm"
echo "SYSROOT: " $ANDROID_SYSROOT
export HWKIND=generic
export CPPFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
export CFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
export LDFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
export ARFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
./configure \
--prefix=/data/local/Inst \
--host=armv7-unknown-linux --target=armv7-unknown-linux \
--with-tmpdir=/sdcard
if [ $? -ne 0 ]
then
exit 1
else
echo "configure success!"
fi
# note: on android emulator, android-14 platform was also tested and works.
# It is not clear what this platform nr really is.
make -j7
if [ $? -ne 0 ]
then
exit 1
else
echo "build success!"
fi
make -j7 install DESTDIR=`pwd`/Inst
The problem I had was that the configure script was ignoring the environment variables. To configure the make file I instead did this:
sudo ./configure --prefix=/data/local/Inst --host=armv7-unknown-linux --target=armv7-unknown-linux --with-tmpdir=/sdcard0 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HWKIND" CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" CC=$CC LD=$LD AR=$AR
This ensures the variables are set properly and works with Linux Mint 13. It does not work on OSX Mountain Lion however. I'd advise anyone using OSX without access to a linux installation to try using linux on a virtual machine.

Categories

Resources