# Guide to Handling API Changes in Android FiveSDK v3.2.0
# Overview
In Android FiveSDK v3.2.0, the SDK's public API implementation has been changed from Java to Kotlin.
In addition, the minSdkVersion has been raised to 24.
This guide explains the changes required in existing apps and libraries as a result of these updates.
# Scope
This guide describes the changes required when updating Android FiveSDK to v3.2.0 or later.
# Summary of Required Changes
| Calling Language | Target | Required Change |
|---|---|---|
| Common | minSdkVersion | Change to 24 or higher |
| Kotlin | Kotlin Gradle Plugin | Update to 2.1.10 or later |
| Kotlin | Code that calls getter methods from the Java API (such as getVersion() and getAdTitle()) | Change to Kotlin property access |
| Kotlin | SAM conversion for EventListener | Change from lambdas to anonymous objects |
# Change minSdkVersion to 24 or Higher
If the minSdkVersion of your app or library is 23 or lower, change it to 24 or higher.
The minSdkVersion of Android FiveSDK v3.2.0 is 24.
If you have already set it to 24 or higher, no changes are required.
# Example
# Update the Kotlin Gradle Plugin
If your project contains Kotlin code that references Android FiveSDK, update the Kotlin Gradle Plugin to 2.1.10 or later.
Android FiveSDK v3.2.0 is compiled with Kotlin 2.1.10 and includes Kotlin metadata version 2.1.0. Compilers in the Kotlin 1.9 series cannot read this metadata, so Kotlin code that references Android FiveSDK cannot be compiled.
If your app calls Android FiveSDK only from Java, you do not need to add the Kotlin Gradle Plugin.
# Example
# Change Getter Method Calls to Property Access in Kotlin Code
If your Kotlin code calls getter methods from the Java version of Android FiveSDK, change those calls to Kotlin property access.
If you were already using Kotlin property syntax when using the Java version of Android FiveSDK, no changes are required. Getter method calls from Java code are still supported as before.
For example, change getVersion() to version, and getAdTitle() to adTitle.
| Class | Kotlin Code Before | Kotlin Code After |
|---|---|---|
FiveAd | fiveAd.getVersion() | fiveAd.version |
FiveAd | FiveAd.getSdkVersion() | FiveAd.sdkVersion |
FiveAd | FiveAd.getSingleton() | FiveAd.singleton |
FiveAdCustomLayout | ad.getAdvertiserName() | ad.advertiserName |
FiveAdCustomLayout | ad.getLogicalWidth() | ad.logicalWidth |
FiveAdCustomLayout | ad.getLogicalHeight() | ad.logicalHeight |
FiveAdNative | ad.getContentViewLogicalWidth() | ad.contentViewLogicalWidth |
FiveAdNative | ad.getContentViewLogicalHeight() | ad.contentViewLogicalHeight |
FiveAdNative | ad.getAdMainView() | ad.adMainView |
FiveAdNative | ad.getButtonText() | ad.buttonText |
FiveAdNative | ad.getAdTitle() | ad.adTitle |
FiveAdNative | ad.getAdvertiserName() | ad.advertiserName |
FiveAdNative | ad.getDescriptionText() | ad.descriptionText |
FiveAdNative | ad.getLongDescriptionText() | ad.longDescriptionText |
# Before
val title = ad.getAdTitle()
# After
val title = ad.adTitle
# Change EventListener Declarations from Lambdas to Anonymous Objects in Kotlin Code
If you create the following EventListeners using Kotlin lambdas, change them to anonymous objects.
FiveAdCustomLayoutEventListenerFiveAdInterstitialEventListenerFiveAdNativeEventListener
These EventListeners were previously Java interfaces, but are now regular Kotlin interfaces.
Lambda creation through SAM conversion, which was available for Java interfaces, cannot be used with regular Kotlin interfaces.
Note that FiveAdVideoRewardEventListener is not affected by this change, because it has always required both onViewError() and onReward() and was therefore never a SAM interface.
# Before
val listener = FiveAdNativeEventListener { _, _ -> }
# After
val listener = object : FiveAdNativeEventListener {
override fun onViewError(
fiveAdNative: FiveAdNative,
errorCode: FiveAdErrorCode,
) {
// Error handling
}
}