当我尝试添加gdpr代码时,遇到了一些错误,但是遇到同样的问题,希望有人能帮助我,谢谢。
// TODO: Replace with your app's privacy policy URL.
privacyUrl = new URL("https://www.your.com/privacyurl");
} catch (MalformedURLException e) {
e.printStackTrace();
// Handle error.
}
ConsentForm form = new ConsentForm.Builder(context, privacyUrl)
.withListener(new ConsentFormListener() {
@Override
public void onConsentFormLoaded() {
// Consent form loaded successfully.
}
@Override
public void onConsentFormOpened() {
// Consent form was displayed.
}
答案 0 :(得分:0)
将依赖项添加到模块的build.gradle
中:
// Google AdMob, EU Cookie Consent
implementation ("com.google.android.ads.consent:consent-library:1.0.7") {
// exclude group: "com.google.code.gson"
}
进口为:
import com.google.ads.consent.AdProvider;
import com.google.ads.consent.ConsentForm;
import com.google.ads.consent.ConsentFormListener;
import com.google.ads.consent.ConsentInfoUpdateListener;
import com.google.ads.consent.ConsentInformation;
import com.google.ads.consent.ConsentStatus;
import com.google.ads.consent.DebugGeography;