Android issue with backticked method names


I started to use kotlin for frontend game development. After a while I tried to run my game in android, but it didn't work. It refused to get it installed on the device. The error I got was a bit strange. After investigating a bit more, I found that the DEX verifier rejected my code because I was using method names with spaces.

Something like this:

fun  `a long name with spaces and maybe even symbols`()

It was great because it allowed me to create method names that could display to the user as possible actions to do withoyt any extra annotation.

Since I didn’t get any notice or warning and all this worked fine on desktop. I wanted to discuss this behaviour.

It seems to not to work on Android. backtick could be limited to operator names, or be marshaled or at least produce some kind of notice or warning about this. What do you think about this? Have anyone had this problem too?


This is unfortunate indeed. Feel free to file an issue in our tracker.


Hi, any update to this? This is usually mentioned as a great Kotlin feature for testing, but Android Studio compiler refuses to compile such methods saying that function name cannot be represented in dex format.

According to this Stackoverflow question it is working in test directory, but not in androidTest.

Maybe it could be caused by fact that androidTests are installed on device and basic test not, but it’d be great if it’d work.


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:


Hi, I understood the reasons soon after I found out its issue only of androidTests. Thank you for your response