VIM3 Build Android (android 9.0 64 bit) failed

Which Khadas SBC do you use?

VIM3

Which system do you use? Android, Ubuntu, OOWOW or others?

Android

Which version of system do you use? Khadas official images, self built images, or others?

self built image

Please describe your issue below:

I’m trying to build the Android Pie source for VIM3 following this page.
https://docs.khadas.com/products/sbc/vim3/development/android/build-android

It almost finished but failed after about 4 hours.
The host system is on Ubuntu 22.04.
I began a new branch for development.
(rep start ayo-vim3-p-64bit --all)

Thanks,

Post a console log of your issue below:

[ 98% 101868/102954] target dex2oat: out/target/product/kvim3/dex_bootjars/system/framework/arm64/boot.art
FAILED: out/target/product/kvim3/dex_bootjars/system/framework/arm64/boot.art
/bin/bash -c “(mkdir -p out/target/product/kvim3/symbols/system/framework/arm64/ ) && (rm -f out/target/product/kvim3/dex_bootjars/system/framework/arm64//.art out/target/product/kvim3/dex_bootjars/system/framework/arm64//.oat out/target/product/kvim3/dex_bootjars/system/framework/arm64//.art.rel ) && (rm -f out/target/product/kvim3/symbols/system/framework/arm64//.art ) && (rm -f out/target/product/kvim3/symbols/system/framework/arm64//.oat ) && (rm -f out/target/product/kvim3/symbols/system/framework/arm64//.art.rel ) && (ANDROID_LOG_TAGS=":e" out/host/linux-x86/bin/dex2oatd --runtime-arg -Xms64m --runtime-arg -Xmx64m --compiler-filter=speed-profile --profile-file=out/target/product/kvim3/dex_bootjars/system/framework/boot.prof --dex-file=out/target/common/obj/JAVA_LIBRARIES/exoplayer_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/core-oj_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/apache-xml_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.hidl.base-V1.0-java_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.hidl.manager-V1.0-java_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/framework-oahl-backward-compatibility_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.test.base_intermediates/javalib.jar --dex-location=/system/framework/exoplayer.jar --dex-location=/system/framework/core-oj.jar --dex-location=/system/framework/core-libart.jar --dex-location=/system/framework/conscrypt.jar --dex-location=/system/framework/okhttp.jar --dex-location=/system/framework/bouncycastle.jar --dex-location=/system/framework/apache-xml.jar --dex-location=/system/framework/ext.jar --dex-location=/system/framework/framework.jar --dex-location=/system/framework/telephony-common.jar --dex-location=/system/framework/voip-common.jar --dex-location=/system/framework/ims-common.jar --dex-location=/system/framework/android.hidl.base-V1.0-java.jar --dex-location=/system/framework/android.hidl.manager-V1.0-java.jar --dex-location=/system/framework/framework-oahl-backward-compatibility.jar --dex-location=/system/framework/android.test.base.jar --oat-symbols=out/target/product/kvim3/symbols/system/framework/arm64/boot.oat --oat-file=out/target/product/kvim3/dex_bootjars/system/framework/arm64/boot.oat --oat-location=/system/framework/arm64/boot.oat --image=out/target/product/kvim3/dex_bootjars/system/framework/arm64/boot.art --base=0x70000000 --instruction-set=arm64 --instruction-set-variant=generic --instruction-set-features=default --android-root=out/target/product/kvim3/system --runtime-arg -Xnorelocate --compile-pic --no-generate-debug-info --generate-build-id --multi-image --no-inline-from=core-oj.jar --abort-on-hard-verifier-error --abort-on-soft-verifier-error --generate-mini-debug-info || ( echo "ERROR: Dex2oat failed to compile a boot image. It is likely that the boot classpath is inconsistent. Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="–runtime-arg -verbose:verifier" to see verification errors." ; false ) && ANDROID_LOG_TAGS=":e" ANDROID_ROOT=out/target/product/kvim3/system ANDROID_DATA=out/target/product/kvim3/dex_bootjars/system/framework/arm64/ out/host/linux-x86/bin/patchoatd --input-image-location=out/target/product/kvim3/dex_bootjars/system/framework/boot.art --output-image-relocation-directory=out/target/product/kvim3/dex_bootjars/system/framework/arm64/ --instruction-set=arm64 --base-offset-delta=0x10000000 )”
patchoatd E 05-09 08:09:42 587620 587620 image_space.cc:1761] Could not create image space with image file ‘out/target/product/kvim3/dex_bootjars/system/framework/boot.art’. Attempting to fall back to imageless running. Error was: Failed to mmap at expected address, mapped at 0x7f34ec000000 instead of 0x705fa000
patchoatd E 05-09 08:09:42 587620 587620 image_space.cc:1761] Attempted image: out/target/product/kvim3/dex_bootjars/system/framework/boot-framework.art
patchoatd E 05-09 08:09:42 587620 587620 runtime.cc:1290] Dex file fallback disabled, cannot continue without image.
patchoatd E 05-09 08:09:42 587620 587620 patchoat.cc:485] Unable to initialize runtime
[ 98% 101869/102954] //art/runtime:libart link libart.so [arm]
Warning: request a ThreadPool with 1 threads, but LLVM_ENABLE_THREADS has been turned off
[ 98% 101870/102954] //frameworks/base/libs/hwui:libhwui link libhwui.so
Warning: request a ThreadPool with 1 threads, but LLVM_ENABLE_THREADS has been turned off
[ 98% 101871/102954] //frameworks/base/libs/hwui:libhwui link libhwui.so [arm]
Warning: request a ThreadPool with 1 threads, but LLVM_ENABLE_THREADS has been turned off
ninja: build stopped: subcommand failed.
08:10:35 ninja failed with: exit status 1

failed to build some targets (03:50:10 (hh:mm:ss))

https://docs.khadas.com/products/sbc/vim3/development/android/download-android-source-code

Have you done this step in the synchronization operation document above?

Check if there is a git lfs pull command in the device/khadas directory

Yes I did.
After “repo sync”, I executed the “git lfs pull” in ‘device/khadas’ directory.

ls - a device/khadas
common .git .gitattributes kvim3 kvim3l
.git → …/…/.repo/projects/device/khadas.git

cat device/khadas/.gitattributes
kvim3/preinstall/Chrome.apk filter=lfs diff=lfs merge=lfs -text
kvim3l/preinstall/Chrome.apk filter=lfs diff=lfs merge=lfs -text

Thanks,

Anyone to build successfully with the latest revision? (repo sync)
Should I use an other branch?
Please follow this issue.

I saw a post on the Internet and the error log you sent
FAILED: same problem as out/target/product/kvim3/dex_bootjars/system/framework/arm64/boot.art, you can try

https://FAILED:out/target/product/generic/dex_bootjars/system/framework/arm/boot.art

Thanks for the reply.

I tried that like below after “make clean” and building the bootloader.

$ source build/envsetup.sh
$ lunch kvim3-userdebug
$ ALLOW_MISSING_DEPENDENCIES=true WITH_DEXPREOPT=false make -j8 otapackage

In this case, it went 1% further but failed.

[ 99% 102385/102954] target dex2oat: out/target/product/kvim3/dex_bootjars/system/framework/arm64/boot.art
FAILED: out/target/product/kvim3/dex_bootjars/system/framework/arm64/boot.art
/bin/bash -c “(mkdir -p out/target/product/kvim3/symbols/system/framework/arm64/ ) && (rm -f out/target/product/kvim3/dex_bootjars/system/framework/arm64//.art out/target/product/kvim3/dex_bootjars/system/framework/arm64//.oat out/target/product/kvim3/dex_bootjars/system/framework/arm64//.art.rel ) && (rm -f out/target/product/kvim3/symbols/system/framework/arm64//.art ) && (rm -f out/target/product/kvim3/symbols/system/framework/arm64//.oat ) && (rm -f out/target/product/kvim3/symbols/system/framework/arm64//.art.rel ) && (ANDROID_LOG_TAGS=":e" out/host/linux-x86/bin/dex2oatd --runtime-arg -Xms64m --runtime-arg -Xmx64m --compiler-filter=speed-profile --profile-file=out/target/product/kvim3/dex_bootjars/system/framework/boot.prof --dex-file=out/target/common/obj/JAVA_LIBRARIES/exoplayer_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/core-oj_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/apache-xml_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.hidl.base-V1.0-java_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.hidl.manager-V1.0-java_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/framework-oahl-backward-compatibility_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.test.base_intermediates/javalib.jar --dex-location=/system/framework/exoplayer.jar --dex-location=/system/framework/core-oj.jar --dex-location=/system/framework/core-libart.jar --dex-location=/system/framework/conscrypt.jar --dex-location=/system/framework/okhttp.jar --dex-location=/system/framework/bouncycastle.jar --dex-location=/system/framework/apache-xml.jar --dex-location=/system/framework/ext.jar --dex-location=/system/framework/framework.jar --dex-location=/system/framework/telephony-common.jar --dex-location=/system/framework/voip-common.jar --dex-location=/system/framework/ims-common.jar --dex-location=/system/framework/android.hidl.base-V1.0-java.jar --dex-location=/system/framework/android.hidl.manager-V1.0-java.jar --dex-location=/system/framework/framework-oahl-backward-compatibility.jar --dex-location=/system/framework/android.test.base.jar --oat-symbols=out/target/product/kvim3/symbols/system/framework/arm64/boot.oat --oat-file=out/target/product/kvim3/dex_bootjars/system/framework/arm64/boot.oat --oat-location=/system/framework/arm64/boot.oat --image=out/target/product/kvim3/dex_bootjars/system/framework/arm64/boot.art --base=0x70000000 --instruction-set=arm64 --instruction-set-variant=generic --instruction-set-features=default --android-root=out/target/product/kvim3/system --runtime-arg -Xnorelocate --compile-pic --no-generate-debug-info --generate-build-id --multi-image --no-inline-from=core-oj.jar --abort-on-hard-verifier-error --abort-on-soft-verifier-error --generate-mini-debug-info || ( echo "ERROR: Dex2oat failed to compile a boot image. It is likely that the boot classpath is inconsistent. Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="–runtime-arg -verbose:verifier" to see verification errors." ; false ) && ANDROID_LOG_TAGS=":e" ANDROID_ROOT=out/target/product/kvim3/system ANDROID_DATA=out/target/product/kvim3/dex_bootjars/system/framework/arm64/ out/host/linux-x86/bin/patchoatd --input-image-location=out/target/product/kvim3/dex_bootjars/system/framework/boot.art --output-image-relocation-directory=out/target/product/kvim3/dex_bootjars/system/framework/arm64/ --instruction-set=arm64 --base-offset-delta=0x10000000 )”
patchoatd E 05-12 08:34:27 1372753 1372753 image_space.cc:1761] Could not create image space with image file ‘out/target/product/kvim3/dex_bootjars/system/framework/boot.art’. Attempting to fall back to imageless running. Error was: Failed to mmap at expected address, mapped at 0x7fb11fc00000 instead of 0x705fa000
patchoatd E 05-12 08:34:27 1372753 1372753 image_space.cc:1761] Attempted image: out/target/product/kvim3/dex_bootjars/system/framework/boot-framework.art
patchoatd E 05-12 08:34:28 1372753 1372753 runtime.cc:1290] Dex file fallback disabled, cannot continue without image.
patchoatd E 05-12 08:34:28 1372753 1372753 patchoat.cc:485] Unable to initialize runtime
[ 99% 102387/102954] target Dex: Launcher3
Warning in out/target/common/obj/APPS/Launcher3_intermediates/dex/d8_input.jar:com/android/launcher3/pageindicators/WorkspacePageIndicator$3.class:
Type java.lang.Integer was not found, it is required for default or static interface methods desugaring of java.lang.Integer com.android.launcher3.pageindicators.WorkspacePageIndicator$3.get(com.android.launcher3.pageindicators.WorkspacePageIndicator)
Warning in out/target/common/obj/APPS/Launcher3_intermediates/dex/d8_input.jar:com/android/launcher3/logging/FileLog$LogWriterCallback.class:
Type java.util.Calendar was not found, it is required for default or static interface methods desugaring of boolean com.android.launcher3.logging.FileLog$LogWriterCallback.handleMessage(android.os.Message)
.
.
##############################
Similar logs have been omitted.
##############################
.
.
Warning in out/target/common/obj/APPS/Launcher3_intermediates/dex/d8_input.jar:com/android/launcher3/keyboard/CustomActionsPopup.class:
Interface android.widget.PopupMenu$OnMenuItemClickListener not found. It’s needed to make sure desugaring of com.android.launcher3.keyboard.CustomActionsPopup is correct. Desugaring will assume that this interface has no default method.
Warning in out/target/common/obj/APPS/Launcher3_intermediates/dex/d8_input.jar:com/android/launcher3/util/FlingAnimation$1.class:
Interface android.animation.TimeInterpolator not found. It’s needed to make sure desugaring of com.android.launcher3.util.FlingAnimation$1 is correct. Desugaring will assume that this interface has no default method.
Warning in out/target/common/obj/APPS/Launcher3_intermediates/dex/d8_input.jar:com/android/launcher3/util/LongArrayMap.class:
Interface java.lang.Iterable not found. It’s needed to make sure desugaring of com.android.launcher3.util.LongArrayMap is correct. Desugaring will assume that this interface has no default method.
[ 99% 102390/102954] Target Java: out/target/common/obj/APPS/PackageInstaller_intermediates/classes-full-debug.jar
ninja: build stopped: subcommand failed.
08:34:51 ninja failed with: exit status 1

failed to build some targets (03:51:22 (hh:mm:ss))

Did you modify something in your framework? Are you going to compile the ota package? The error displayed is the package dex2oat exception.
Try to compile normally

source build/envsetup.sh && lunch kvim3-userdebug
make -j50 2>&1 | tee build_vim3_android.log

If it still fails, send the generated build_vim3_android.log to me through the network disk

Yes I modified 2 files.

  1. linux-x86/flex/flex-2.5.39 binary to solve the issue mentioned below.
    [Guide] Arch-Linux Building Khadas Source Android 9
  2. common/scripts/dtc/dtc-lexer.lex.c_shipped (line 634) for the solution for ‘multiple definition of yylloc’ error.
    -YYLTYPE yylloc;
    +extern YYLTYPE yylloc;

It failed anyway, even without the target otapackage.
Here is the log link.

Hello, I can compile normally without modifying these. You modified it because of a compilation error. Then you can roll back these modifications, synchronize the latest code, and then send me the compilation log. I suspect that the compilation exception problem is caused by other problems

I tried the build with the original branch without any modification.
But there happened the same issues as in the previous tries.

$ repo branch

  • khadas-vim3-p-64bit | in all projects

$ repo sync -j8
Fetching: 100% (705/705), done in 8.642s
Checking out: 100% (705/705), done in 1.013s
repo sync has finished successfully.

$ repo diff

$ make clean

$ source build/envsetup.sh && lunch kvim3-userdebug
including device/khadas/kvim3l/vendorsetup.sh
including device/khadas/kvim3/vendorsetup.sh
including sdk/bash_completion/adb.bash
hardware/amlogic/wifi/configs/wifi.mk:43: warning: WIFI_MOUDLE is multiwifi
hardware/amlogic/wifi/configs/wifi.mk:47: warning: WIFI_BUILD_IN is false
hardware/amlogic/bluetooth/configs/bluetooth.mk:20: warning: BLUETOOTH_MODULE is BCMBT
hardware/amlogic/bluetooth/configs/bluetooth.mk:24: warning: BLUETOOTH_INF is not set

//============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=9
TARGET_PRODUCT=kvim3
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv7-a-neon
TARGET_2ND_CPU_VARIANT=cortex-a9
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.19.0-41-generic-x86_64-Ubuntu-22.04.1-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=PPR1.180610.011
OUT_DIR=out
//============================================

$ make -j50 2>&1 | tee build_vim3_android.log

This is the first log in which the flex related issue happened.

This is the second log after solving the flex issue.
(with ‘yylloc’ multiple definition issue in common/scripts/dtc/dtc-lexer.lex.c)

This is the last log after modifying the second issue.
(FAILED: out/target/product/kvim3/dex_bootjars/system/framework/arm/boot.art)

This is the result of ‘repo diff’ after building.

Hello, I checked the build_vim3_android-Without_anychange.log for the error point

FAILED: out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/dtc-lexer.c
/bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/dtc-lexer.c external/dtc/dtc-lexer. l"
flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.

May need to refactor flex on Ubuntu-22.04
The operation is as follows

cd prebuilts/misc/linux-x86/flex
rm flex-2.5.39
tar zxf flex-2.5.39.tar.gz
cd flex-2.5.39
./configure
make
mv flex ../
cd ../
rm -rf flex-2.5.39
mv flex flex-2.5.39

See how you do it

Did you modify all his modifications and compile it, or did you modify one and compile it when you encountered his problem, then modify and compile it again? If you only modify the error report above, will the second problem on the link you posted appear?

I did ‘make’ 3 times and encountered 3 problems in total.

At the first try, I got the first log and replaced flex-2.5.39 only as you described.
And I did ‘make’ again and got the 2nd log.

After modifying just the multiple definition error in the 2nd log,
I did ‘make’ again and got the last log.

For the yylloc definition error,
I commented out the line 635 in ‘dtc-lexer.lex.c_shipped’.

Please check the following 3 files in common/scripts/dtc/ from your repo branch.

dtc-lexer.lex.c_shipped
635 YYLTYPE yylloc;

dtc-parser.tab.c_shipped
1205 YYLTYPE yylloc
1206 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1207 = { 1, 1, 1, 1 }
1208 # endif
1209 ;

dtc-parser.tab.h_shipped
121 extern YYSTYPE yylval;
122 extern YYLTYPE yylloc;

Hello, I passed the link you sent

I saw that he modified the two files

dtc-lexer.l

and

dtc-parser.tab.c_shipped

, but only one of the three files modified by you is corresponding to it. You can see if there is one in dtc-lexer.l Modify, if not modify it try

I guess “dtc-lexer.l” would not be used in compiling.
boot.art issue still existed.
(FAILED: out/target/product/kvim3/dex_bootjars/system/framework/arm64/boot.art)
This is the log after modifying “dtc-lexer.l”.

I built all successfully.

My host Ubuntu kernel version is 5.19.
It seems that the mmap of the host linux kernel might not be compatible with Android runtime source.
The link mentions kernel 5.18.

For the explanation, please check the links below.

https://groups.google.com/g/android-building/c/ZfUQQWt_ABI

Workaround for mmap error when building.

https://android-review.googlesource.com/c/platform/art/+/2226578
( modify art/runtime/mem_map.cc )

BTW, The Google Play is not available in the self built images?
Is that available in Khadas official images only?

Thanks,

The real error should be caused by the following. I am sorry that I have not found a solution to this yesterday. My personal suggestion is to use Ubuntu 18.04.6 LTS to build the firmware. 18.04 is more stable

patchoatd E 05-17 16:05:24 837942 837942 image_space.cc:1761] Could not create image space with image file 'out/target/product/kvim3/dex_bootjars/system/framework/boot.art'. Attempting to fall back to imageless running. Error was: Failed to mmap at expected address, mapped at 0x7fe43d000000 instead of 0x704c2000

The link below explains how to open Google Play Services