Why aapt2 generate compile error "Check failed"? - android

I'm running AAPT2 from the command line:
%PATH_AAPT2%\aapt2.exe compile -v --dir res -o build
Many resource files are compiled. But after a time aapt2 is aborting with the message
Check failed: node_stack.size() == 1u
The build output is:
>C:\Android\aapt2\aapt2.exe compile -v --dir res -o build
res\color\button_back.xml: note: compiling XML.
...
res\drawable\rectangle.xml: note: compiling XML.
res\drawable\row.xml: note: compiling XML.
res\drawable\splash_screen.xml: note: compiling XML.
res\menu\menu_main.xml: note: compiling XML.
aapt2.exe F 08-23 07:52:20 16152 15008 ResourceParser.cpp:346] Check failed: node_stack.size() == 1u
What is the reason?
The used AAPT2 version is 4.1.0 rc01, but the error occurs with other versions too.
The error seems not to be related to any resource. I removed the recently compiled resources like menu_main.xml, but the error occurs furthermore.

Related

The C compiler "clang.exe" is not able to compile a simple test program

I am trying to compile shell script that compiles the C project library, but i am stuck at this when it comes to compile the nmake part.
I am using NDK 21 and cmake version is 3.10
I am using shell script using bash same as defined here, i want to compress this library as they showing in the docs running ./android.sh
Please check the link: https://github.com/tanersener/mobile-ffmpeg#52-build-scripts
here is the attached log:
DEBUG: Downloading library source: cpu-features
DEBUG: Checking if cpu-features is already downloaded at /d/Bilals/Projects/GithubProjects/mobile-ffmpeg/src/cpu-features
INFO: cpu-features library already downloaded
INFO: cpu-features already downloaded. Source folder found at /d/Bilals/Projects/GithubProjects/mobile-ffmpeg/src/cpu-features
-- Building for: NMake Makefiles
-- Check for working C compiler: D:/Bilals/PcBackupData/sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_adf3f\fast"
-- Check for working C compiler: D:/Bilals/PcBackupData/sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
CMake Error at D:/Bilals/PcBackupData/sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"D:/Bilals/PcBackupData/sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/Bilals/Projects/GithubProjects/mobile-ffmpeg/android/build/cpu-features/arm/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_adf3f\fast"
The system cannot find the file specified
Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_adf3f\fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:9 (project)
-- Configuring incomplete, errors occurred!
See also "D:/Bilals/Projects/GithubProjects/mobile-ffmpeg/android/build/cpu-features/arm/CMakeFiles/CMakeOutput.log".
See also "D:/Bilals/Projects/GithubProjects/mobile-ffmpeg/android/build/cpu-features/arm/CMakeFiles/CMakeError.log".
and here is my environmental variables
You should use Linux Make, not NMake. Generally speaking, these scripts were never tuned to run on Windows, in cygwin or mingw shell, even though I have run them in WSL (Ubuntu) bash.

How to build runnable apk with aapt2?

I have a simple android project.
This commands compile resources and build apk without dex:
aapt2 compile project/res/values/strings.xml project/res/layout/activity_main.xml -o project/compiled_res
aapt2 link -o project/apk/unsigned_app.apk -I sdk/platforms/android-28/android.jar --manifest project/src/AndroidManifest.xml -R project/compiled_res/*.flat --java project/src --auto-add-overlay
Quote from documentation:
However, the generated APK does not contain DEX bytecode and is
unsigned
...
you can use other command line tools, such as d8 to
compile Java bytecode into DEX bytecode and apksigner to sign your
APK.
Ok. I can:
d8 project/compiled_classes/com/illuzor/buildtest/*.class --output project/dex
But how to pack this dex to apk? aapt2 can`t recognize classes.dex:
I can just add classes.dex to my apk by zipping:
zip -uj project/apk/unsigned_app.apk project/dex/classes.dex
And it works after aligning and signing. But must be another way, more proper.
I'm looking for a proper way too. But I have no luck even it is 2019 now, and I searched everywhere, for days.
I guess aapt add will get the job done, but your solution with zip is not bad.
Hope aapt won't be deprecated soon, or aapt2 should get enhanced before that happens.

Compilation Python 3.6.5 static binary for arm32 fail

I'm trying, on Debian 9.4 x64, to compiling static Python binaries for arm32.
I have initialy:
downloaded the "Gzipped source tarball" source file from:
https://www.python.org/downloads/release/python-365/
extracted source files in: /python3.6.5/
downloaded and extract "binutils-gold-2.29.1-16.1.armv7hl.rpm" by cmd line:
rpm -qlp /python3.6.5/binutils-gold-2.29.1-16.1.armv7hl.rpm
try to compile the binary with this following command:
./configure --build=arm --prefix="$PWD"/out LDFLAGS="-static -static-libgcc -Wl,--unresolved-symbols=ignore-all -Wl,--export-dynamic" CPPFLAGS=-static CXXFLAGS=-static CFLAGS="-Os -static" LDFLAGS=-static LD=ld.gold
And i get this errors:
/usr/bin/ld: BFD assertion (GNU Binutils for Debian) 2.28 as failed ../../bfd/elflink.c:14098
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.28 internal error, aborting at ../../bfd/elf64-x86-64.c:6137 in elf_x86_64_finish_dynamic_symbol
/usr/bin/ld: Thanks to report this anomaly.
collect2: error: ld returned 1 exit status
Makefile:561 : the recipe for the "python" target has failed
-make: *** [python] Error 1
I'm trying to find how i could fix this error, but unfortunatly the support webpage on Python website isn't helpfull (https://wiki.python.org/moin/BuildStatically).
Finally, I would like to compile Python 3.6.5 for all processor platforms on which Android can run (arm32, aarm64, x86_x64, mips, mipsx64,...), to ultimately get a single binary file (i will repeat tasks for all other archs when i will have done with arm32).
So one file for each architectures cited, not multiple files/folders.
In a static way to avoid any dependencies with external libraries.
I chose to carry out the build operations, but if other less hazardous and simpler solutions exist i am taker.
NB: all cmd line has been made through LXTerminal on root session by default.
Thanks by advance for help.

Error when trying to add NewRelic library into my application

I'm trying to including the NewRelic library into my project, but I get this error when I build it
Error:Execution failed for task ':v1:preDexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Program Files\Android\android-studio\sdk\build-tools\19.1.0\dx.bat --dex --output
C:\Documents and Settings\t.hart\My Documents\Android\MoneyTracker\v1\build\pre-dexed\debug\android-agent-3.378.0-27125f93a249f513379e837d75ebec255f6dcaa4.jar
C:\Documents and Settings\t.hart\.gradle\caches\modules-2\files-2.1\com.newrelic.agent.android\android-agent\3.378.0\1ebf0e20081a7f1b9a5c31bfc4e7dba776e0c171\android-agent-3.378.0.jar
Error Code:
1
Output:
Error opening zip file or JAR manifest missing : C:\Documents
To include the library you need to add 3 lines to your build.gradle files,
//This to the buildscript dependancies
classpath 'com.newrelic.agent.android:agent-gradle-plugin:3.378.0'
//This line (in the example it's under the android line
apply plugin: 'newrelic'
//And this to dependancies
compile 'com.newrelic.agent.android:android-agent:3.378.0'
After some trial and error it seems it's the last line (the compile one) that's causing the error to be thrown. Is this because of the spaces in C:/Documents And Settings?
I'm also using these librarys, and they all downloaded to the build/pre-dexed/debug folder fine with no issues.
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
compile 'com.android.support:support-v4:19.1.0'
EDIT: Updated error message
Error:Execution failed for task ':v1:preDexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Program Files\Android\android-studio\sdk\build-tools\19.1.0\dx.bat --dex --output
C:\MoneyTracker\v1\build\pre-dexed\debug\support-v4-19.1.0-cd41ef807caadb29c9df0131dee869d3723185ad.jar
C:\Program Files\Android\android-studio\sdk\extras\android\m2repository\com\android\support\support-v4\19.1.0\support-v4-19.1.0.jar
Error Code:
1
Output:
Error opening zip file or JAR manifest missing : C:\Documents
Now that's a strange error...
It effectively has to do with spaces in your folders names, the error message tells you gradle can't find a zip or jar manifest in C:\Documents, which is obviously not the folder your newrelic library is in. Try moving your project in a directory which name doesn't have space. Make it a habit, some tools really don't like spaces in filenames (especially unix rooted one).
You can set the GRADLE_USER_HOME environment variable, gradle.user.home system property, or --gradle-user-home command line parameter to directory which name doesn't have space.
(via How to change Gradle download location)

Cannot build cordova project successfully error while executing ant debug command

I was having an error that is Camera not successful invoked on first try (click) so I tried this solution on stackoverflow Phonegap(3.0.0) Camera not successful on first try.
I followed the steps as mentioned in the answer removed android by cordova platform remove android then I run the second command cordova platform add android ;
Now when I use netbeans to run the cordova application on cordova android decvice this error occurs:
exec: ant debug -f "/var/www/mobile/platforms/android/build.xml"
[ 'ant debug -f "/var/www/mobile/platforms/android/build.xml"',
{ [Error: Command failed:
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
] killed: false, code: 1, signal: null },
'Buildfile: /var/www/mobile/platforms/android/build.xml\n\n-set-mode-check:\n\n-set-debug-files:\n\n-check-env:\n [checkenv] Android SDK Tools Revision 22.3.0\n [checkenv]
.
.
.**LONG TEXT which I removed from the post **
.
\nBUILD FAILED\n/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720:
The following error occurred while executing this line:\n/var/www/adt-bundle-linux-x86_64- 20130917/sdk/tools/ant/build.xml:734:
Compile failed; see the compiler error output for details.\n\nTotal time: 8 seconds\n' ]
Error executing "ant debug -f "/var/www/mobile/platforms/android/build.xml"":
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
child_process.spawn(/var/www/mobile/platforms/android/cordova/build,[]) = 2
/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
Error: An error occurred while building the android project.Error executing "ant debug -f "/var/www/mobile/platforms/android/build.xml"":
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cordova/src/compile.js:65:22)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
/var/www/mobile/nbproject/build.xml:256: exec returned: 8
BUILD FAILED (total time: 4 minutes 36 seconds)
any idea about this problem?
I was having a similar issue. I ran ant debug -f "/path/to/project/build.xml" from a separate terminal. It displayed a more specific description of the error (which for me wast that there was a space in the project name). This answer also notes:
config.xml can't have a widget id with number as a first character
after a dot. For example: com.42myapp.test or com.myapp.42test won't
work as well as 42com.myapp.test. It will trigger an error from the
compiler.
I was facing similar issues when i started using the CLI to build apps using cordova and started checking the internet for solutions. While i was at it, i discovered the following things that may help you or anyone else facing the same problem can take some hints from this:
These are some very basic checks that you need to take
1. make sure you have all the required sdk's in place (ANT, Java, Android) and is available when you use these commands on the terminal/command $ ant $ java $ adt. if any of these commands are not found, then you need to get it installed or get the class paths fixed.
make sure your project path does not have spaces. i.e. do not have spaces or special characters in directory names. this issue seems to have been fixed on latest versions of cordova and phonegap, but either cases it is a good practice to follow as ant and java paths could be dependent on the folder names you make.
use -d or -v to get extra debug information on the build process to know where and what is causing the issue. $ cordova build android -d or $ cordova build android -v
Make sure you dont use "#" as the link attribute of author tag in the cordova config.xml on the root of the project. This expects the compiler to interpret a hexadecimal color and fails the build. (this was my problem)
Hope this helps.
er... Happy debugging??
Make sure your Ant is 1.8.0 or later version. Cordova 3.3 demands that.
In the past several days, I found that the conflicting files from Dropbox had a very long name. After renaming it, everything worked.

Categories

Resources