gpt4 book ai didi

android - 为什么当我添加 GDPR EU 同意时我的应用程序 android 崩溃?

转载 作者:行者123 更新时间:2023-12-04 04:23:39 24 4
gpt4 key购买 nike

我将 GDPR 代码添加到我的应用程序中,但它崩溃了。

这是我的功能:

private void loadGPDR() {

ConsentInformation consentInformation = ConsentInformation.getInstance(this);
String[] publisherIds = {"yyyyyyyyyyyyyy"};
consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
@Override
public void onConsentInfoUpdated(ConsentStatus consentStatus) {
// User's consent status successfully updated.
}

@Override
public void onFailedToUpdateConsentInfo(String errorDescription) {
// User's consent status failed to update.
}
});
URL privacyUrl = null;
try {
// TODO: Replace with your app's privacy policy URL.
privacyUrl = new URL("https://sites.google.com/view/yyyyyyyyyy");
} catch (MalformedURLException e) {
e.printStackTrace();
// Handle error.
}
form = new ConsentForm.Builder(this, privacyUrl)
.withListener(new ConsentFormListener() {
@Override
public void onConsentFormLoaded() {
// Consent form loaded successfully.
form.show();
}

@Override
public void onConsentFormOpened() {
// Consent form was displayed.
}

@Override
public void onConsentFormClosed(
ConsentStatus consentStatus, Boolean userPrefersAdFree) {
// Consent form was closed.
}

@Override
public void onConsentFormError(String errorDescription) {
// Consent form error.
}
})
.withPersonalizedAdsOption()
.withNonPersonalizedAdsOption()
.withAdFreeOption()
.build();
form.load();
}

错误:

Process: com.code.myapplication, PID: 28444
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.code.myapplication/com.code.myapplication.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x2040003
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2420)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5294)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:114)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040003
at android.content.res.Resources.getText(Resources.java:321)
at android.content.res.XResources.getText(XResources.java:837)
at android.content.res.Resources.getString(Resources.java:407)
at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:684)
at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:608)
at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:631)
at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:780)
at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:619)
at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:556)
at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:311)
at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:96)
at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:263)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:123)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:110)
at com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:107)
at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:260)
at android.webkit.WebView.<init>(WebView.java:554)
at android.webkit.WebView.<init>(WebView.java:489)
at android.webkit.WebView.<init>(WebView.java:472)
at android.webkit.WebView.<init>(WebView.java:459)
at android.webkit.WebView.<init>(WebView.java:449)
at com.google.ads.consent.ConsentForm.<init>(ConsentForm.java:80)
at com.google.ads.consent.ConsentForm.<init>(ConsentForm.java:46)
at com.google.ads.consent.ConsentForm$Builder.build(ConsentForm.java:210)
at com.code.myapplication.MainActivity.loadGPDR(MainActivity.java:70)
at com.code.myapplication.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)

最佳答案

Belyamani Said 的评论对我有用。只需更新 appcompat 库:

来自:

implementation 'androidx.appcompat:appcompat:1.1.0'

到:

implementation 'androidx.appcompat:appcompat:1.2.0-alpha03'

关于android - 为什么当我添加 GDPR EU 同意时我的应用程序 android 崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58440781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com