Android aapt2 tool fails with "failed to open file: The device does not recognize the command"?

217 views Asked by At

as part of a custom Android build chain, I am calling "aapt2 link" in order to link the files generated by a previous call to "aapt2 compile" together. This works fine on Mac, but on Windows it fails with the following error:

failed to open file: The device does not recognize the command.

I'm using the same SDK versions, and the error happens on multiple systems, including my own those of users of our build chain.

I'm calling rapt as follows:

C:\Users\mh\AppData\Local\Android\sdk\build-tools\33.0.1\aapt2.exe 
link 
-v 
-o c:\obj\destination.apk 
--manifest c:\Obj\manifest.xml 
--java c:\Obj\java 
-I C:\obj\android.jar 
--proto-format 
--min-sdk-version 26 
--target-sdk-version 26 
@c:\Obj\Aapt2LinkFiles.txt

(paths shortened for clarity here). All files listed in c:\Obj\Aapt2LinkFiles.txt exist, and aapt prints them all out, before emitting the error.

Does anyone have an idea what I could be missing?

As a side question: Is there a way to see, in Android Studio, how and with what parameters aapt2 is called as part of the normal automated build process? Because builds in Android Studio work fine (but I seem to not be able tom find any lace where there is a full build log, in the way that other IDEs such as Xcode or Visual Studio provide a textual overview of what actual tools get executed and with what parameters, as you build.

Thanx!

Update full command line for repro:

C:> C:\Users\mh\AppData\Local\Android\sdk\build-tools\33.0.1\aapt2.exe link -v -o c:\Obj\ForAAB.apk --manifest c:\Obj\m.xml --java c:\Obj\java -I C:\obj\a.jar --proto-format --min-sdk-version 26 --target-sdk-version 26 @c:\Obj\files.txt

Output

note: including C:\obj\a.jar.
note: linking package 'org.me.testapt2' using package ID 7f.
c:\Obj\res-aapt2\drawable-hdpi_icon.png.flat
c:\Obj\res-aapt2\drawable-ldpi_icon.png.flat
c:\Obj\res-aapt2\drawable-mdpi_icon.png.flat
c:\Obj\res-aapt2\drawable-xhdpi_icon.png.flat
c:\Obj\res-aapt2\drawable_icon.png.flat
c:\Obj\res-aapt2\layout_main.xml.flat: error: failed to open file: The device does not recognize the command. (22).
error: failed parsing input.

files can be found at https://www.dropbox.com/s/zuuopmhyzkd271u/Obj.zip?dl=0, unzip to C:\Obj

0

There are 0 answers