Android SDK - aapt: error while loading shared libraries: libc++.so - android

I downloaded the sdk-tools linux-3859397.zip and extract it to /opt/android (which is my ANDROID_HOME)
So, when I launch aapt it fail to load the libc++ shared library
$ /opt/android/build-tools/27.0.3/aapt
/opt/android/build-tools/27.0.3/aapt: error while loading shared libraries: libc++.so: cannot open shared object file: No such file or directory
But the libc++ exists, as example the ldd tools has found it !
$ ldd /opt/android/build-tools/27.0.3/aapt
linux-vdso.so.1 (0x00007ffdd66b3000)
libc++.so => /opt/android/build-tools/27.0.3/lib64/libc++.so (0x00007fc511580000)
librt.so.1 => /usr/lib64/librt.so.1 (0x00007fc511378000)
libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007fc511170000)
libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007fc510f50000)
libz.so.1 => /usr/lib64/libz.so.1 (0x00007fc510d38000)
libm.so.6 => /usr/lib64/libm.so.6 (0x00007fc5109e0000)
libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007fc5107c8000)
libc.so.6 => /usr/lib64/libc.so.6 (0x00007fc5103e0000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc511698000)
$ file /opt/android/build-tools/27.0.3/lib64/libc++.so
/opt/android/build-tools/27.0.3/lib64/libc++.so: setgid ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
I tried to install libstdc++-devel both in 32bit and 64 bits but that do not solve this issue
Thanks for your help
Note: same problem with aapt2

[Solved]
After copying libc++.so file to /lib/. Issue resolved.
sravan#host3933:/lib$ ls -al |grep libc++
-rwxr-xr-x 1 root root 5584312 Aug 20 17:41 libc++.so
sravan#host3933:/lib$ aapt -help
ERROR: Unknown command '-help'
Android Asset Packaging Tool
Usage:
aapt l[ist] [-v] [-a] file.{zip,jar,apk}
List contents of Zip-compatible archive.

Related

Failed to build sample SDK add-on on Android 13 AOSP

I'm trying to build my own SDK add-on from scratch, and attempt to comply with the sample in device/sample. Complying to the instructions in README.txt, I got following failure while building:
[100% 1/1] analyzing Android.bp files and generating ninja file at out/soong/build.ninja
FAILED: out/soong/build.ninja
cd "$(dirname "out/host/linux-x86/bin/soong_build")" && BUILDER="$PWD/$(basename "out/host/linux-x86/bin/soong_build")" && cd / && env -i "$BUILDER" --top "$TOP" --soong_o
ut "out/soong" --out "out" -o out/soong/build.ninja --globListDir build --globFile out/soong/globs-build.ninja -t -l out/.module_paths/Android.bp.list --available_env out/s
oong/soong.environment.available --used_env out/soong/soong.environment.used.build Android.bp
error: prebuilts/module_sdk/conscrypt/current/Android.bp:20:1: dependency "art-bootclasspath-fragment" of "conscrypt-module-sdk_com.android.conscrypt-bootclasspath-fragment#current
" missing variant:
apex:com.android.art
available variants:
os:android,arch:common
error: prebuilts/module_sdk/conscrypt/current/Android.bp:20:1: dependency "prebuilt_art-bootclasspath-fragment" of "conscrypt-module-sdk_com.android.conscrypt-bootclasspath-fragmen
t#current" missing variant:
apex:com.android.art
available variants:
os:android,arch:common
10:34:20 soong bootstrap failed with: exit status 1
Does anyone encounter the same issue? It would be appriciated if there's any workaround on this. Thanks.
Edit build/make/target/product/sdk_phone_x86_64.mk (or your device target file) and add following line at the end:
MODULE_BUILD_FROM_SOURCE := true
For me, that solved the error and the build now starts.
You can view my product repository (you can drop it in your source tree and use lunch aosp_sdk_phone_x86_64-eng) to have this change as well:
https://git.halogenos.org/halogenOS/android_product_halogenOS/

aapt: error while loading shared libraries: libc++.so

We have an error during build:
AAPT err(Facade for 1550528231): /usr/local/android-sdk/build-tools/23.0.3/aapt: error while loading shared libraries: libc++.so: cannot open shared object file: No such file or directory
We have two build-tools installed:
# ls -l /usr/local/android-sdk/build-tools/
total 8
drwxr-xr-x 4 root root 4096 Jul 22 11:43 23.0.1
drwxr-xr-x 4 root root 4096 Jul 22 11:50 23.0.3
23.0.3 - downloaded and unpacked manually.
Both have libc++.so:
# find /usr/local/android-sdk/build-tools/ -name 'libc++.so'
/usr/local/android-sdk/build-tools/23.0.3/lib/libc++.so
/usr/local/android-sdk/build-tools/23.0.1/lib/libc++.so
/usr/local/android-sdk/build-tools/23.0.1/lib/ added to $PATH and $LD_LIBRARY_PATH:
$ echo $PATH
/usr/local/maven-3.2.5/bin:/usr/local/gradle-1.5/bin:/usr/share/centrifydc/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/android-sdk/tools:/usr/local/android-sdk/platform-tools:/usr/local/android-sdk/build-tools/23.0.3/lib/:/opt/awscli/bin:/usr/local/sonar-runner/bin:/usr/local/android-sdk/build-tools/23.0.3
$ echo $LD_LIBRARY_PATH
/usr/local/android-sdk-23.0.2/build-tools/23.0.3/lib/l
What's wrong here?
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.2 LTS
Release: 12.04

Can't compile CyanogenMod 13

I'm trying to compile CyanogenMod from scratch with the help of this guide. I've done most of the steps without any errors, but at the brunch angler step, I keep getting this error:
Building with Jack: /home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/android-support-v13-ics-mr1_intermediates/classes.jack
host Executable: llvm-rs-cc (/home/hexafluoride/android/system/out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/llvm-rs-cc)
Building with Jack: /home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/com.android.gallery3d.common2_intermediates/classes.jack
target Symbolic: libssl (/home/hexafluoride/android/system/out/target/product/angler/symbols/system/lib64/libssl.so)
target StaticLib: libLLVMAArch64CodeGen (/home/hexafluoride/android/system/out/target/product/angler/obj/STATIC_LIBRARIES/libLLVMAArch64CodeGen_intermediates/libLLVMAArch64CodeGen.a)
Launching background server java -Dfile.encoding=UTF-8 -Xms2560m -XX:+TieredCompilation -jar /home/hexafluoride/android/system/out/host/linux-x86/framework/jack-launcher.jar -cp /home/hexafluoride/android/system/out/host/linux-x86/framework/jack.jar com.android.jack.server.JackSimpleServer
target StaticLib: libLLVMAArch64Info (/home/hexafluoride/android/system/out/target/product/angler/obj/STATIC_LIBRARIES/libLLVMAArch64Info_intermediates/libLLVMAArch64Info.a)
Launching background server java -Dfile.encoding=UTF-8 -Xms2560m -XX:+TieredCompilation -jar /home/hexafluoride/android/system/out/host/linux-x86/framework/jack-launcher.jar -cp /home/hexafluoride/android/system/out/host/linux-x86/framework/jack.jar com.android.jack.server.JackSimpleServer
target StaticLib: libLLVMAArch64Desc (/home/hexafluoride/android/system/out/target/product/angler/obj/STATIC_LIBRARIES/libLLVMAArch64Desc_intermediates/libLLVMAArch64Desc.a)
target StaticLib: libLLVMAArch64AsmParser (/home/hexafluoride/android/system/out/target/product/angler/obj/STATIC_LIBRARIES/libLLVMAArch64AsmParser_intermediates/libLLVMAArch64AsmParser.a)
target StaticLib: libLLVMAArch64AsmPrinter (/home/hexafluoride/android/system/out/target/product/angler/obj/STATIC_LIBRARIES/libLLVMAArch64AsmPrinter_intermediates/libLLVMAArch64AsmPrinter.a)
ERROR: /home/hexafluoride/android/system/packages/apps/Gallery2/gallerycommon/src/com/android/gallery3d/exif/ExifData.java:1: The type java.lang.Object cannot be found in source files, imported jack libs or the classpath
ERROR: /home/hexafluoride/android/system/packages/apps/Gallery2/gallerycommon/src/com/android/gallery3d/exif/ExifData.java:19: The import android cannot be resolved
* lots of errors saying that basic types can't be resolved after this *
And then make fails. I've tried doing make showcommands, and this is the output:
if [ -s /home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/android-support-v4-jellybean_intermediates/jack-rsc/java-source-list-uniq ] ; then export tmpEcjArg="#/home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/android-support-v4-jellybean_intermediates/jack-rsc/java-source-list-uniq"; else export tmpEcjArg=""; fi; JACK_VM_COMMAND="java -Dfile.encoding=UTF-8 -Xms2560m -XX:+TieredCompilation -jar /home/hexafluoride/android/system/out/host/linux-x86/framework/jack-launcher.jar " JACK_JAR="/home/hexafluoride/android/system/out/host/linux-x86/framework/jack.jar" /home/hexafluoride/android/system/out/host/linux-x86/bin/jack #build/core/jack-default.args --verbose error -g --classpath /home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/sdk_v16_intermediates/classes.jack:/home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/sdk_v16_intermediates/classes.jack:/home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/android-support-v4-ics-mr1_intermediates/classes.jack --import /home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/android-support-v4-ics-mr1_intermediates/classes.jack -D jack.import.resource.policy=keep-first -D jack.import.type.policy=keep-first -D jack.java.source.version=1.7 --output-jack /home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/android-support-v4-jellybean_intermediates/classes.jack $tmpEcjArg || ( rm -f /home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/android-support-v4-jellybean_intermediates/classes.jack ; exit 41 )
ERROR: /home/hexafluoride/android/system/frameworks/support/v4/jellybean/android/support/v4/app/NavUtilsJB.java:0: The type android.app.Notification cannot be found in source files, imported jack libs or the classpath
build/core/java.mk:636: recipe for target '/home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/android-support-v4-jellybean_intermediates/classes.jack' failed
make: *** [/home/hexafluoride/android/system/out/target/common/obj/JAVA_LIBRARIES/android-support-v4-jellybean_intermediates/classes.jack] Error 41
What am I doing wrong? I'm on Ubuntu Server 16.04.
Alright, the problem probably was because I abruptly interrupted the build process because of a hang, and then tried to continue building from there.
I did a make clobber && brunch angler and it built successfully.

Cross-compiling a MPICH library for Android NDK

My goal is to run MPICH on Android phones. I'm using Debian Jessie. I thought that I'll achieve that following this tutorial:
http://hex.ro/wp/projects/personal-cloud-computing/compiling-mpich2-for-android-and-running-on-two-phones/
but instead of creating toolchain with Buildroot I decided to create it from Android NDK, as on this site:
http://www.threadstates.com/articles/2013/setting-up-an-android-cross-compiling-environment-with-the-ndk.html
I tried to use MPICH library versions 2.1.4, 2.1.5, 3.0.4 and configure it using command:
sudo CFLAGS=" -march=armv5 -mfpu=vfp -static "
CC=/home/cerbia/android/bin/arm-linux-androideabi-gcc ./configure
--prefix=/home/cerbia/old --host=arm-linux --with-pm=smpd --disable-f77 --disable-fc
but I still had this kind of error:
configure: error: SMPD requires MD5 support, and configure could not
find either md5_calc in md5.h or MD5 in openssl/md5.h
I found, that it is connected with openssl version and I tried to follow this instruction:
Download, compile, modify and install OpenSSL to the NDK directory. cd ~ wget www.openssl.org/source/openssl-1.0.0g.tar.gz tar xvzf
openssl-1.0.0g.tar.gz cd openssl-1.0.0g ./config no-asm shared --prefix=$ANDROID_ROOT/platforms/android-3/arch-arm/usr
edit Makefile:
CC= arm-linux-gnueabi-gcc-4.6
CFLAG= -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DOPENSSL_N -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -fPIC
DEPFLAG= -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_R C5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_STORE
PEX_LIBS=
EX_LIBS= -ldl
EXE_EXT=
ARFLAGS=
AR= arm-linux-gnueabi-ar $(ARFLAGS) r
RANLIB= arm-linux-gnueabi-ranlib
NM= arm-linux-gnueabi-nm
PERL= /usr/bin/perl
TAR= tar
TARFLAGS= --no-recursion
MAKEDEPPROG= gcc
LIBDIR=lib
Than instead of HIPL I tried to cross-compile MPICH in the analogous way as below
Download and cross-compile HIPL. cd ~ bzr co lp:hipl trunk cd trunk edit configure.ac and comment out all AM_CFLAGS autoreconf --install
./configure --disable-gcc-warn --disable-firewall -host=arm-linux
CC=arm-linux-gnueabi-gcc-4.6
CPPFLAGS="-I$ANDROID_ROOT/platforms/android-3/arch-arm/usr/include"
CFLAGS="-nostdlib"
LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/platforms/android-3/arch-arm/usr/lib,-L$ANDROID_ROOT/platforms/android-3/arch-arm/usr/lib"
LIBS="-lc" make make all-am make[1]: Entering directory `/home/mkomu/projects/hipl-bzr/arm' CC lib/core/builder.lo In file
included from lib/core/debug.h:34:0,
from lib/core/crypto.h:43,
from lib/core/builder.c:100: lib/core/protodefs.h:917:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:929:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:1027:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:1036:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:1043:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:1054:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:1055:5: error: unknown type name 'in_port_t' ...
it comes from site: bugs.launchpad.net/hipl/+bug/715126
but I got the same errors as person there..
make[8]: Wejście do katalogu
`/home/cerbia/old/mpich2-1.3.2/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp'
CC tcp_finalize.c In file included from
tcp_finalize.c:7:0: tcp_impl.h:108:89: error: unknown type name
'in_port_t' make[8]: * [tcp_finalize.o] Błąd 1
Do you have any advices what I should try to make it working?
In Linux, in_port_t is typedefed as uint16_t in netinet/in.h. The only place this typedef is used is in the definition of sockaddr_in.
The Android NDK does not define or use in_port_t, but instead uses unsigned short int. To compile code using the Android NDK, either typedef in_port_t or replace it with unsigned short int.

Hello World Android Program

I just built my goldfish android kernel. I wrote a hello world program and compiled using arm-linux-gnueabi-gcc. I used adb push to put the executable in /data/local of the emulated kernel. I was able to ssh into the emulated kernel using adb shell. When I cd into /data/local and ls the directory, I'm able to see the a.out which I had put using adb push. When I do #./a.out, I get the error ./a.out: not found.
Can some one help me on this.
I added the -static option during compilation worked. arm-linux-gnueabi-gcc -static
I guess it's a missing library problem. I have met this problem before, my fix is below:
root#evab:~# ./a.out
-sh: ./a.out: not found
root#evab:~# ls /lib /root
/lib:
libc.so.6
/root:
a.out
root#evab:~#
Then check which shared library is needed by the application:
leo#leo-VirtualBox:/opt/nfs/root$ arm-linux-readelf a.out -a |grep lib
[Requesting program interpreter: /lib/ld-linux.so.3]
0x00000001 (NEEDED) Shared library: [libc.so.6]
... ...
By the output, we can confirm that the ld-linux.so.3 is missing, so copy ld-linux.so.3 to target filesystem /lib directory:
root#evab:~# ./a.out
test
root#evab:~# ls /lib /root
/lib:
ld-linux.so.3 libc.so.6
/root:
a.out
root#evab:~#

Categories

Resources