Building for Android with non-unique audio file names

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ragnar Brynjúlfsson

I’m trying to port my game to Android, but it fails to build presumably because I have sound files that have the same name. They’re in different folders in the project, but it seems the Android lumps them all together in an assets folder.

When I try to build it, I get this error when it comes to signing the game:

ADDING: resources.arsc
Starting signing of the APK binary using /home/ragtag/Games/android/sdk/build-tools/30.0.3/apksigner
Signing debug binary using:
/home/ragtag/Games/android/sdk/build-tools/30.0.3/apksigner sign --verbose --ks /home/ragtag/.android/debug.keystore --ks-pass pass:android --ks-key-alias androiddebugkey /home/ragtag/Games/mandarin_memory_game\
Exception in thread "main" Multiple ZIP entries with the same name: assets/sounds/chinese/.ogg.import

ERROR: Failed to export the project for platform 'Android'.
   at: _export_project_to_path (editor/project_export.cpp:863)

The game is a Chinese learning game, and it has two sound folders with around 5000 .ogg files each, of which around half share the same name (one uses Simplified characters, while the other uses Traditional, but there is a lot of overlap between the two).

The game builds fine for Windows and Linux, and I built a small test project for Android, and that worked fine too. So my build setup seems okay, it’s just this game that won’t build properly.

If non-unique sound files aren’t the issue, is it possible that there is an issue with files having Chinese characters in their names (e.g. 发言.ogg)?

I’m building on Ubuntu 20.04.3, with OpenJDK 11, Godot v3.4.2 and this:

  Path                 | Version      | Description                             | Location            
  -------              | -------      | -------                                 | -------             
  build-tools;30.0.3   | 30.0.3       | Android SDK Build-Tools 30.0.3          | build-tools/30.0.3  
  cmake; | 3.10.2       | CMake                    | cmake/
  cmdline-tools;latest | 6.0          | Android SDK Command-line Tools (latest) | cmdline-tools/latest
  emulator             | 31.2.8       | Android Emulator                        | emulator            
  ndk;21.4.7075529     | 21.4.7075529 | NDK (Side by side) 21.4.7075529         | ndk/21.4.7075529    
  patcher;v4           | 1            | SDK Patch Applier v4                    | patcher/v4          
  platform-tools       | 32.0.0       | Android SDK Platform-Tools              | platform-tools      
  platforms;android-29 | 5            | Android SDK Platform 29                 | platforms/android-29
:bust_in_silhouette: Reply From: Ragnar Brynjúlfsson

The problem does not seem to be non-unique names, but that the packaging doesn’t handle having files with Chinese characters in their names. I tried prefixing all the simplified characters with s and the traditional with t, but it made no difference. So the problem seem to be Chinese characters in the file names.

I guess I have to try use utf8 encoding of the characters as filenames instead, which is a pitty, because it means they’re no longer human readable.

:bust_in_silhouette: Reply From: Ragnar Brynjúlfsson

Just to follow this up. I fixed this by renaming all my audio files to their hex equivalent, so 爱.ogg would be e788b1.ogg, after which it built without issue for Android.

Damn. Android development truly is a mess. I’m glad you figured out a solution, although in 2022 Android should support unicode file names for this sort of thing.

blurrred | 2022-03-12 17:52