lzhiyong / android-sdk-tools

building android-sdk tools for Android
Apache License 2.0
378 stars 65 forks source link

Help #16

Closed RohitVerma882 closed 2 years ago

RohitVerma882 commented 2 years ago

When i compile Android-12 aapt source code then it can run on android version 5,6,7,8,... devices or not??

lzhiyong commented 2 years ago

When i compile Android-12 aapt source code then it can run on android version 5,6,7,8,... devices or not??

You can download the compiled binaries for testing, they are all statically linked and should work fine.

RohitVerma882 commented 2 years ago

Ok, thanks

RohitVerma882 commented 2 years ago

IMG_20220310_150754

Why generated lib size is too high

lzhiyong commented 2 years ago

Why generated lib size is too high

llvm-strip -g .a strip -g .a

RohitVerma882 commented 2 years ago

Why generated lib size is too high

llvm-strip -g .a strip -g .a

Thanks

RohitVerma882 commented 2 years ago

Screenshot_2022-03-10-21-07-10-54_84d3000e3f4017145260f7618db1d683

Error when compling aidl

lzhiyong commented 2 years ago

Error when compling aidl

redownload sdk-tools-source.zip and compile with ndk-r23b

NDK_TOOLCHAIN=/path/to/android-ndk-r23/toolchains/llvm/prebuilt/linux-x86_64

cmake -G 'Ninja' \
    -DCMAKE_C_COMPILER=$NDK_TOOLCHAIN/bin/aarch64-linux-android30-clang \
    -DCMAKE_CXX_COMPILER=$NDK_TOOLCHAIN/bin/aarch64-linux-android30-clang++ \
    -DCMAKE_SYSROOT=$NDK_TOOLCHAIN/sysroot \
    -DCMAKE_BUILD_TYPE=Release \
    ..

# patch aidl_language_y.h
ninja patch

ninja -j16
RohitVerma882 commented 2 years ago

It doesn't working, Others way to patch aidl_language_y.h ???

lzhiyong commented 2 years ago

It doesn't working, Others way to patch aidl_language_y.h ???

modify the aidl_language_y.h

// add these two lines at the end of the file
typedef union yy::parser::value_type YYSTYPE;
typedef yy::parser::location_type YYLTYPE;
RohitVerma882 commented 2 years ago

It doesn't working, Others way to patch aidl_language_y.h ???

modify the aidl_language_y.h

// add these two lines at the end of the file
typedef union yy::parser::value_type YYSTYPE;
typedef yy::parser::location_type YYLTYPE;

Same happened

RohitVerma882 commented 2 years ago

aapt, aapt2 link error Screenshot_2022-04-27-21-55-41-53_84d3000e3f4017145260f7618db1d683

RohitVerma882 commented 2 years ago

Getting error while compiling for x86 and x86_64

lzhiyong commented 2 years ago

Getting error while compiling for x86 and x86_64

modify the src/boringssl/CMakeLists.txt, start at line 500

# set ARCH and MARCH
set(MARCH)
if(ANDROID_ABI MATCHES "arm64-v8a")
    set(ARCH "aarch64")
    set(MARCH "aarch64")
elseif(ANDROID_ABI MATCHES "armeabi-v7a")
    set(ARCH "arm")
    set(MARCH ${ANDROID_ABI})
elseif(ANDROID_ABI MATCHES "x86")
    set(ARCH "x86")
    set(MARCH "i386")
else(ANDROID_ABI MATCHES "x86_64")
    set(ARCH "x86_64")
    set(MARCH ${ANDROID_ABI})
endif()

# set -march flag == ${MARCH}
if(ANDROID AND NOT ANDROID_NDK_REVISION AND ARCH STREQUAL "arm")
  # The third-party Android-NDK CMake files somehow fail to set the -march flag
  # for assembly files. Without this flag, the compiler believes that it's
  # building for ARMv5.
  set(CMAKE_ASM_FLAGS "-march=${MARCH} ${CMAKE_ASM_FLAGS}")
endif()

build.sh

# ANDROID_ABI = arm64-v8a, armeabi-v7a, x86, x86_64

cmake -G 'Ninja' \
    -DCMAKE_C_COMPILER=$NDK_TOOLCHAIN/bin/i686-linux-android30-clang \
    -DCMAKE_CXX_COMPILER=$NDK_TOOLCHAIN/bin/i686-linux-android30-clang++ \
    -DCMAKE_SYSROOT=$NDK_TOOLCHAIN/sysroot \
    -DCMAKE_BUILD_TYPE=Release \
    -DANDROID_ABI=x86
    ..
lzhiyong commented 2 years ago

IMG_20220428_140141 I just tested aapt2 briefly, there may be other errors, please refer to the corresponding Android.bp and CMakeLists.txt to modify

RohitVerma882 commented 2 years ago

clang-12: error: the clang compiler does not support '-march=i686'

lzhiyong commented 2 years ago

clang-12: error: the clang compiler does not support '-march=i686'

Sorry, there is an error in the above command, it should be for x86

-DCMAKE_C_COMPILER=$NDK_TOOLCHAIN/bin/i686-linux-android30-clang \
-DCMAKE_CXX_COMPILER=$NDK_TOOLCHAIN/bin/i686-linux-android30-clang++ \
RohitVerma882 commented 2 years ago

Thanks, it worked.

RohitVerma882 commented 2 years ago

Screenshot_2022-04-28-23-28-38-39_84d3000e3f4017145260f7618db1d683 adb linking error

RohitVerma882 commented 2 years ago

Screenshot_2022-04-28-23-28-38-39_84d3000e3f4017145260f7618db1d683 adb linking error

This is last error!

lzhiyong commented 2 years ago

not generating cpp files correctly, for cross compiling you need host protoc

put the aarch64 protoc executable in your x86 build/bin directory

no need to execute the ninja protoc command for cross compilation