Android issue with backticked method names

Backticks basically allow almost any name that is legal on the platform to be used as symbol. The JVM basically excludes a select few characters but otherwise allows almost anything (see Chapter 4 of the spec). This is great for compatibility, but beyond that may cause unexpected issues for tools that make narrower assumptions.

Android does not actually run Java class files, but uses a different kind of virtual machine (originally Dalvik) that uses the DEX format instead. As part of building your app it will take all your .class files and translates them into a single (or multiple for multidex) dex file. Without looking at the DEX spec it is clear that this format is more restrictive on symbol names. The Android studio compiler error message thus is 100% correct.

This is basically a DEX limitation. The only thing that could work around this would be for Kotlin (or the dex compiler) to mangle the names to something legal. If you rely on the names that will cause errors. Otherwise you can try “proguard” (or google’s replacement for it in the latest Android build tools) to mangle everything including your space-containing names. Of course if you want the names to be test names that doesn’t help :frowning: