googleads / googleads-mobile-android-mediation

Sample Android project showcasing how to build a mediation adapter or custom event for the Google Mobile Ads SDK.
Apache License 2.0
242 stars 198 forks source link

failed to compile by using AS 4.1.0 #300

Open samlu opened 4 years ago

samlu commented 4 years ago

Android Studio 4.1.0 no more supports BuildConfig.VERSION_NAME for library projects. See https://developer.android.com/studio/releases/gradle-plugin#behavior_changes for details.

It results in the related code won't pass the compilation. Here listed are some examples.

https://github.com/googleads/googleads-mobile-android-mediation/blob/f89acf12dd592dc5f8eae27bc0deb99e2a0ac896/ThirdPartyAdapters/facebook/facebook/src/main/java/com/google/ads/mediation/facebook/FacebookMediationAdapter.java#L148-L150

https://github.com/googleads/googleads-mobile-android-mediation/blob/189d8f8f7d1c214d8cab49eb5890fc00bf848a6e/ThirdPartyAdapters/facebook/facebook/src/main/java/com/google/ads/mediation/facebook/FacebookInitializer.java#L48-L49

Other mediation SDKs have the same issue.

ericleich commented 4 years ago

@samlu we discovered the same yesterday and are working on a solution for it by defining a custom build config parameter.

That said, are you having an issue including the already compiled Facebook adapter as recommended here, or are you trying to build the Facebook adapter yourself? I'd only suspect you'd have the problem if you're trying to build yourself.

samlu commented 4 years ago

Looking forward to seeing the new solution.

Yes, I am building the FAN adapter myself.

ericleich commented 4 years ago

@samlu So we haven't added this to Facebook yet as we haven't had to make a change on their adapter yet or do a release, but to unblock you, https://github.com/googleads/googleads-mobile-android-mediation/commit/908719f3d4704c61c3668a9366df01693f37b5a4 is an example of the approach we're taking on other adapters.

The BuildConfig generated by AS 4.1.0 doesn't have VERSION_NAME or VERSION_CODE anymore. We opted to define our own custom variable ADAPTER_VERSION instead, and use that in the code. By using a different custom field name as opposed to VERSION_NAME, it's compatible with older android studio versions (which would otherwise generate that field twice and fail to compile).