android / privacy-sandbox-samples

Apache License 2.0
130 stars 52 forks source link

can't build PrivacySandboxJava #72

Closed cyberhorse208 closed 1 year ago

cyberhorse208 commented 1 year ago

i just download the latest code, branch main. use Android Studio Hedgehog | 2023.1.1 Canary 5 to open the PrivacySandboxJava project. after the android gradle plugin upgrade(8.0.0-alpha02 to 8.0.2), i got error message like this:

Could not resolve all dependencies for configuration ':client-app:oemDebugRuntimeClasspath'. Could not create task ':example-sdk:privacySandboxClassesJarStubs'. Could not resolve all files for configuration ':example-sdk:detachedConfiguration3'. Could not find androidx.privacysandbox.tools:tools:1.0.0-SNAPSHOT. Searched in the following locations:

did i do something wrong? how can i fix this?

siran-work commented 1 year ago

Thanks for reporting this issue! This issue can be fixed by updating AGP to the latest version (8.2.0-alpha08).

cyberhorse208 commented 1 year ago

8.2.0-alpha08 not supported by Gradle 8.2 which is the latest version supported by my AS: Android Studio Hedgehog | 2023.1.1 Canary 5 Build #AI-231.7864.76.2311.10195651, built on May 25, 2023

error msg: The project is using an incompatible version (AGP 8.2.0-alpha08) of the Android Gradle plugin. Latest supported version is AGP 8.2.0-alpha05

so i change AGP to 8.2.0-alpha05, after build.gradle "sync now", i still get many errors like this when tried to run on my pixel 6(android 14 with privacy sandbox enabled):

Task :client-app:mergeExtDexPreviewDebug

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

siran-work commented 1 year ago

The Unable to proceed generating shim with no provided sdk descriptor entries in: is an indication that there is no interface with @PrivacySanboxService specified. There are two options to resolve: 1) SDK modules require at least one library in its dependencies to contain an interface annotated with @PrivacySandboxService. So you may need to add something like the following to the sdk-implementation module:

package com.example.sdkimplementation

import androidx.privacysandbox.tools.PrivacySandboxService

@PrivacySandboxService interface SdkApi { fun createFile(sizeInMb: Int): String? }

The error message itself is from the client/app side attempting to generate shim code, but not having been provided with the @PrivacySandboxService from the SDK. Once you have a project that builds, you can verify the interface descriptors by looking at example-sdk/build/intermediates/stub_jar/sdk-interface-descriptors.jar

2) If the sdk doesn't require a service, you can specify android.experimental.privacysandboxsdk.requireServices=false.

cshmerling commented 1 year ago

Closing this due to inactivity. Please re-open if you are still having issues!