0

I am having problems adding Banner Ads to my Android App. I had done the app using Version 27 SDK. I followed the instruction on adding Banner ads, when I added the "implementation 'com.google.android.gms:play-services-ads:20.6.0'" in build.gradle, Android Studio flagged an error that SDK is inadequate and needs to be upgraded to 31 or higher.

I used the Project Structure Dialog to upgrade the SDK to version 31, the IDE then highlighted the dependencies that needed upgrading which I used the "Suggestion" tab to upgrade, tried to run the code and it won't run.The error on build terminal is shown below Build terminal error

Please can anyone help me solve this problem? Thanks in advance for your time.

Thanks to @Mikahli, I was able to go past the dependency issue but I am now getting errors on initialisation. I copied the code in the documentation, please see Initialisation Errors. Thanks in advance to everyone involved.

Mxgrig
  • 1
  • 1

2 Answers2

0

please check the following link. Maybe this is the problem you are facing now:

If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components.

If that's the case you can fix it by adding android:exported="true" to activities, services, or broadcast receivers in your Manifest

<activity android:name=".MainActivity"
            android:exported="true"
            >
Mikhail
  • 133
  • 2
  • 9
  • Thanks for your response. Should I upgrade SDK before doing this or not bother? – Mxgrig Apr 02 '22 at 15:14
  • @NeuTattler you need to apply the answer above in case you are planning to target SDK 31. If you don't want to update SDK, you can use an older version of a dependency, for example: `implementation 'com.google.android.gms:play-services-ads:20.3.0'` – Mikhail Apr 02 '22 at 15:28
  • @Mikhali Using your recommendation, I was able to go past those dependency issues, "THANK YOU VERY MUCH".However I am now getting initialisation errors which is a surprise because I literally copied the initialisation code from the documentation. I will post the screen shot in the question section – Mxgrig Apr 03 '22 at 14:42
  • @NeuTattler this is strange indeed. It's could be good to double-check that you added a correct value in the manifest `` – Mikhail Apr 04 '22 at 08:56
  • @Mikhali I had used the test id number because I wanted to test it before adding the admob one. It crashed, changed to the admob id, got a crash as well. – Mxgrig Apr 04 '22 at 18:36
  • @NeuTattler well, if you can share your current implementation related to AdMob I can try to check it, but I believe it should be not in this question because problems seem to be unrelated – Mikhail Apr 05 '22 at 01:12
0

The error image you have shown is related to the error manifest merger. I have seen this error before, so i recommend that you must see this answer.

Check this answer : Manifest merger failed..

maybe it will help..

Mohit Kumar
  • 79
  • 1
  • 3