Unity Admob The type or namespace name 'BannerView' could not be found Error Solution

Unity Admob The type or namespace name 'BannerView' could not be found Hatası Çözümü


Unity Admob The type or namespace name 'BannerView' could not be found Error Solution

 Hello everyone, in this post I will talk about an error you may encounter when trying to use AdMob ads with Unity and how to solve it.

The error we encounter is "The type or namespace name 'BannerView' could not be found", and to enter the full message: "error CS0246: The type or namespace name 'BannerView' could not be found (are you missing a using directive or an assembly reference?)", which is quite a lengthy error.

This error can occur for a few reasons. The first one is that you did not install the AdMob package on Unity. However, if you have made it this far as a game developer, I don't think you forgot or failed to install the necessary plugin for ads. Still, for those who want to download the latest version, I am leaving the download link here.

GitHub - Unity AdMob Plugin

Google AdMob Unity Page

Here I am sharing a screenshot of the error we received, and then I will move on to the solutions.



AdMob Error


If you still get the same error after adding the package I mentioned above to your project, then our solution is the following.


GoogleMobileAds > Editor 


 Go to this location and

 

GoogleMobileAds.Editor


Click on the file with this name and in the Inspector window on the right, you need to check the box for Use GUID's and you also need to tick the boxes for Android, iOS, and Editor under the "Platforms" section.

After checking these boxes, when you click the "Apply" button at the bottom in the Inspector window, the problem will be solved.

This is how it normally looks before ticking the boxes.


Unity Admob The type or namespace name 'BannerView' could not be found Hatası Çözümü

This is how it should look after the boxes are checked.


Unity Admob The type or namespace name 'BannerView' could not be found Hatası Çözümü

Note: Another method found by someone else is that if the libraries are not included correctly while importing, this error may also occur, and when the library info is corrected, the error goes away. I mentioned this above, but maybe those who missed it will realize it from the warning at the end of the article.

The library you need to import is "using GoogleMobileAds.Api;" but if you import it as "using GoogleMobileAds;" you will get an error.


If you still have issues despite all these, don't hesitate to comment, and if someone finds another solution to this error, I would be very happy if you share it as well. Have a good day and happy gaming.