The following code generated by showkase has a deprecation warning when we update our Android SDK version to 34
public fun Showkase.getMetadata(): ShowkaseElementsMetadata {
try {
val showkaseComponentProvider =
Class.forName("REDACTED").newInstance() // deprecated!!!
as ShowkaseProvider
return showkaseComponentProvider.metadata()
} catch(exception: ClassNotFoundException) {
error("The class wasn't generated correctly. Make sure that you have setup Showkase correctly by following the steps here - https://github.com/airbnb/Showkase#Installation.")
}
}
Added in API level 1 Deprecated in API level 34
public T newInstance ()
This method was deprecated in API level 34. This method propagates any exception thrown by the nullary constructor, including a checked exception. Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. The Constructor.newInstance method avoids this problem by wrapping any exception thrown by the constructor in a (checked) InvocationTargetException .
The call
clazz.newInstance()
can be replaced by
clazz.getDeclaredConstructor().newInstance()
The following code generated by showkase has a deprecation warning when we update our Android SDK version to 34