Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Cannot use Xamarin.GooglePlayServices.Ads package because it produces a compile-time error #250

Open
silviubogan opened this issue Aug 18, 2019 · 11 comments
Assignees
Labels
in-progress Work is in progress

Comments

@silviubogan
Copy link

silviubogan commented Aug 18, 2019

Xamarin.Android Version (eg: 6.0):

Android 9.0 (Pie).

Operating System & Version (eg: Mac OSX 10.11):

Windows 10 Pro, latest update at the time of this writing, 1903.

Google Play Services Version (eg: 8.4.0):

49 in the Android SDK Manager.

Describe your Issue:

The steps below throw a compile-time error that should not exist or hopefully it could be avoided somehow.

Steps to Reproduce (with link to sample solution if possible):

Step 1. Create a new Xamarin.Forms project (Empty template; just for Android) (see the link at the end of the issue for the repo).
Step 2. In the Package Manager Console in VS2019 (with latest updates) run

Install-Package Xamarin.GooglePlayServices.Ads -Version 71.1720.0

Step 3. Press the Start button (it has the label Samsung SM-G960F (Android 9.0 - API 28).

Include any relevant Exception Stack traces, build logs, adb logs:

Output pane > Show output from Build:

Runtime checks completed
1>------ Build started: Project: App2, Configuration: Debug Any CPU ------
1>App2 -> E:\Lucru\teste\App2\App2\App2\bin\Debug\netstandard2.0\App2.dll
2>------ Build started: Project: App2.Android, Configuration: Debug Any CPU ------
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1755,2): warning XA0106: Skipping App2.Droid.Resource.Drawable.avd_hide_password_1. Please check that your Nuget Package versions are compatible.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1755,2): warning XA0106: Skipping App2.Droid.Resource.Drawable.avd_hide_password_2. Please check that your Nuget Package versions are compatible.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1755,2): warning XA0106: Skipping App2.Droid.Resource.Drawable.avd_hide_password_3. Please check that your Nuget Package versions are compatible.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1755,2): warning XA0106: Skipping App2.Droid.Resource.Drawable.avd_show_password_1. Please check that your Nuget Package versions are compatible.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1755,2): warning XA0106: Skipping App2.Droid.Resource.Drawable.avd_show_password_2. Please check that your Nuget Package versions are compatible.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1755,2): warning XA0106: Skipping App2.Droid.Resource.Drawable.avd_show_password_3. Please check that your Nuget Package versions are compatible.
2>  App2.Android -> E:\Lucru\teste\App2\App2\App2.Android\bin\Debug\App2.Android.dll
2>  No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
2>  obj\Debug\90\android\src\mono\com\google\android\gms\ads\reward\mediation\MediationRewardedVideoAdListenerImplementor.java:4: error: MediationRewardedVideoAdListenerImplementor is not abstract and does not override abstract method zzb(Bundle) in MediationRewardedVideoAdListener
2>  public class MediationRewardedVideoAdListenerImplementor
2>         ^
2>  Note: Some input files use or override a deprecated API.
2>  Note: Recompile with -Xlint:deprecation for details.
2>  Note: Some input files use unchecked or unsafe operations.
2>  Note: Recompile with -Xlint:unchecked for details.
2>  1 error
2>E:\Lucru\teste\App2\App2\App2.Android\obj\Debug\90\android\src\mono\com\google\android\gms\ads\reward\mediation\MediationRewardedVideoAdListenerImplementor.java(4,8): error :  error: MediationRewardedVideoAdListenerImplementor is not abstract and does not override abstract method zzb(Bundle) in MediationRewardedVideoAdListener
2>E:\Lucru\teste\App2\App2\App2.Android\obj\Debug\90\android\src\mono\com\google\android\gms\ads\reward\mediation\MediationRewardedVideoAdListenerImplementor.java(4,8): error : public class MediationRewardedVideoAdListenerImplementor
2>E:\Lucru\teste\App2\App2\App2.Android\obj\Debug\90\android\src\mono\com\google\android\gms\ads\reward\mediation\MediationRewardedVideoAdListenerImplementor.java(4,8): error : 
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

Test repository

https://github.com/silviubogan/testing-xamarin-ads

Update

I have seen that on GitHub there are updates not published in NuGet. How can I use them? I have discovered this page. Is it what I need?

@VladislavAntonyuk
Copy link

I can add that 71.1720.0 - preview6 doesn't have the issue

@lukealderton
Copy link

Can confirm, 71.1712.1 did not have the issue, after updating to 71.1720.0, this error is now present during compile.

@lukealderton
Copy link

error: MediationRewardedVideoAdListenerImplementor is not abstract and does not override abstract method zzb(Bundle) in MediationRewardedVideoAdListener
public class MediationRewardedVideoAdListenerImplementor GymWorkoutTracker.Android K:\Internal Projects\Gym Workout Tracker v2\GymWorkoutTracker\GymWorkoutTracker.Android\obj\Debug\90\android\src\mono\com\google\android\gms\ads\reward\mediation\MediationRewardedVideoAdListenerImplementor.java 4

@silviubogan
Copy link
Author

I followed this tutorial and it does not work for me although since I posted this issue I downloaded this recent archive in the Releases page of this repo and built it.

I wonder what is the difference between:

  1. Xamarin.Firebase.Ads.71.1601.0.nupkg and
  2. Xamarin.GooglePlayServices.Ads.71.1720.0.nupkg

packages found in the output directory after the complete build is done?

If I use either package above I get the following compile error:

unexpected element <activity> found in <manifest>.	App1.Android	E:\Lucru\xamarin-guess-my-number\App1\App1.Android\obj\Debug\90\android\manifest\AndroidManifest.xml	37

The file in the error is this (generated automatically): E:\Lucru\xamarin-guess-my-number\App1\App1.Android\obj\Debug\90\android\manifest\AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.app1" android:installLocation="auto">
  <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.INTERNET" />
  <application android:label="App1.Android" android:name="android.app.Application" android:allowBackup="true" android:icon="@mipmap/icon" android:debuggable="true">
    <activity android:configChanges="orientation|screenSize" android:icon="@mipmap/icon" android:label="App1" android:theme="@style/MainTheme" android:name="md5a445f6db5abf8b5b69aa92721cad9446.MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <service android:name="md5dcb6eccdc824e0677ffae8ccdde42930.KeepAliveService" />
    <receiver android:enabled="true" android:exported="false" android:label="Essentials Battery Broadcast Receiver" android:name="md5d630c3d3bfb5f5558520331566132d97.BatteryBroadcastReceiver" />
    <receiver android:enabled="true" android:exported="false" android:label="Essentials Energy Saver Broadcast Receiver" android:name="md5d630c3d3bfb5f5558520331566132d97.EnergySaverBroadcastReceiver" />
    <receiver android:enabled="true" android:exported="false" android:label="Essentials Connectivity Broadcast Receiver" android:name="md5d630c3d3bfb5f5558520331566132d97.ConnectivityBroadcastReceiver" />
    <provider android:authorities="com.companyname.app1.fileProvider" android:exported="false" android:grantUriPermissions="true" android:name="xamarin.essentials.fileProvider">
      <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/xamarin_essentials_fileprovider_file_paths" />
    </provider>
    <receiver android:enabled="true" android:exported="false" android:name="md51558244f76c53b6aeda52c8a337f2c37.PowerSaveModeBroadcastReceiver" />
    <provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="1999999999" android:authorities="com.companyname.app1.mono.MonoRuntimeProvider.__mono_init__" />
    <!--suppress ExportedReceiver-->
    <receiver android:name="mono.android.Seppuku">
      <intent-filter>
        <action android:name="mono.android.intent.action.SEPPUKU" />
        <category android:name="mono.android.intent.category.SEPPUKU.com.companyname.app1" />
      </intent-filter>
    </receiver>
    <!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
    <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:exported="false" android:theme="@android:style/Theme.Translucent" />
    <provider android:name="com.google.android.gms.ads.MobileAdsInitProvider" android:authorities="com.companyname.app1.mobileadsinitprovider" android:exported="false" android:initOrder="100" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
  </application>
  <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>

The error part is from here: E:\Lucru\xamarin-guess-my-number\App1\App1.Android\Properties\AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.app1" android:installLocation="auto">
	<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
	<application android:label="App1.Android"></application>
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
	<uses-permission android:name="android.permission.INTERNET" />
  <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
</manifest>

If I remove the last activity and the last uses-permission elements in the last file presented above:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.app1" android:installLocation="auto">
	<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
	<application android:label="App1.Android"></application>
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

I get this error again:

MediationRewardedVideoAdListenerImplementor is not abstract and does not override abstract method zzb(Bundle) in MediationRewardedVideoAdListener
public class MediationRewardedVideoAdListenerImplementor	App1.Android	E:\Lucru\xamarin-guess-my-number\App1\App1.Android\obj\Debug\90\android\src\mono\com\google\android\gms\ads\reward\mediation\MediationRewardedVideoAdListenerImplementor.java	4

@motoko89
Copy link

It appears to be a bug regression? #236 @moljac

@moljac moljac added the in-progress Work is in progress label Aug 20, 2019
@moljac moljac self-assigned this Aug 20, 2019
@moljac
Copy link
Member

moljac commented Aug 20, 2019

@motoko89 Not regression, but similar.

@silviubogan @lukealderton @VladislavAntonyuk

Explanation:

In preview I managed to bind 17.2.0, but due to some other updates (in other GPS artifacts) and missing external dependency version (TensorFlow.Lite, etc) I was forced to release with version 17.1.2.

Between 17.1.2 and 17.2.0 the name of one of the obfuscated classes changed from zzc to zzb and that causes this error.

here is the code (and comment)

https://github.com/xamarin/GooglePlayServicesComponents/blob/master/source/com.google.android.gms/play-services-ads-lite/Transforms/Metadata.xml#L77

I fixed that and tagged 71.20190819 last night (CET):

https://github.com/xamarin/GooglePlayServicesComponents/releases/tag/71.20190819

Just update to 71.1720.1

https://www.nuget.org/packages/Xamarin.GooglePlayServices.Ads.Lite/71.1720.1

And please let me know if that worked.

Even better - close the issue if it is OK

@VladislavAntonyuk
Copy link

The issue is fixed

@moljac
Copy link
Member

moljac commented Aug 21, 2019

@silviubogan @lukealderton @motoko89
For you guys, does it work?

@silviubogan
Copy link
Author

@moljac This issue is solved although I have another issue: I have to build the packages from the latest tag you created because I figured out I have to use Xamarin.Firebase.Ads package or at least Xamarin.Firebase.Ads.Lite instead of Xamarin.GooglePlayServices.Ads and Xamarin.GooglePlayServices.Ads.Lite, and their NuGet version is not updated to this tag. If I fail to do this, I think I will open a new issue for updating the NuGet version. I hope it is OK. Thank you. When I use the package in your link above I get this exception:

Java.Lang.RuntimeException: 'Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: 

******************




******************

'

Screenshot:

2019-08-21_14-33-12

@moljac
Copy link
Member

moljac commented Aug 21, 2019

@silviubogan
Just go ahead and open new issue please

@moljac
Copy link
Member

moljac commented Nov 5, 2019

Closing this one as resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in-progress Work is in progress
Projects
None yet
Development

No branches or pull requests

5 participants