Classes annotated as visibleForTesting

491 views
Skip to first unread message

Asapha

unread,
Sep 28, 2022, 11:33:29 AM9/28/22
to Google Mobile Ads SDK Developers
It seems that some classes such as com.google.android.gms.ads.AdSize and com.google.android.gms.ads.AdRequest have the @VisibleForTesting annotation in the SDK.

Why would that be the case? Both of those classes are used in samples in the docs.

Using them leads to this error when running Android's linter:
This method should only be accessed from tests or within private scope

A warning is also shown in Android Studio.

Versions used:
com.google.firebase:firebase-ads:21.2.0
AGP 7.4.0-beta01
Android Studio Electric Eel | 2022.1.1 Beta 1

Mobile Ads SDK Forum Advisor

unread,
Sep 28, 2022, 9:32:48 PM9/28/22
to azefx...@gmail.com, google-adm...@googlegroups.com

Hi Asapha,

Thank you for reaching out to us.

Can you confirm if the error you've mentioned is showing in our sample app? Upon checking our sample app for banner, I haven't seen the error "This method should only be accessed from tests or within private scope". With that, can you provide us privately your sample app project and steps to replicate for us to further investigate this? You can provide the following details via Reply privately to author option or directly provide it to the link below.

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002euGnCQAU&entry.80707362=00139488

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

Regards,

Google Logo
Princess Pamela
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2euGnC:ref
Message has been deleted

Asapha

unread,
Sep 30, 2022, 1:08:58 PM9/30/22
to Google Mobile Ads SDK Developers
My last messages with the exact repro steps are getting deleted.
Trying 1 last time without quoting your response…

The gist of it is to update to Gradle 7.5.1, AGP 7.4.0-beta01 and run the :app:lintDebug task.
In the html report, you'll see a warning about the visibleForTesting annotation.
I could repro via the interstitial sample project.

On my end, I'm getting the error because my project has lint { warningsAsErrors } in its build.gradle.

While we can easily suppress the warning, I can't see why these publicly documented classes would have the annotation.

Mobile Ads SDK Forum Advisor

unread,
Sep 30, 2022, 2:39:53 PM9/30/22
to azefx...@gmail.com, google-adm...@googlegroups.com
Hi Asapha,

Thank you for getting back to us. It's odd that your response were deleted. Could you please upload the requested information using the steps below instead?

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002euGnCQAU&entry.80707362=00139488

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.



Regards,
Google Logo
Teejay Wennie
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2euGnC:ref

Hermawan Winata

unread,
Mar 1, 2023, 12:41:49 AM3/1/23
to Google Mobile Ads SDK Developers
Hi Teejay,

I have the same lint warning in Android Studio. I have uploaded a screenshot of the warning.
I don't think a public API should be annotated with VisibleForTesting. Or perhaps Android Studio should not consider that annotation from the SDK?
I'm using "com.google.android.gms:play-services-ads:21.2.0".

Mobile Ads SDK Forum Advisor

unread,
Mar 1, 2023, 5:45:13 AM3/1/23
to shin...@gmail.com, google-adm...@googlegroups.com
Hello,

Does this warning still appear if you update the SDK to 21.5.0? Feel free to reach back to us at any time if you still encounter this.

Regards,
Google Logo Mobile Ads SDK Team


ref:_00D1U1174p._5004Q2euGnC:ref

Rayan M

unread,
Mar 16, 2023, 11:37:52 AM3/16/23
to Google Mobile Ads SDK Developers
Hello.

I can confirm that the issue for the com.google.android.gms.ads.AdSize class has been fixed in 21.5.0 but the issue remains for com.google.android.gms.ads.admanager.AdManagerAdRequest which we are also expected to use as per the documentation : https://developers.google.com/admob/android/banner but is still marked as @VisibleForTesting.

Best regards.

Mobile Ads SDK Forum Advisor

unread,
Mar 16, 2023, 3:32:32 PM3/16/23
to google-adm...@googlegroups.com

Hi Rayan,

Thank you for confirming that the issue for the com.google.android.gms.ads.AdSize class has been fixed in version 21.5.0. For the com.google.android.gms.ads.admanager.AdManagerAdRequest, can you provide us the following information for us to further check this in our end?

  • Sample app project where this behavior is happening
  • Steps to replicate
  • SDK version
  • App Id
  • Device name and versions affected
  • Screenshots (if any)

You can provide the following details via reply privately to author option or directly provide it to the link below.

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

Regards,

Reply all
Reply to author
Forward
0 new messages