Crash in WordpieceTextEncoder
zenyagami opened this issue · 3 comments
I tried to search for min sdk version and in the manifest it looks like api 8, however in the class
WordpieceTextEncoder
there is a call using
return this.vocabulary.getOrDefault(token,this.vocabulary.get(UNKNOWN));
in encodeSingle
(line 90) from WordpieceTextEncoder
I had a crash because of getOrDefault
, this is supported only from api 24+
would be nice to use something like
return this.vocabulary[token] ?: this.vocabulary.get(UNKNOWN));
version 11.4.1
(tha's kotlin)
Ah, 8 is the minimum API level for the core speech pipeline, but we've been building against newer versions internally. Thanks for the catch. No reason that call can't be updated to do things the pre-Java 1.8 way.
Out of curiosity, which API level are you targeting?
I found in a crash , not many has android 6
minSdkVersion 23
targetSdkVersion 30
I don't have many users under 23 but still many are targeting android 20+
After some digging, it turns out that this problem can be resolved with a little Gradle file trickery; see this Google issue.
I don't get a crash on API 21 in the emulator if I add the following to my build.gradle
:
compileOptions {
coreLibraryDesugaringEnabled = true
}
// ...
dependencies {
// ...
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")
}
I do still plan to remove the call to the newer method; just wanted to let you know about the workaround until it's released.
Note that you'll also probably have trouble with TTS on an API that old due to ExoPlayer...but there's a workaround to that too: add the following to your gradle.properties
:
android.enableDexingArtifactTransform=false