Open deakjahn opened 7 months ago
I fail to see the real reason for BuildConfigMediation
at all. The adapter version could be hardwired directly and the SDK version doesn't need to be stored and synchronized manually because it can be queried simply:
override fun getVersionInfo(): VersionInfo {
Log.d(TAG, "getVersionInfo()")
return VersionInfo(2, 0, 1 * 100)
}
override fun getSDKVersionInfo(): VersionInfo {
Log.d(TAG, "getSDKVersionInfo()")
val versionString: String = HwAds.getSDKVersion()
val splits = versionString.split(".").toTypedArray()
return if (splits.size >= 3) {
val major = splits[0].toInt()
val minor = splits[1].toInt()
val micro = splits[2].toInt()
VersionInfo(major, minor, micro)
} else
VersionInfo(0, 0, 0)
}
Also note that the split()
delimiters are wrong.
The plugin also needs agconnect-services.json
bundled with your app, or at least the relevant data from it. I would suggest a different approach than bundling it and applying the agconnect
plugin:
override fun initialize(context: Context, initializationCompleteCallback: InitializationCompleteCallback, list: List<MediationConfiguration>) {
Log.d(TAG, "initialize()")
try {
AGConnectInstance.initialize(context, AGConnectOptionsBuilder().apply {
setClientId("xxx")
setClientSecret("xxx")
setApiKey("xxx")
setCPId("xxx")
setProductId("xxx")
setAppId("xxx")
setPackageName("xxx")
})
HwAds.init(context);
initializationCompleteCallback.onInitializationSucceeded()
}
catch (e: IOException) {
initializationCompleteCallback.onInitializationFailed(e.message ?: "")
}
}
This, of course, means that you have to copy the source and incorporate it into your own app rather than referencing it on GitHub. Something that I'd suggest, anyway, because of the current errors. You can also hardwire all your other identifiers like your add unit ids, too.
Contrary to what the source says:
https://github.com/Explore-In-HMS/huawei.ads.admob_mediation/blob/deb4ef1e2032014f3b6095e9816f94efb476a1ed/admob_mediation/src/main/java/com/hmscl/huawei/admob_mediation/all_ads.kt#L77-L84
it is called, very much so, and expects to be called back as:
Otherwise, the GMS will wait for the timeout, note a failure with the adapter and won't use it at all.
So:
See the documentation at: https://developers.google.com/ad-manager/mobile-ads-sdk/android/custom-events/setup