Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging ad failed to load #355

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class CrashlyticsReportingTree @Inject constructor(
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
if (priority == Log.ERROR && t != null) {
crashlytics.recordException(t)
} else {
crashlytics.log(message)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.viewinterop.AndroidView
import androidx.lifecycle.compose.LifecycleResumeEffect
import com.google.android.gms.ads.AdListener
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.AdSize
import com.google.android.gms.ads.AdView
import com.google.android.gms.ads.LoadAdError
import com.toquete.boxbox.core.common.annotation.Generated
import com.toquete.boxbox.feature.home.R
import timber.log.Timber

@Composable
fun AdBanner(modifier: Modifier = Modifier) {
Expand Down Expand Up @@ -78,6 +81,11 @@ private fun getAdView(context: Context, width: Int, isPreviewMode: Boolean): AdV
return AdView(context).apply {
adUnitId = resources.getString(R.string.home_ad_unit_id)
setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(context, width))
adListener = object : AdListener() {
override fun onAdFailedToLoad(error: LoadAdError) {
Timber.w("Ad failed to load: $error")
}
}
loadAd(AdRequest.Builder().build())
}
}
Expand Down
Loading