Jump to content
Vanar

AdMob in Delphi11

Recommended Posts

On 5/30/2024 at 12:27 AM, Dave Nottage said:

No, since one is an application id, and the other is an ad unit id.

By setting the AdUnitId property of those you have ids for. You set these up in the AdMob web interface

.The most likely cause is that you need to configure GDPR and IDFA messages, here.

I still have an error. Consent error from: ConsentInfoUpdate - 3: Publisher misconfiguration: Failed to read publisher's account configuration; no form(s) configured for the input app ID. Verify that you have configured one or more forms for this application and try again. Received app ID: `ca-app-pub-3285XXXXXX~XXXXX"

 

I've changed

       <meta-data
                android:name="com.google.android.gms.ads.APPLICATION_ID"
                android:value="ca-app-pub-3285XXXXXX~96437XXXXX" />
        <service
            android:name="com.google.android.gms.metadata.ModuleDependencies"
            android:enabled="false"
            android:exported="false"

 

In unit1.pas add

AdMobBannerAd1.AdUnitID:='ca-app-pub-3285XXXXXX/21205XXXXX'

 

advertising format identifier - banner .

Is there anything else that needs to be changed for the test application?

 

Share this post


Link to post
2 hours ago, sevalx@gmail.com said:

I still have an error. Consent error from: ConsentInfoUpdate - 3: Publisher misconfiguration...

Which is the same error as last time, where I advised:

2 hours ago, sevalx@gmail.com said:

The most likely cause is that you need to configure GDPR and IDFA messages, here.

Have you configured the GDPR and IDFA messages?

2 hours ago, sevalx@gmail.com said:

Is there anything else that needs to be changed for the test application?

Not in the application itself. See above.

Share this post


Link to post
21 hours ago, Dave Nottage said:

Have you configured the GDPR and IDFA messages? 

I have added GDPR messages. I don't use IDFA. No, I’m writing applications for the iPhone. Now the test application does not display any messages at all. It closes when you press the button. But when I press other buttons, nothing happens.

2342.png

Share this post


Link to post
27 minutes ago, sevalx@gmail.com said:

Now the test application does not display any messages at all. It closes when you press the button

I assume by "close" you mean it crashes? At this point I can only suggest adding logging to the app to see exactly where it is failing. 

Share this post


Link to post
22 hours ago, Dave Nottage said:

I assume by "close" you mean it crashes? At this point I can only suggest adding logging to the app to see exactly where it is failing. 

I sent the log in a private message. and I also wanted to ask... is it possible to show ads with this component without enabling GDPR and IDFA, or does the component only work when GDPR and IDFA are enabled? For example, countries where this does not apply. This is necessary for an application that is intended for only one country, for example.

Share this post


Link to post
1 hour ago, sevalx@gmail.com said:

I sent the log in a private message

Here is the problem:

2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	FATAL EXCEPTION: Thread-6
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	Process: com.embarcadero.AdTestD12, PID: 12847
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/R$string;
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	at com.google.android.gms.measurement.internal.zzga.zza(com.google.android.gms:play-services-measurement-base@@20.1.2:1)
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	at com.google.android.gms.internal.measurement.zzee.<init>(com.google.android.gms:play-services-measurement-sdk-api@@20.1.2:8)
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	at com.google.android.gms.internal.measurement.zzee.zzg(com.google.android.gms:play-services-measurement-sdk-api@@20.1.2:2)
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	at com.google.android.gms.measurement.api.AppMeasurementSdk.getInstance(com.google.android.gms:play-services-measurement-sdk-api@@20.1.2:3)
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	at com.google.android.gms.internal.ads.zzbnq.run(com.google.android.gms:play-services-ads-lite@@22.2.0:10)
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	at java.lang.Thread.run(Thread.java:1012)
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.R$string" on path: DexPathList[[zip file "/data/app/~~aO0p4K6Hjy9h4IY8lEyzVQ==/com.embarcadero.AdTestD12-AUBcLSpltNJ395APPGwSJA==/base.apk"],nativeLibraryDirectories=[/data/app/~~aO0p4K6Hjy9h4IY8lEyzVQ==/com.embarcadero.AdTestD12-AUBcLSpltNJ395APPGwSJA==/lib/arm, /data/app/~~aO0p4K6Hjy9h4IY8lEyzVQ==/com.embarcadero.AdTestD12-AUBcLSpltNJ395APPGwSJA==/base.apk!/lib/armeabi-v7a, /system/lib, /system/system_ext/lib]]
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
2024.06.12 22:02:52.452	E	com.embarcadero.AdTestD12	12847	15753	AndroidRuntime	... 6 more

Not sure why this was not happening before. I see from your first post about this you are using an emulator? I strongly advise to use a real device. If you are unable to, make sure the emulator system image includes "Play Store":

  

image.thumb.png.9f4543ca61f25246db1f8ec8fe648cb6.png

Share this post


Link to post
On 6/12/2024 at 11:41 PM, Dave Nottage said:

Here is the problem:

Not sure why this was not happening before. I see from your first post about this you are using an emulator? I strongly advise to use a real device. If you are unable to, make sure the emulator system image includes "Play Store":

  

 

I use real mobile phone

Share this post


Link to post
2 hours ago, sevalx@gmail.com said:

I use real mobile phone

What make/model? And what version of Android is on it?

Share this post


Link to post
On 6/25/2024 at 11:14 AM, Dave Nottage said:

Is this using the demo, unaltered, following all of the instructions? In which version of Delphi?

Maybe you can post an apk application with your built-in advertising (of all types) so that I can install it and see how advertising will work. This may not work due to sanctions and restrictions in some countries. Although it doesn’t work with VPN either.

Share this post


Link to post
On 6/29/2024 at 3:34 PM, sevalx@gmail.com said:

Maybe you can post an apk application with your built-in advertising (of all types) so that I can install it and see how advertising will work.

Posted a 64-bit APK built with Delphi 12 here

Share this post


Link to post

yes I only use a real phone. samsung a31 (android 12). If it doesn’t start with your data, then there’s no point in looking for an error in the code. But why does my application close, but yours starts and does not close itself? have you added error and exception handling?

 

 

 

 

 

 

 

 

 

 

 

 

Share this post


Link to post
3 hours ago, sevalx@gmail.com said:

yes I only use a real phone

Your screenshot looks very much like it is from an emulator

3 hours ago, sevalx@gmail.com said:

But why does my application close, but yours starts and does not close itself?

I don't know, because you never really answered this question:

On 6/25/2024 at 4:44 PM, Dave Nottage said:

Is this using the demo, unaltered, following all of the instructions? In which version of Delphi?

 

3 hours ago, sevalx@gmail.com said:

have you added error and exception handling?

No - it is built direct from the demo app, with no alterations, using Delphi 12.1

Share this post


Link to post

Hi,

I Have some problems with this demo. I am using Nokia 2.2 with Android 11 and Delphi 12.2. I have tested the demo in 32 and 64 bit but app crash in DW.AdMob.Android.pas on line 263. This line is TJMobileAds.JavaClass.initialize(TAndroidHelper.Context);

 

I have a breakpoint before and after this line. No consent is shown.

 

Can you help me?

Thanks.

 

P.s. I read all the posts carefully.

Share this post


Link to post
6 hours ago, Manuel S. said:

I have tested the demo in 32 and 64 bit but app crash in DW.AdMob.Android.pas on line 263

Is there an error message? If not, please use a log viewer to check if the system is generating any error messages.

Share this post


Link to post

Hi,

I have used DeviceLens and I have find this message when is executed TJMobileAds.JavaClass.initialize(TAndroidHelper.Context);

"The Google Play services resources were not found. Check your project configuration to ensure that the resources are included."

 

1) I have deleted ADTestD12.R.jar from my project because library play-services-base:18.1.0.jar already exists and I think it needs only for Delphi 11.3.

Is correct?

2) However I did a test by creating this file and got an error during deployment on the manifest file. You can see the attached images.
Do you have any advice?

3) If I delete from device the app, consent is shown only first time but app crash when I click on consent.

4) I have added logcat.log with all log before crash.

 

Immagine.png

Immagine2.png

Immagine3.png

logcat.log

Edited by Manuel S.

Share this post


Link to post
3 hours ago, Manuel S. said:

"The Google Play services resources were not found. Check your project configuration to ensure that the resources are included."

You can ignore this message.

3 hours ago, Manuel S. said:

1) I have deleted ADTestD12.R.jar from my project because library play-services-base:18.1.0.jar already exists and I think it needs only for Delphi 11.3.

Is correct?

No, it is not correct. The file should not be deleted as it contains code necessary for the application to work.

3 hours ago, Manuel S. said:

4) I have added logcat.log with all log before crash.

These are the relevant lines from the log:

2025/01/26 18:01:17.006	E	com.embarcadero.AdTestD12	13280	13708	AndroidRuntime	FATAL EXCEPTION: Thread-3
2025/01/26 18:01:17.006	E	com.embarcadero.AdTestD12	13280	13708	AndroidRuntime	Process: com.embarcadero.AdTestD12, PID: 13280
2025/01/26 18:01:17.006	E	com.embarcadero.AdTestD12	13280	13708	AndroidRuntime	java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/R$string;
2025/01/26 18:01:17.006	E	com.embarcadero.AdTestD12	13280	13708	AndroidRuntime	at com.google.android.gms.measurement.internal.zzga.zza(com.google.android.gms:play-services-measurement-base@@20.1.2:1)
2025/01/26 18:01:17.006	E	com.embarcadero.AdTestD12	13280	13708	AndroidRuntime	at com.google.android.gms.internal.measurement.zzee.<init>(com.google.android.gms:play-services-measurement-sdk-api@@20.1.2:8)
2025/01/26 18:01:17.006	E	com.embarcadero.AdTestD12	13280	13708	AndroidRuntime	at com.google.android.gms.internal.measurement.zzee.zzg(com.google.android.gms:play-services-measurement-sdk-api@@20.1.2:2)
2025/01/26 18:01:17.006	E	com.embarcadero.AdTestD12	13280	13708	AndroidRuntime	at com.google.android.gms.measurement.api.AppMeasurementSdk.getInstance(com.google.android.gms:play-services-measurement-sdk-api@@20.1.2:3)
2025/01/26 18:01:17.006	E	com.embarcadero.AdTestD12	13280	13708	AndroidRuntime	at com.google.android.gms.internal.ads.zzbnq.run(com.google.android.gms:play-services-ads-lite@@22.2.0:10)
2025/01/26 18:01:17.006	E	com.embarcadero.AdTestD12	13280	13708	AndroidRuntime	at java.lang.Thread.run(Thread.java:923)
2025/01/26 18:01:17.006	E	com.embarcadero.AdTestD12	13280	13708	AndroidRuntime	Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.R$string" on path: DexPathList[[zip file "/data/app/~~Pts3t76XeBO1SwYlnYkkgg==/com.embarcadero.AdTestD12-tDvQz1HYX23fQ4WpUJMxbw==/base.apk"],nativeLibraryDirectories=[/data/app/~~Pts3t76XeBO1SwYlnYkkgg==/com.embarcadero.AdTestD12-tDvQz1HYX23fQ4WpUJMxbw==/lib/arm, /data/app/~~Pts3t76XeBO1SwYlnYkkgg==/com.embarcadero.AdTestD12-tDvQz1HYX23fQ4WpUJMxbw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/system_ext/lib]]

The error is occurring because you removed ADTestD12.R.jar from the project. 

On 1/25/2025 at 10:59 PM, Manuel S. said:

P.s. I read all the posts carefully.

It seems you did not carefully read the instructions from the demo.

Share this post


Link to post

Hi,

As demonstrated by the images in my previous post which I am reporting now, I did a test by creating the ADTestD12.R.jar file but I had a problem compiling the Android.Manifest.xml file as demonstrated by the images below.

 

I have modified file play-services-base18.1.0-Manifest.merge.xml and project runs very well.

Sorry.

 

Immagine3.png

Immagine2.thumb.png.8122d1929b1a2ce759ca46dbe301c447.png

Edited by Manuel S.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×