Search Unity

Question Cannot find protocol declaration for 'GADRewardedAdDelegate'

Discussion in 'Package Manager' started by wernergast, Mar 15, 2023.

  1. wernergast

    wernergast

    Joined:
    Jul 12, 2022
    Posts:
    18
    Hi,

    I changing admob ads to unity ads and get this error in Xcode.

    Cannot find protocol declaration for 'GADRewardedAdDelegate'

    I fill in -> dotmob -> mobile ads the game id and import the unity ads package

    I delete:
    google mobile ads map
    plugin -> ios map
    externaldependies.... map

    I only find that I need to reinstall admob package but I dont want to use admob anymore.
    This is the full error.

    Has anyone a sollution?

    upload_2023-3-15_12-17-3.png


    Code (CSharp):
    1. // Copyright 2018 Google Inc. All Rights Reserved.
    2.  
    3. #import "GADURewardedAd.h"
    4.  
    5. #import <CoreGraphics/CoreGraphics.h>
    6. #import <UIKit/UIKit.h>
    7.  
    8. #import "GADUPluginUtil.h"
    9. #import "UnityAppController.h"
    10. #import "UnityInterface.h"
    11.  
    12. @interface GADURewardedAd () <GADRewardedAdDelegate>
    13. @end
    14.  
    15. @implementation GADURewardedAd
    16.  
    17. + (UIViewController *)unityGLViewController {
    18.   UnityAppController *applicationDelegate = [UIApplication sharedApplication].delegate;
    19.   return applicationDelegate.rootViewController;
    20. }
    21.  
    22. - (instancetype)initWithRewardedAdClientReference:(GADUTypeRewardedAdClientRef *)rewardedAdClient
    23.                                          adUnitID:(NSString *)adUnitID {
    24.   self = [super init];
    25.   if (self) {
    26.     _rewardedAdClient = rewardedAdClient;
    27.     _rewardedAd = [[GADRewardedAd alloc] initWithAdUnitID:adUnitID];
    28.  
    29.     __weak GADURewardedAd *weakSelf = self;
    30.     _rewardedAd.paidEventHandler = ^void(GADAdValue *_Nonnull adValue) {
    31.       GADURewardedAd *strongSelf = weakSelf;
    32.       if (strongSelf.paidEventCallback) {
    33.         int64_t valueInMicros =
    34.             [adValue.value decimalNumberByMultiplyingByPowerOf10:6].longLongValue;
    35.         strongSelf.paidEventCallback(
    36.             strongSelf.rewardedAdClient, (int)adValue.precision, valueInMicros,
    37.             [adValue.currencyCode cStringUsingEncoding:NSUTF8StringEncoding]);
    38.       }
    39.     };
    40.   }
    41.   return self;
    42. }
    43.  
    44. - (void)loadRequest:(GADRequest *)request {
    45.   [self.rewardedAd loadRequest:request
    46.              completionHandler:^(GADRequestError *_Nullable error) {
    47.                if (error) {
    48.                  if (self.adFailedToLoadCallback) {
    49.                    NSString *errorMsg =
    50.                        [NSString stringWithFormat:@"Failed to receive ad with error: %@",
    51.                                                   [error localizedDescription]];
    52.                    self.adFailedToLoadCallback(
    53.                        self.rewardedAdClient, [errorMsg cStringUsingEncoding:NSUTF8StringEncoding]);
    54.                  }
    55.                } else {
    56.                  if (self.adReceivedCallback) {
    57.                    self.adReceivedCallback(self.rewardedAdClient);
    58.                  }
    59.                }
    60.              }];
    61. }
    62.  
    63. - (BOOL)isReady {
    64.   return [self.rewardedAd isReady];
    65. }
    66.  
    67. - (void)show {
    68.   if ([self.rewardedAd isReady]) {
    69.     UIViewController *unityController = [GADURewardedAd unityGLViewController];
    70.     [self.rewardedAd presentFromRootViewController:unityController delegate:self];
    71.   } else {
    72.     NSLog(@"GoogleMobileAdsPlugin: Rewarded ad is not ready to be shown.");
    73.   }
    74. }
    75.  
     
  2. A6cloud

    A6cloud

    Joined:
    Aug 30, 2021
    Posts:
    1
    Fixed , By deleting every thing starts by ( Google , GAD .. etc ) re Importing latest version of Admob Package
     
    Last edited: Mar 17, 2023
  3. wernergast

    wernergast

    Joined:
    Jul 12, 2022
    Posts:
    18
    The problem is that i dont want to use admob anymore. I use only unity ads. If i dont delete the package unity ads dont work.
     
  4. wernergast

    wernergast

    Joined:
    Jul 12, 2022
    Posts:
    18
    I delete the files in unity and did not update the build file. I thought it was automatic.
     
  5. kojiruri

    kojiruri

    Joined:
    Jan 11, 2019
    Posts:
    2
  6. dingaloo12

    dingaloo12

    Joined:
    Jun 30, 2020
    Posts:
    12
    I'm having a similar error, where I deleted google ads, and added Unity ads, and keep getting an error relating to google ads not being set up properly. I deleted every mention of google ads, including what @kojiruri and @A6cloud suggested, but still get errors.

    At one point I got it to run (I just installed the google ads dependencies I think) but since google ads isn't set up, it said I needed to properly initialize it. I went back to unity, double checked that it was all removed as necessary, made some changes, and now it's showing a ton of "GAD" undefined symbols again.
     
  7. dogugzm

    dogugzm

    Joined:
    Oct 11, 2023
    Posts:
    1
    I just deleted all Google Ad files under Plugins - IOS. After that re-download Google Ad Package but just import IOS folder.