Hello. I am working on adding aapt2.
Now I have a successful build but I have an error while executing aapt2
./vendor/aapt2 version
Segmentation error (the memory stack is flushed to disk)
Next I used gdb --args ./vendor/aapt2 version
Program received signal SIGSEGV, Segmentation fault.
0x0000555555b4e12e in android::operator==<char> (lhs=<error reading variable: Cannot access memory at address 0x7fffff7feff8>, rhs=<error reading variable: Cannot access memory at address 0x7fffff7feff0>) at /home/5b/android-tools-31.0.3p1/vendor/base/libs/androidfw/include/androidfw/StringPiece.h:290
290 inline bool operator==(const ::std::basic_string<TChar>& lhs, const BasicStringPiece<TChar>& rhs) {
In build log I see this
In file included from /home/5b/android-tools-31.0.3p1/vendor/base/tools/aapt2/cmd/Command.h:26,
from /home/5b/android-tools-31.0.3p1/vendor/base/tools/aapt2/cmd/Command.cpp:17:
/home/5b/android-tools-31.0.3p1/vendor/base/libs/androidfw/include/androidfw/StringPiece.h: In instantiation of ‘bool android::operator==(const std::__cxx11::basic_string<_CharT>&, const android::BasicStringPiece<TChar>&) [with TChar = char]’:
/home/5b/android-tools-31.0.3p1/vendor/base/tools/aapt2/cmd/Command.cpp:191:34: required from here
/home/5b/android-tools-31.0.3p1/vendor/base/libs/androidfw/include/androidfw/StringPiece.h:291:14: warning: in C++20 this comparison calls the current function recursively with reversed arguments
291 | return rhs == lhs;
| ~~~~^~~~~~
Mb you have secret knowledge, how can I fix this? =)
Hello. I am working on adding aapt2. Now I have a successful build but I have an error while executing aapt2
Next I used
gdb --args ./vendor/aapt2 version
In build log I see this
Mb you have secret knowledge, how can I fix this? =)
my aapt2 cmake file
``` # # based on © 2022 Github Lzhiyong protobuf_generate_cpp(AAPT2_CONFIGURATION_PROTO_SRCS AAPT2_CONFIGURATION_PROTO_HDRS base/tools/aapt2/Configuration.proto) protobuf_generate_cpp(AAPT2_RESINT_PROTO_SRCS AAPT2_RESINT_PROTO_HDRS base/tools/aapt2/ResourcesInternal.proto) protobuf_generate_cpp(AAPT2_RES_PROTO_SRCS AAPT2_RES_PROTO_HDRS base/tools/aapt2/Resources.proto) # libincfs-utils add_library(libincfs-utils STATIC incremental_delivery/incfs/util/map_ptr.cpp ) target_include_directories(libincfs-utils PUBLIC core/include libbase/include incremental_delivery/incfs/include incremental_delivery/incfs/util/include ) # libincfs add_library(libincfs STATIC incremental_delivery/incfs/incfs_ndk.c incremental_delivery/incfs/incfs.cpp incremental_delivery/incfs/MountRegistry.cpp incremental_delivery/incfs/path.cpp incremental_delivery/sysprop/IncrementalProperties.sysprop.cpp ) target_include_directories(libincfs PUBLIC incremental_delivery/incfs/include incremental_delivery/incfs/util/include incremental_delivery/sysprop/include incremental_delivery/incfs/kernel-headers libbase/include libutils/include boringssl/include selinux/libselinux/include logging/liblog/include ) # libbuildversion add_library(libbuildversion STATIC libbuildversion/libbuildversion.cpp ) target_include_directories(libbuildversion PRIVATE libbuildversion/include ) set(INCLUDES base/tools/aapt2 protobuf/src logging/liblog/include expat/lib fmtlib/include libpng libbase/include base/libs/androidfw/include base/cmds/idmap2/libidmap2_policies/include core/libsystem/include core/libutils/include boringssl/third_party/googletest/include libziparchive/include libbuildversion/include incremental_delivery/incfs/util/include incremental_delivery/incfs/kernel-headers native/include /usr/include/android/nativehelper ) set(COMPILE_FLAGS -Wno-missing-field-initializers -fno-exceptions -fno-rtti -fPIC -DNDEBUG ) set(TOOL_SOURCE base/tools/aapt2/cmd/Command.cpp base/tools/aapt2/cmd/Compile.cpp base/tools/aapt2/cmd/Convert.cpp base/tools/aapt2/cmd/Diff.cpp base/tools/aapt2/cmd/Dump.cpp base/tools/aapt2/cmd/Link.cpp base/tools/aapt2/cmd/Optimize.cpp base/tools/aapt2/cmd/Util.cpp ) # build the host static library: aapt2 add_library(libaapt2 STATIC base/tools/aapt2/compile/IdAssigner.cpp base/tools/aapt2/compile/InlineXmlFormatParser.cpp base/tools/aapt2/compile/NinePatch.cpp base/tools/aapt2/compile/Png.cpp base/tools/aapt2/compile/PngChunkFilter.cpp base/tools/aapt2/compile/PngCrunch.cpp base/tools/aapt2/compile/PseudolocaleGenerator.cpp base/tools/aapt2/compile/Pseudolocalizer.cpp base/tools/aapt2/compile/XmlIdCollector.cpp base/tools/aapt2/configuration/ConfigurationParser.cpp base/tools/aapt2/dump/DumpManifest.cpp base/tools/aapt2/filter/AbiFilter.cpp base/tools/aapt2/filter/ConfigFilter.cpp base/tools/aapt2/format/Archive.cpp base/tools/aapt2/format/Container.cpp base/tools/aapt2/format/binary/BinaryResourceParser.cpp base/tools/aapt2/format/binary/ResChunkPullParser.cpp base/tools/aapt2/format/binary/TableFlattener.cpp base/tools/aapt2/format/binary/XmlFlattener.cpp base/tools/aapt2/format/proto/ProtoDeserialize.cpp base/tools/aapt2/format/proto/ProtoSerialize.cpp base/tools/aapt2/io/BigBufferStream.cpp base/tools/aapt2/io/File.cpp base/tools/aapt2/io/FileStream.cpp base/tools/aapt2/io/FileSystem.cpp base/tools/aapt2/io/StringStream.cpp base/tools/aapt2/io/Util.cpp base/tools/aapt2/io/ZipArchive.cpp base/tools/aapt2/link/AutoVersioner.cpp base/tools/aapt2/link/ManifestFixer.cpp base/tools/aapt2/link/NoDefaultResourceRemover.cpp base/tools/aapt2/link/ProductFilter.cpp base/tools/aapt2/link/PrivateAttributeMover.cpp base/tools/aapt2/link/ReferenceLinker.cpp base/tools/aapt2/link/ResourceExcluder.cpp base/tools/aapt2/link/TableMerger.cpp base/tools/aapt2/link/XmlCompatVersioner.cpp base/tools/aapt2/link/XmlNamespaceRemover.cpp base/tools/aapt2/link/XmlReferenceLinker.cpp base/tools/aapt2/optimize/MultiApkGenerator.cpp base/tools/aapt2/optimize/ResourceDeduper.cpp base/tools/aapt2/optimize/ResourceFilter.cpp base/tools/aapt2/optimize/ResourcePathShortener.cpp base/tools/aapt2/optimize/VersionCollapser.cpp base/tools/aapt2/process/SymbolTable.cpp base/tools/aapt2/split/TableSplitter.cpp base/tools/aapt2/text/Printer.cpp base/tools/aapt2/text/Unicode.cpp base/tools/aapt2/text/Utf8Iterator.cpp base/tools/aapt2/util/BigBuffer.cpp base/tools/aapt2/util/Files.cpp base/tools/aapt2/util/Util.cpp base/tools/aapt2/Debug.cpp base/tools/aapt2/DominatorTree.cpp base/tools/aapt2/java/AnnotationProcessor.cpp base/tools/aapt2/java/ClassDefinition.cpp base/tools/aapt2/java/JavaClassGenerator.cpp base/tools/aapt2/java/ManifestClassGenerator.cpp base/tools/aapt2/java/ProguardRules.cpp base/tools/aapt2/LoadedApk.cpp base/tools/aapt2/Resource.cpp base/tools/aapt2/ResourceParser.cpp base/tools/aapt2/ResourceTable.cpp base/tools/aapt2/ResourceUtils.cpp base/tools/aapt2/ResourceValues.cpp base/tools/aapt2/SdkConstants.cpp base/tools/aapt2/StringPool.cpp base/tools/aapt2/trace/TraceBuffer.cpp base/tools/aapt2/xml/XmlActionExecutor.cpp base/tools/aapt2/xml/XmlDom.cpp base/tools/aapt2/xml/XmlPullParser.cpp base/tools/aapt2/xml/XmlUtil.cpp base/tools/aapt2/Configuration.proto base/tools/aapt2/Resources.proto base/tools/aapt2/ResourcesInternal.proto ${AAPT2_CONFIGURATION_PROTO_SRCS} ${AAPT2_CONFIGURATION_PROTO_HDRS} ${AAPT2_RESINT_PROTO_SRCS} ${AAPT2_RESINT_PROTO_HDRS} ${AAPT2_RES_PROTO_SRCS} ${AAPT2_RES_PROTO_HDRS} ) target_include_directories(libaapt2 PRIVATE ${INCLUDES}) target_compile_options(libaapt2 PRIVATE ${COMPILE_FLAGS}) # build the host shared library: aapt2_jni add_library(libaapt2_jni SHARED base/tools/aapt2/jni/aapt2_jni.cpp ${TOOL_SOURCE} ) target_include_directories(libaapt2_jni PRIVATE ${INCLUDES}) target_compile_options(libaapt2_jni PRIVATE ${COMPILE_FLAGS}) target_link_libraries(libaapt2_jni libaapt2) # build the executable file aapt2 add_executable(aapt2 base/tools/aapt2/Main.cpp ${TOOL_SOURCE} ) target_include_directories(aapt2 PRIVATE ${INCLUDES}) target_compile_options(aapt2 PRIVATE ${COMPILE_FLAGS}) set_property(TARGET aapt2 PROPERTY CXX_STANDARD 17) set_property(TARGET libaapt2_jni PROPERTY CXX_STANDARD 17) target_link_libraries(aapt2 libaapt2 libincfs libandroidfw libutil liblog libincfs-utils libcutils libzip libbase libbuildversion png expat z protobuf ) ```