问题
ConsentInformation consentInformation = ConsentInformation.getInstance(that);
String[] publisherIds = {"pub-XYZYXYZYXYZYXYZXY"};
consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
@Override
public void onConsentInfoUpdated(ConsentStatus consentStatus) {
Consent consent = new Consent();
if(!ConsentInformation.getInstance(that).isRequestLocationInEeaOrUnknown()) {
consentCallback(that, new AdRequest.Builder().build());
} else {
if(consentStatus == ConsentStatus.NON_PERSONALIZED) {
Bundle extras = new Bundle();
extras.putString("npa", "1");
AdRequest adRequest = new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class, extras).build();
consentCallback(that, adRequest);
} else if(consentStatus == ConsentStatus.PERSONALIZED) {
consentCallback(that, new AdRequest.Builder().build());
} else if(consentStatus == ConsentStatus.UNKNOWN) {
consent.collectConsent(that, miscellaneous, new ConsentInterface() {
@Override
public void callbackConsentInterface(AdRequest adRequest) {
consentCallback(that, adRequest);
}
});
}
}
}
So as you can see, I've correctly indicated my Pub ID (as highlighted in this similar question: Android - ConsentInformation - Could not parse Event FE preflight response).
However I still have this error:
W/System.err: Could not parse Event FE preflight response.
What could I do to fix this bug?
I precise that I didn't enter my bank account information in Google AdMob, and I can't do it to test for firm and technical reasons.
回答1:
I have solved my problem simply by strictly following those three steps I've imaginated. I've tested almost all combinations of them: if one of these steps isn't followed, you will get this "Could not parse Event". Otherwise, you won't get this error.
Follow these docs: https://developers.google.com/admob/android/eu-consent + https://firebase.google.com/docs/admob ("Get started for Android") + https://developers.google.com/admob ("Android setup")
Be sure to specify your Publisher ID in the Publisher IDs array for the Consent API (https://support.google.com/admob/answer/2784578)
Important: fill-in your payments informations in your Google AdMob account (https://apps.admob.com/v2/payments/settings) (not speaking about your credit card or any other payment method, but about your living coordinates)
Wait <= 24 hours
Following the above docs, create your AdMob "app", etc.
Be sure to have selected some providers in "Blocking Controls > EU Consent > Select ad technology providers" (https://apps.admob.com/v2/pubcontrols/eu-user-consent) (normally it's impossible to not have selected something)
[Not-Tested but found on the Internet] In your App-Level Gradle file, be sure to have:
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
Then it should work.
回答2:
The error may appear if your AdMob account isn't yet approved. Wait until the "Under Review" message disappear and try again.
来源:https://stackoverflow.com/questions/61405294/android-google-admob-could-not-parse-event-fe-preflight-response-but-i-have-cor