Android Studio armv7 project - android

I'm trying to run these projects which uses jni to do a arm assembly call im using android studio but it has external makefiles im a little bit lost
https://github.com/Miouyouyou/ARMv7-Java-JNI-call
https://github.com/Miouyouyou/ARMv7-Java-JNI-return
I am using android studio on windows, when i try to do make using the android studio terminal (using gnu make) i get
armv7a-hardfloat-linux-gnueabi-as -o decypherArcane.o decypherArcane.s
process_begin: CreateProcess(NULL, armv7a-hardfloat-linux-gnueabi-as -o decypher
make (e=2): The system cannot find the file specified.
make: *** [decypherArcane.o] Error 2
i think it will perhaps work if i convert the makefile into a .bat one
This is the makefile (it is outside the root of the android studio project)
`CROSS_COMPILE = armv7a-hardfloat-linux-gnueabi-
LD = $(CROSS_COMPILE)ld.gold
AS = $(CROSS_COMPILE)as
ANDROID_APK_NATIVE_LIB_DIR = ./apk/app/src/main/jniLibs
ANDROID_LIBNAME = libarcane.so
SOURCE = decypherArcane.s
OBJECT = decypherArcane.o
.PHONY: all
all: $(OBJECT)
$(LD) -shared --dynamic-linker=/system/bin/linker --hash-style=sysv -o $(ANDROID_LIBNAME) $(OBJECT)
mkdir -p $(ANDROID_APK_NATIVE_LIB_DIR)/armeabi{,-v7a}
cp $(ANDROID_LIBNAME) $(ANDROID_APK_NATIVE_LIB_DIR)/armeabi
cp $(ANDROID_LIBNAME) $(ANDROID_APK_NATIVE_LIB_DIR)/armeabi-v7a
.PHONY: install
install: all
make -C apk
$(OBJECT): $(SOURCE)
$(AS) -o $(OBJECT) $(SOURCE)
.PHONY: clean
clean:
$(RM) $(OBJECT) $(ANDROID_LIBNAME)
.PHONY: distclean
distclean: clean
$(RM) $(ANDROID_APK_NATIVE_LIB_DIR)/armeabi/$(ANDROID_LIBNAME)
$(RM) $(ANDROID_APK_NATIVE_LIB_DIR)/armeabi-v7a/$(ANDROID_LIBNAME)
`

I've updated these two projects, ARMv7-Java-JNI-return and ARMv7-Java-JNI-call, making the build process slightly easier on Windows.
You'll need :
The Android NDK path in your PATH environment variable.
A Java JDK to compile and install the sample APK
For each project :
Browse the folder where you cloned the repository
Open a Command window here using Shift + Right Click → Open a Command window here
Type mkBuild
If everything goes fine, you should see something like this :
[armeabi] Compile arm : arcane <= decypherArcane.s
[armeabi] SharedLibrary : libarcane.so
[armeabi] Install : libarcane.so => apk/app/src/main/jniLibs/armeabi/libarcane.so
[armeabi-v7a] Compile arm : arcane <= decypherArcane.s
[armeabi-v7a] SharedLibrary : libarcane.so
[armeabi-v7a] Install : libarcane.so => apk/app/src/main/jniLibs/armeabi-v7a/libarcane.so
If that's the case, plug your phone and type the following in the opened Command Window :
cd apk
gradlew installDebug
Again, if everything goes fine, then your phone should have a new Android APP named either Decyph'App or Wild Assembly !. Run the new app and see the results.
Now, if you run into any issue while trying to build, install or run these samples, please open an issue ticket on Github or Gitlab mirrors.

Related

How to generate libpjsua2.so for x86 abi in jnilibs

I want to test the app with android 10 in emulator.So for that I only have "armeabi", "armeabi-v7a","arm64-v8a" in jnilibs. But running app with android 10 device(Emulator), requires x86 abi. So for that first I have downloaded ndk for x86.And the second thing is I want to generate libpjsua2.so for x86 abi.
I am using pjsip library.
I have referred to https://trac.pjsip.org/repos/wiki/Getting-Started/Android. What I have tried is,
1) Downloaded latest pjsip version and extracted in folder.
2) Followed the steps given in pjsip website as below,
$ cd /path/to/your/pjsip/dir
$ export ANDROID_NDK_ROOT=/path_to_android_ndk_dir
$ ./configure-android
$ make dep && make clean && make
$ cd /path/to/your/pjsip/dir
$ make clean
# cleanup pjsua sample app
$ cd pjsip-apps/src/pjsua/android/jni
$ make clean
# also cleanup pjsua2 sample app (SWIG)
$ cd /path/to/your/pjsip/dir
$ cd pjsip-apps/src/swig
$ make clean
$ cd pjsip-apps/src/swig
$ make clean
TARGET_ABI=x86 ./configure-android --use-ndk-cflags
Got error when reached above code,
LDFLAGS = --sysroot= -L/libs/x86/
LIBS = -lgnustl_static -lc -lgcc -ldl
AR = /home/Android/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
RANLIB = /home/Android/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
TARGET_HOST = llvm-linux-android
TARGET_ABI = x86
checking build system type... x86_64-unknown-linux-gnu
checking host system type... Invalid configuration `llvm-linux-android': machine `llvm' not recognized
aconfigure: error: /bin/sh ./config.sub llvm-linux-android failed
In my pjsip2.7 folder I found a folder named llvm but that is a empty folder. I doesn't know What is that. I am using cent os 7. Why I am getting this error? What do I need to do to overcome this.
Try compile with this builder
replace in ./config.cong you are using 2.10
# PJSIP Version to download
PJSIP_VERSION=2.10
./prepare-build-system
and then
./build

ubuntu 15.10 64bit build Android source 5.0 version

How can I fix this problem?When I was building the Android source of 5.0 with
'make -j4', it was causing a problem.
This is the error log:
Install: out/host/linux-x86/bin/acp
Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y
prebuilts/misc/linux-x86/bison/bison -d -o out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
logtags: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/content/EventLogTags.java <= frameworks/base/core/java/android/content/EventLogTags.logtags
prebuilts/misc/linux-x86/bison/bison: m4 子进程失败
build/core/binary.mk:539: recipe for target 'out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp' failed
make: *** [out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 1
make: *** 正在等待未完成的任务....
frameworks/base/tools/aidl/aidl_language_l.l:55: warning, 无法匹配规则
flex-2.5.39: fatal internal error, exec of /usr/bin/m4 failed
build/core/binary.mk:576: recipe for target 'out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp' failed
make: *** [out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 1
make: *** Deleting file 'out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp'
logtags: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/speech/tts/EventLogTags.java <= frameworks/base/core/java/android/speech/tts/EventLogTags.logtags
In my case, I get similar error when build Marshmallow 6.0.1_r1 in Ubuntu 18.04.
If you get similar errors like this:
build/core/binary.mk:646: recipe for target 'out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp' failed
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Aborted (core dumped)
Look at the line carefully, it's a core dumped, so I use coredumpctl list, navigate to the end of list with G, then figure out the core dump executed path (right column) is prebuilts/misc/linux-x86/flex/flex-2.5.39
And the PREBUILT file shows:
xb#dnxb:~/my_android_src/prebuilts/misc/linux-x86/flex$ cat PREBUILT
The objects in this prebuilt directory can be rebuilt
using the source archive hosted at
http://sourceforge.net/projects/flex/files/
Commands:
./configure
make CFLAGS="-static" LDFLAGS="-static"
# (Disregard the errors at the end of the build)
rm flex
make CFLAGS="-static" LDFLAGS="-static" flex
# Copy the linker command line, replace it with static libm.a
gcc -static -static -o flex ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o /usr/lib/x86_64-linux-gnu/libm.a
xb#dnxb:~/my_android_src/prebuilts/misc/linux-x86/flex$
That's it, the first 2 lines said that you probably need to rebuild yourself if something went wrong since this flex-2.5.39 binary is prebuilt in another platform.
So simply untar the flex-2.5.39.tar.gz of this directory, go to the extracted flex-2.5.39 directory, then follows the PREBUILT instruction above.
In short, you need to do the following steps:
cd <ANDROID_TREE_DIR>/prebuilts/misc/linux-x86/flex
tar -zxvf flex-2.5.39.tar.gz
cd flex-2.5.39
make CFLAGS="-static" LDFLAGS="-static"
rm flex
make CFLAGS="-static" LDFLAGS="-static" flex
/bin/bash ./libtool --tag=CC --mode=link gcc -static -static -o flex ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o lib/libcompat.la /usr/lib/x86_64-linux-gnu/libm.a
cd ..
cp flex-2.5.39/flex .
mv flex flex-2.5.39
ls -la
flex-2.5.39 #### <<- YOUR new generated file
flex-2.5.39.tar.gz
MODULE_LICENSE_BSD_LIKE
NOTICE
PREBUILT
Now try to do make <module> -j4 again, no longer abort on such error.
p/s: Alternative way will be LANG=C make pm -j4 if you see something like LC_* error message.
p/s2: I also need symlink ld as below to fixed 'out/host/linux-x86/obj/lib/libart.so' failed and error: unsupported reloc 42:
xb#dnxb:~/my_android_src$ cp prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld ../ld_bk #backup android source's ld first
xb#dnxb:~/my_android_src$ rm prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld #remove android source's ld
xb#dnxb:~/my_android_src$ ln -s /usr/bin/ld.gold prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld #create symlink for android source's ld to system's ld.gold
Check carefully you have all the required packages installed https://source.android.com/source/initializing.html

How to compile clk, the Android bootloader?

https://github.com/n0d3/lk – this is the repository holding source code for clk 1.5, which is a bootloader for Android and which I am trying to compile. Compiled packages can be found; however, I need to customize it. How can I compile it?
Running make returns the following:
$ make
makefile:22: *** No project specified. Use "make projectname" or put "PROJECT := projectname" in local.mk. Stop.
Running make htcleo returns the following:
$ make htcleo
make[1]: Entering directory '/cygdrive/c/Users/Domas/lk'
make[1]: arm-eabi-gcc: Command not found
LIBGCC =
CFLAGS = -O2 -g -fno-builtin -finline -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -include ./build-htcleo/config.h -ffunction-sections -fdata-sections -mlittle-endian -mfpu=neon -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mthumb-interwork -mthumb -D__thumb__
including app/aboot dev/battery dev/fbcon dev/keys lib/debug lib/devinfo lib/heap lib/libc lib/ptable
generating build-htcleo/config.h
compiling arch/arm/start.S
make[1]: arm-eabi-gcc: Command not found
arch/arm/compile.mk:30: recipe for target 'build-htcleo/arch/arm/start.o' failed
make[1]: *** [build-htcleo/arch/arm/start.o] Error 127
make[1]: Leaving directory '/cygdrive/c/Users/Domas/lk'
makefile:15: recipe for target 'make-make' failed
make: *** [make-make] Error 2
As you can see the make breaks on make[1]: arm-eabi-gcc: Command not found. I was able to compile an older version (which had a different compilation process) by using a CodeSourcery toolchain, which has arm-none-eabi-gcc.exe, but not arm-eabi-gcc.exe, which seems to be needed to compile this version.
Note:
I appreciate that this might not be a popular type of question here on SO; however, I've been banging my head on this one the whole day, and could really use some guidance.
I managed to compile it. What I did was find a git repository that had a compilation script and some additional files for compilation along side the source code, but it was the old source code. So I downloaded this project, and replaced the source code with a recent one, and the compilation script worked. Below instructions, most of it is copy paste from xda forums:
Download this zip archive here: https://github.com/cedesmith/cLK/archive/master.zip
It's the old source code, but it has the necessary scripts to make compilation easy.
Unzip the archive so that the compile script's path is ~/cLK/compile
Delete the ~/cLK/lk subdirectory (this is the old source code).
Download the new source code: git clone https://github.com/n0d3/lk
Now you should have the new source code in ~/cLK/lk. On to the actual compilation: this will depend on whether you're on Linux or Windows:
Linux
on Debian:
sudo apt-get update
sudo apt-get install gcc make git wget unzip zip libc6-dev-amd64 libc6-dev
on Fedora:
yum install gcc make git wget unzip zip
Now download the CodeSourcery toolchain:
wget http://www.codesourcery.com/sgpp/lite/arm/portal/package5353/public/arm-none-eabi/arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
tar xvfj arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
export PATH=$HOME/clk/arm-2009q3/bin:$PATH
Finally, compile:
cd ~/cLK
./compile clean
If everything goes well, you'll find the RUU_signed in this folder: bin/RUU_signed.nbh
Windows
You'll need Cygwin:
Download, the following file, and execute it http://www.cygwin.com/setup.exe
Click Next
Click "Install from internet" and click Next
Click Next (to accept the default directory to install)
Click Next (to accept the default directory for local Package directory)
Click "Direct Connection", and click Next
Select a "local mirror", and click Next
Now in the search bar, you need to search for the following things to install
gcc
make
git
wget
zip
unzip
Once selected click Next to continue, and Finish
Fire up the cygwin terminal (mintty); the following commands probably don't work in cmd.exe.
Now download CodeSourcery toolchain and yang:
wget http://www.codesourcery.com/sgpp/lite/arm/portal/package5354/public/arm-none-eabi/arm-2009q3-68-arm-none-eabi-i686-mingw32.tar.bz2
tar xvfj arm-2009q3-68-arm-none-eabi-i686-mingw32.tar.bz2
wget http://htc-flasher.googlecode.com/files/yang-1.1_win32.zip
cd cLK/bin
rm -rf yang
mkdir yang
unzip ../../yang-1.1_win32.zip yang/yang.exe
mv yang/yang.exe .
cd ..
sed -i s/yang/yang.exe/g compile
And finally, compile:
export PATH=$HOME/arm-2009q3/bin:$PATH
cd ~/cLK
./compile clean
Now your RUU_signed.nbh will be located in the following folder bin/RUU_signed.nbh

Cross-Compiling GCC for ARM Android. Build Fails At GMP

I'm at the end of my rope on this one.
I'm new to Android development. I've read the GCC install documentation and parts of Embedded Android. I'm trying to cross-compile gcc 4.7 using an Android NDK toolchain built with the make-standalone-toolchain.sh script. I'm using the gcc and binutils source files from the NDK toolchain sources.
I copied the gcc-4.7 and binutils-2.23 into a directory gcc-src and created a 'build' directory alongside both, as follows:
gcc-src/gcc-4.7
gcc-src/binutils-2.23
gcc-src/build
I've symlinked the sources for
bfd,
gas,
gprof,
ld,
gprof
opcodes
from binutils to the gcc-4.7 source directory. I also ran the script in contrib/ that downloads the relevant sources for
gmp,
mpfr
mpc
and creates the appropriate symlinks
I've run configure with the (latest) following options:
sh ../gcc-4.7/configure --prefix=/usr/arm --disable-option-checking --host=arm-linux-eabi
--target=arm-linux-eabi --with-sysroot=/usr/sysroot --with-build-sysroot=/usr/sysroot --with-build-time-tools=/usr/bin --program-prefix=arm-
--disable-multilib --with-cpu=arm7 --enable-languages=c,c++,lto --disable-werror --disable-nls CC=arm-linux-androideabi-gcc GCC=arm-linux-androideabi-gcc
CFLAGS='-Wall -g -mfloat-abi=softfp -mbionic -mandroid -Wl,-lsupc++ -Wl,-lgnustl_shared'
CPPFLAGS='-Wall -g -mbionic -mandroid' LDFLAGS='-Wl,-lsupc++ -Wl,-lgnustl_shared' CXX=arm-linux-androideabi-g++
LD=arm-linux-androideabi-ld STRIP=arm-linux-androideabi-strip OBJDUMP=arm-linux-androideabi-objdump READELF=arm-linux-androideabi-readelf
AS=arm-linux-androideabi-as NM=arm-linux-androideabi-nm
LIBS='-lc -ldl -lm' CC_FOR_TARGET=arm-linux-androideabi-gcc CPP_FOR_TARGET=arm-linux-androideabi-gcc CXX_FOR_TARGET=arm-linux-androideabi-g++
GCC_FOR_TARGET=arm-linux-androideabi-gcc RANLIB_FOR_TARGET=arm-linux-androideabi-gcc-ranlib LD_FOR_TARGET=arm-linux-androideabi-ld
AS_FOR_TARGET=arm-linux-androideabi-as NM_FOR_TARGET=arm-linux-androideabi-gcc-nm AR_FOR_TARGET=arm-linux-androideabi-gcc-ar
READELF_FOR_TARGET=arm-linux-androideabi-readelf
OBJDUMP_FOR_TARGET=arm-linux-androideabi-objdump STRIP_FOR_TARGET=arm-linux-androideabi-strip
host_configargs=--with-headers=/usr/sysroot/usr/include target_configargs=/usr/sysroot/usr/include
When I run make -d...or make -d all-host...it constantly fails when it tries to compile gen-fac_ui.c because it can't find the includes stdio.h, stdint.h or string.h.
I'll add the exact error tomorrow after I re-set my build directory and start again, but I wanted to post the details and problem tonight before I pass out.
Any help...is greatly appreciated. I'm at a loss on this one.
QUICK NOTE: I noticed that the binutils src directory contains an include/ folder...I'll try symlinking that into the gcc src directory and running 'make distclean' then '../gcc-4.7/configure && make again.'
UPDATE: symlinking include/ did not fix the problem. Here's the error I'm continuously getting
make[2]: Entering directory `/project/android/tc-src/gcc/gcc-src/build/gmp'
gcc `test -f 'gen-fac_ui.c' || echo '../../gcc-4.7/gmp/'`gen-fac_ui.c -o gen-fac_ui
Putting child 0x007ddd30 (gen-fac_ui) PID 25531 on the chain.
Live child 0x007ddd30 (gen-fac_ui) PID 25531
../../gcc-4.7/gmp/gen-fac_ui.c:20:19: error: stdio.h: No such file or directory
../../gcc-4.7/gmp/gen-fac_ui.c:21:20: error: stdlib.h: No such file or directory
In file included from ../../gcc-4.7/gmp/gen-fac_ui.c:23:
../../gcc-4.7/gmp/dumbmp.c:42:20: error: string.h: No such file or directory
In file included from ../../gcc-4.7/gmp/gen-fac_ui.c:23:
I successfully compiled gen-fac_ui by doing the following:
Uninstalling the build gcc which is not (I think) needed as I'm using the cross-compiler toolchain generated by the make-standalone-toolchain.sh script from the Android NDK
Configuring the appropriate variables to set up the cross-compiler tools as the BUILD tools.
I have a different problem now, which I'll post in a different question. Basically, while gen-fac_ui compiles, it (of course) won't run.

android ndk-build error on ubuntu 12.10 32 bit

i have downloaded the latest android ndk r8b on my ubuntu 12.10 beta 2 .
i have included the ndk directory in the PATH variable (when i write ndk-b in terminal and hit tab it auto-completes it) .
but when i try :
cd android-ndk/samples/san-angeles/jni
ndk-build
i get this error:
make: /home/mixpro/Android/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found
make: /home/mixpro/Android/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found
Compile thumb : sanangeles <= importgl.c
make: /home/mixpro/Android/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found
make: *** [/home/mixpro/Android/android-ndk/samples/san-angeles/obj/local/armeabi/objs/sanangeles/importgl.o] Error 127
when checking the /android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin directory using ls i get:
arm-linux-androideabi-addr2line arm-linux-androideabi-g++
arm-linux-androideabi-gdbtui arm-linux-androideabi-size
arm-linux-androideabi-c++filt arm-linux-androideabi-gcc-4.6.x-google
arm-linux-androideabi-gprof arm-linux-androideabi-strings
arm-linux-androideabi-cpp arm-linux-androideabi-gcov
arm-linux-androideabi-readelf arm-linux-androideabi-elfedit
arm-linux-androideabi-gdb arm-linux-androideabi-run
meaning there is no arm-linux-androideabi-gcc in the directory
I am afraid that somehow you got arm-linux-androideabi-addr2line arm-linux-androideabi-gcc deleted. On linux, it is just a symlink to arm-linux-androideabi-gcc-4.6.x-google, so it's very easy to restore it. But maybe, to be on the safe side, it's worthwhile to reinstall NDK.
you should create symbolic link like this : ln -s /usr/bin/arm-linux-gnueabi-gcc-4.7 "/home/sofien/Bureau/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc"

Categories

Resources