android / privacy-sandbox-samples

Apache License 2.0
130 stars 52 forks source link

Failing to build FetchAndJoinCustomAudienceRequest #78

Closed davidae closed 1 year ago

davidae commented 1 year ago

Now that FetchAndJoinCustomAudienceRequest is out on DP9, I wanted to try the functionality, but when I call,

val request = FetchAndJoinCustomAudienceRequest.Builder(fetchURI)
    .setName(name)
    .setActivationTime(activationTime)
    .setExpirationTime(expirationTime)
    .build()

I get the following error

FATAL EXCEPTION: binder:13136_4
Process: com.example.client_sdk_sandbox, PID: 13136
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/adservices/customaudience/FetchAndJoinCustomAudienceRequest$Builder;
  ...
  ...
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.adservices.customaudience.FetchAndJoinCustomAudienceRequest$Builder" on path: DexPathList[[zip file "/data/app/~~cuGD8yBmE5QfjE8O7098iw==/com.example.privacysandbox.provider_10000-Hqro1mYFHZ8PHcnRezQgbw==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

Android Studio is able to do autocomplete over the objects, and I see the following details on the builder

  < Android API 33, UpsideDownCakePrivacySandbox preview, extension level 6 Platform > (android.jar)

Some other noteworthy configuration values I have are,

robclifford27 commented 1 year ago

Hey @davidae thanks for trying to test the sample. Hopefully I can help you get unblocked here: What version of Android Studio are you using? Also, your emulator device is one of the Play Store enabled versions correct?

davidae commented 1 year ago

Hey, @robclifford27, thank you for reaching out.

What version of Android Studio are you using?

I'm using Hedgehog | 2023.1.1 Canary 15

Also, your emulator device is one of the Play Store enabled versions correct?

Yes, I believe so. Here is a snipped from my emulator Device Info Properties

image.androidVersion.api         34
image.androidVersion.codename    UpsideDownCakePrivacySandbox
image.sysdir.1                   system-images/android-UpsideDownCakePrivacySandbox/google_apis_playstore/x86_64/
PlayStore.enabled                true
runtime.network.latency          none
runtime.network.speed            full
showDeviceFrame                  yes
skin.dynamic                     yes
tag.display                      Google Play
tag.id                           google_apis_playstore
davidae commented 1 year ago

It seems that was the guiding hint I needed, upgraded to Iguana | 2023.2.1 Canary 1 August 25, 2023, and now it works :sweat_smile:

Cheers :+1:

robclifford27 commented 1 year ago

Awesome, good luck and let us know if you run into anything else!