Googleads-mobile-unity: Latest builds not supporting API level lower than 14

Created on 10 Mar 2017  路  3Comments  路  Source: googleads/googleads-mobile-unity

I noticed that since v3.1.3 the plugin had a minimum SDK level set to 14 in the manifest and setting that to 9 would crash on older android versions.

The cause of the crash is both the uses of which crashes the app with a NoSuchMethodError exception.
mPopupWindow.getContentView().setSystemUiVisibility(visibilityFlags);

(Line 170 in Banner.java and line 168 in NativeExpressAd.java)

I'm not exactly sure why this is needed but I've built an app without it and tested it on a bunch of old and newer android versions across several devices and both banner ads and interstitials function normally.

Because of this and because I needed to manually position a banner advert in the middle of the screen whilst also supporting API levels above 9 in a project I just wrapped that part of the code in an SDK level check so API level 14 or higher still uses that line of code (I'm assuming it has some purpose, I'm just not sure what that is) but lower ignores it (allowing the plugin to work in all versions above 9).

        // Wrapped setSystemUiVisibility in an SDK level check to fix crashes on devices using SDK levels lower than 14
        if(android.os.Build.VERSION.SDK_INT >= 14) {
            // Copy system UI visibility flags set on Unity player window to newly created PopUpWindow.
            int visibilityFlags = mUnityPlayerActivity.getWindow().getAttributes().flags;
            mPopupWindow.getContentView().setSystemUiVisibility(visibilityFlags);
        }

Then obviously also change the minSdkVersion to 9 in /source/android-library/app/build/intermediates/exploded-aar/com.android.support/support-media-compat/25.1.1/AndroidManifest.xml

Is there any issues with removing this line of code, or at least any issues with just removing it if the SDK level is less than 14? Could we have this change included in a future release?

Thanks.

support question

All 3 comments

@Seani6 Support for Android SDKs < 14 has been dropped by the Google Mobile Ads SDK as well as Play Services. Since this plugin is a wrapper on top of the GMA SDK, it will have the same restrictions.

Ah darn that's a shame.

Well is there any issues with the fixes I suggested in my post? From the test devices we had removing the setSystemUiVisibility(..) lines on SDK < 14 seemed to fix everything but will it cause issues on certain android versions or in any specific situations?

The purpose of those two lines is to correctly position the ad views in immersive modes where the nav bar is hidden. Since ad views are placed in a PopUpWindow, the window will need to have to same UI visibility flags to ensure ad views are not offset by size of the nav bar. Immersive mode was only introduced in API 19 (don't think they're any devices with nav buttons running an older version of Android than this either), so you shouldn't run into any issues with the approach you're taking.

Was this page helpful?
0 / 5 - 0 ratings