Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.4k views
in Technique[技术] by (71.8m points)

android - What Huawei AdsKit AdListener.onAdFailed errorCode 2 means?

I have integrated Huawei AdsKit (banner ads) and registered AdListener. onAdFailed is called with errorCode = 2. What can be a reason?

There is something [strange] in the log (JSON error):

2021-01-12 23:26:11.107 30332-30332 I/HiAdSDK.ae:  setBannerAdSize width: 468  height: 60
2021-01-12 23:26:11.115 30332-30417 W/HiAdSDK.HMSConnectProcessor:  check hms sdk available error
2021-01-12 23:26:11.118 30332-30417 I/HiAdSDK.HiAd:  ppskit api is not included
2021-01-12 23:26:14.025 30332-30332 I/HiAdSDK.PPSBannerViewViewMonitor:  onViewAttachedToWindow
2021-01-12 23:26:14.026 30332-30332 I/HiAdSDK.PPSBannerViewViewMonitor:  registerObservers
2021-01-12 23:26:14.028 30332-30332 I/HiAdSDK.PPSBannerViewViewMonitor:  onViewVisibilityChanged
2021-01-12 23:26:14.035 30332-30332 I/HiAdSDK.PPSNativeViewViewMonitor:  onViewAttachedToWindow
2021-01-12 23:26:14.036 30332-30332 I/HiAdSDK.PPSNativeViewViewMonitor:  registerObservers
2021-01-12 23:26:14.037 30332-30332 I/HiAdSDK.PPSNativeViewViewMonitor:  onViewVisibilityChanged
2021-01-12 23:26:14.041 30332-30332 I/HiAdSDK.PPSNativeViewViewMonitor:  onViewAttachedToWindow
2021-01-12 23:26:14.042 30332-30332 I/HiAdSDK.PPSNativeViewViewMonitor:  registerObservers
2021-01-12 23:26:14.043 30332-30332 I/HiAdSDK.PPSNativeViewViewMonitor:  onViewVisibilityChanged
2021-01-12 23:26:16.545 30332-30332 I/HiAdSDK.PPSBannerViewViewMonitor:  onViewVisibilityChanged
2021-01-12 23:26:16.546 30332-30332 I/HiAdSDK.PPSNativeViewViewMonitor:  onViewVisibilityChanged
2021-01-12 23:26:16.547 30332-30332 I/HiAdSDK.PPSNativeViewViewMonitor:  onViewVisibilityChanged
2021-01-12 23:26:16.553 30332-30332 I/HiAdSDK.ae:  load banner 
2021-01-12 23:26:16.567 30332-30332 I/HiAdSDK.h:  loadAds
2021-01-12 23:26:16.615 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:26:16.615 30332-30432 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:26:16.616 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag sendAsyncLocationByNative failed because switch is off
2021-01-12 23:26:16.654 30332-30432 W/HiAdSDK.jd:  Root obj class (class java.lang.Object) is invalid
2021-01-12 23:26:16.655 30332-30432 W/HiAdSDK.jd:  toJson jsex
2021-01-12 23:26:16.663 30332-30432 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqNativeAd
2021-01-12 23:26:16.667 30332-30432 I/HiAdSDK.Decouple.PPSApiServiceManager:  bindService 1610475976666
2021-01-12 23:26:16.668 30332-30432 I/HiAdSDK.HiAdTools:  current connected service pkg: null
2021-01-12 23:26:16.675 30332-30432 I/HiAdSDK.HiAdTools:  isSupportHmsAdsService hms ver: 50005300
2021-01-12 23:26:16.679 30332-30432 I/HiAdSDK.Decouple.PPSApiServiceManager:  bind service pkg: com.huawei.hwid
2021-01-12 23:26:16.689 30332-30432 I/HiAdSDK.Decouple.PPSApiServiceManager:  bind service result: true
2021-01-12 23:26:16.694 30332-30435 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqConfig
2021-01-12 23:26:16.696 30332-30435 I/HiAdSDK.Decouple.PPSApiServiceManager:  bindService 1610475976695
2021-01-12 23:26:16.698 30332-30435 I/HiAdSDK.HiAdTools:  current connected service pkg: null
2021-01-12 23:26:16.705 30332-30435 I/HiAdSDK.HiAdTools:  isSupportHmsAdsService hms ver: 50005300
2021-01-12 23:26:16.708 30332-30435 I/HiAdSDK.Decouple.PPSApiServiceManager:  bind service pkg: com.huawei.hwid
2021-01-12 23:26:16.715 30332-30435 I/HiAdSDK.Decouple.PPSApiServiceManager:  bind service result: true
2021-01-12 23:26:16.918 30332-30332 I/HiAdSDK.PPSBannerViewViewMonitor:  onViewShown
2021-01-12 23:26:17.134 30332-30332 I/HiAdSDK.Decouple.PPSApiServiceManager:  PPS remote service connected 1610475977134
2021-01-12 23:26:17.137 30332-30332 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: AidlConnectMonitorMethod
2021-01-12 23:26:17.156 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqNativeAd code: -1 msg: JSONException:Input json string cannot be empty!
2021-01-12 23:26:17.160 30332-30430 I/HiAdSDK.h:  onAdFailed, errorCode:-1
2021-01-12 23:26:17.445 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqConfig code: 200 msg: null
2021-01-12 23:26:37.668 30332-30433 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: apistatistics
2021-01-12 23:26:37.700 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call apistatistics code: 200 msg: null
2021-01-12 23:26:46.930 30332-30332 I/HiAdSDK.h:  loadAds
2021-01-12 23:26:46.936 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:26:46.937 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag sendAsyncLocationByNative failed because switch is off
2021-01-12 23:26:46.952 30332-30417 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:26:46.990 30332-30417 W/HiAdSDK.jd:  Root obj class (class java.lang.Object) is invalid
2021-01-12 23:26:46.992 30332-30417 W/HiAdSDK.jd:  toJson jsex
2021-01-12 23:26:46.994 30332-30417 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqNativeAd
2021-01-12 23:26:47.001 30332-30432 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqConfig
2021-01-12 23:26:47.007 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqNativeAd code: -1 msg: JSONException:Input json string cannot be empty!
2021-01-12 23:26:47.009 30332-30430 I/HiAdSDK.h:  onAdFailed, errorCode:-1
2021-01-12 23:26:47.021 30332-30433 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: apistatistics
2021-01-12 23:26:47.054 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call apistatistics code: 200 msg: null
2021-01-12 23:26:47.261 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqConfig code: 200 msg: null
2021-01-12 23:27:16.954 30332-30332 I/HiAdSDK.h:  loadAds
2021-01-12 23:27:16.961 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:27:16.961 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag sendAsyncLocationByNative failed because switch is off
2021-01-12 23:27:16.978 30332-30448 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:27:17.009 30332-30448 W/HiAdSDK.jd:  Root obj class (class java.lang.Object) is invalid
2021-01-12 23:27:17.010 30332-30448 W/HiAdSDK.jd:  toJson jsex
2021-01-12 23:27:17.012 30332-30448 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqNativeAd
2021-01-12 23:27:17.018 30332-30448 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqConfig
2021-01-12 23:27:17.023 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqNativeAd code: -1 msg: JSONException:Input json string cannot be empty!
2021-01-12 23:27:17.025 30332-30430 I/HiAdSDK.h:  onAdFailed, errorCode:-1
2021-01-12 23:27:17.035 30332-30434 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: apistatistics
2021-01-12 23:27:17.070 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call apistatistics code: 200 msg: null
2021-01-12 23:27:17.277 30332-30356 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqConfig code: 200 msg: null
2021-01-12 23:27:46.980 30332-30332 I/HiAdSDK.h:  loadAds
2021-01-12 23:27:46.989 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:27:46.991 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag sendAsyncLocationByNative failed because switch is off
2021-01-12 23:27:47.007 30332-30432 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:27:47.048 30332-30432 W/HiAdSDK.jd:  Root obj class (class java.lang.Object) is invalid
2021-01-12 23:27:47.050 30332-30432 W/HiAdSDK.jd:  toJson jsex
2021-01-12 23:27:47.053 30332-30432 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqNativeAd
2021-01-12 23:27:47.061 30332-30455 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqConfig
2021-01-12 23:27:47.067 30332-30356 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqNativeAd code: -1 msg: JSONException:Input json string cannot be empty!
2021-01-12 23:27:47.069 30332-30430 I/HiAdSDK.h:  onAdFailed, errorCode:-1
2021-01-12 23:27:47.075 30332-30433 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: apistatistics
2021-01-12 23:27:47.112 30332-30356 I/HiAdSDK.Decouple.PPSApiServiceManager:  call apistatistics code: 200 msg: null
2021-01-12 23:27:47.333 30332-30349 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqConfig code: 200 msg: null
2021-01-12 23:28:17.012 30332-30332 I/HiAdSDK.h:  loadAds
2021-01-12 23:28:17.024 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:28:17.025 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag sendAsyncLocationByNative failed because switch is off
2021-01-12 23:28:17.044 30332-30458 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:28:17.065 30332-30458 W/HiAdSDK.jd:  Root obj class (class java.lang.Object) is invalid
2021-01-12 23:28:17.066 30332-30458 W/HiAdSDK.jd:  toJson jsex
2021-01-12 23:28:17.068 30332-30458 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqNativeAd
2021-01-12 23:28:17.073 30332-30458 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqConfig
2021-01-12 23:28:17.080 30332-30349 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqNativeAd code: -1 msg: JSONException:Input json string cannot be empty!
2021-01-12 23:28:17.083 30332-30430 I/HiAdSDK.h:  onAdFailed, errorCode:-1
2021-01-12 23:28:17.090 30332-30434 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: apistatistics
2021-01-12 23:28:17.127 30332-30349 I/HiAdSDK.Decouple.PPSApiServiceManager:  call apistatistics code: 200 msg: null
2021-01-12 23:28:17.328 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqConfig code: 200 msg: null
2021-01-12 23:28:47.046 30332-30332 I/HiAdSDK.h:  loadAds
2021-01-12 23:28:47.057 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:28:47.058 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag sendAsyncLocationByNative failed because switch is off
2021-01-12 23:28:47.079 30332-30463 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:28:47.109 30332-30463 W/HiAdSDK.jd:  Root obj class (class java.lang.Object) is invalid
2021-01-12 23:28:47.110 30332-30463 W/HiAdSDK.jd:  toJson jsex
2021-01-12 23:28:47.112 30332-30463 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqNativeAd
2021-01-12 23:28:47.127 30332-30465 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: reqConfig
2021-01-12 23:28:47.128 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqNativeAd code: -1 msg: JSONException:Input json string cannot be empty!
2021-01-12 23:28:47.131 30332-30430 I/HiAdSDK.h:  onAdFailed, errorCode:-1
2021-01-12 23:28:47.139 30332-30433 I/HiAdSDK.Decouple.PPSApiServiceManager:  call remote method: apistatistics
2021-01-12 23:28:47.180 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call apistatistics code: 200 msg: null
2021-01-12 23:28:47.363 30332-30372 I/HiAdSDK.Decouple.PPSApiServiceManager:  call reqConfig code: 200 msg: null
2021-01-12 23:29:17.086 30332-30332 I/HiAdSDK.h:  loadAds
2021-01-12 23:29:17.098 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:29:17.100 30332-30430 I/HiAdSDK.LocationUtils:  loc_tag sendAsyncLocationByNative failed because switch is off
2021-01-12 23:29:17.115 30332-30469 I/HiAdSDK.LocationUtils:  loc_tag isGpsSwitchOpen locationMode is 0
2021-01-12 23:29:17.143 30332-30469 W/HiAdSDK.jd:  Root obj class (class java.lang.Object) is invalid
2021-01-12 23:29:17.144 30332-30469 W/HiAdSDK.jd:  toJ

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems to be an SDK bug: if AdParam.Bulder keywords are used it requires some other fields too.

I've compared my code with example and found the difference, i've passed ad request keywords:

private AdParam requestAd(boolean addKeywords) {
        AdParam.Builder builder = new AdParam.Builder();
        // --- cut start ---
        if (addKeywords) {
            String[] keywords = context.getResources().getStringArray(R.array.ad_keywords);
            for (String eachKeyword : keywords) {
                builder.addKeyword(eachKeyword);
            }
        }
        // --- cut stop ---
        return builder.build();
    }

If i specify the sex (builder.setGender(1);) - it does not help.

Don't set keywords to workaround it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...