我正在尝试加载广告。尝试时,应用程序崩溃并退出。
我正在使用Firebase进行数据库及其他操作,并且它可以在加载广告之前一直工作。以下是我的依赖关系:
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:cardview-v7:25.2.0'
以下是Log Cat显示的内容:
05-25 02:41:06.158 1562-4610/system_process I/ActivityManager: START u0 {cmp=com.example.johnn.myfirstapp/.FullDetails (has extras)} from uid 10074 on display 0
05-25 02:41:06.164 3956-3984/com.example.johnn.myfirstapp V/FA: Recording user engagement, ms: 4475
05-25 02:41:06.173 3956-3984/com.example.johnn.myfirstapp V/FA: Activity paused, time: 26769028
05-25 02:41:06.176 3956-3956/com.example.johnn.myfirstapp V/FA: onActivityCreated
05-25 02:41:06.187 3956-3984/com.example.johnn.myfirstapp D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=4475, _sc=DetailsActivity, _si=1459254922483070610}]
05-25 02:41:06.213 3956-3956/com.example.johnn.myfirstapp D/DynamitePackage: Instantiated singleton DynamitePackage.
Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
05-25 02:41:06.230 3956-3956/com.example.johnn.myfirstapp W/System: ClassLoader referenced unknown path: /system/app/webview/lib/x86
05-25 02:41:06.230 3956-3956/com.example.johnn.myfirstapp D/ApplicationLoaders: ignored Vulkan layer search path /system/app/webview/lib/x86:/system/app/webview/webview.apk!/lib/x86:/system/lib:/vendor/lib for namespace 0xa7b80110
05-25 02:41:06.231 3956-3956/com.example.johnn.myfirstapp I/WebViewFactory: Loading com.android.webview version 52.0.2743.100 (code 275610010)
05-25 02:41:06.243 3956-3956/com.example.johnn.myfirstapp I/cr_LibraryLoader: Time to load native libraries: 1 ms (timestamps 9107-9108)
Expected native library version number "52.0.2743.100", actual native library version number "52.0.2743.100"
05-25 02:41:06.246 3956-3956/com.example.johnn.myfirstapp V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {d77ee50}
05-25 02:41:06.246 3956-3956/com.example.johnn.myfirstapp I/cr_LibraryLoader: Expected native library version number "52.0.2743.100", actual native library version number "52.0.2743.100"
05-25 02:41:06.246 3956-3956/com.example.johnn.myfirstapp I/chromium: [INFO:library_loader_hooks.cc(143)] Chromium logging enabled: level = 0, default verbosity = 0
05-25 02:41:06.255 3956-3956/com.example.johnn.myfirstapp I/cr_BrowserStartup: Initializing chromium process, singleProcess=true
05-25 02:41:06.275 2550-3996/com.google.android.gms V/FA-SVC: Logging event: origin=auto,name=_e,params=Bundle[mParcelledData.dataSize=136]
05-25 02:41:06.279 2550-3996/com.google.android.gms V/FA-SVC: Saving event, name, data size: _e, 70
Event recorded: Event{appId='com.example.johnn.myfirstapp', name='_e', params=Bundle[{_o=auto, _et=4475, _sc=DetailsActivity, _si=1459254922483070610}]}
05-25 02:41:06.283 2550-3996/com.google.android.gms V/FA-SVC: Upload scheduled in approximately ms: 14881
05-25 02:41:06.286 2550-3996/com.google.android.gms V/FA-SVC: Background event processing time, ms: 11
05-25 02:41:06.359 3956-3956/com.example.johnn.myfirstapp I/cr_DRP: No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
05-25 02:41:16.162 1562-1578/system_process W/ActivityManager: Launch timeout has expired, giving up wake lock!
05-25 02:41:54.927 1562-1578/system_process W/BroadcastQueue: Timeout of broadcast BroadcastRecord{f953a12 u0 android.intent.action.PACKAGE_REMOVED} - receiver=android.os.BinderProxy@62765e3, started 60001ms ago
05-25 02:41:54.928 1562-1578/system_process W/BroadcastQueue: Receiver during timeout: ResolveInfo{63bbe0 com.google.android.googlequicksearchbox/com.google.android.apps.gsa.search.core.icingsync.IcingCorporaChangedReceiver m=0x208000}
05-25 02:41:54.932 1562-1578/system_process I/Process: Sending signal. PID: 3682 SIG: 3
由于“模拟器”中的Google Play服务可能会崩溃吗?
答案 0 :(得分:0)
以下是我在第3个活动 onCreate 方法中获得的内容:
try{
mInterstitial = new InterstitialAd(this);
mInterstitial.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
mInterstitial.loadAd(new AdRequest.Builder().build());
mInterstitial.setAdListener(new AdListener(){
@Override
public void onAdLoaded() { }
@Override
public void onAdFailedToLoad(int errorCode) { }
@Override
public void onAdOpened() { }
@Override
public void onAdLeftApplication() { }
@Override
public void onAdClosed() {
Intent adsIntent = new Intent(FullDetails.this, DetailsActivity.class);
adsIntent.putExtra("ID", categoryId);
startActivity( adsIntent);
}
});
}
catch (Exception ex){
final String tag = "ErrCode:";
Log.v(tag, ex.getMessage());
}
应用崩溃的地方,没有它应用程序顺利。