我想在我的应用程序中添加一些添加.当我启用了StrictMode时,我得到了一堆像这样的策略违规(可能是6或7).这是正常的吗?
18817-18817/com.xyz.xyz.xyz D/StrictMode: StrictMode policy violation; ~duration=67937 ms: androID.os.StrictMode$StrictModediskReadViolation: policy=5439503 violation=2 at androID.os.StrictMode$AndroIDBlockGuardPolicy.onReadFromdisk(StrictMode.java:1263) at libcore.io.BlockGuardOs.fstat(BlockGuardOs.java:132) at java.io.RandomAccessfile.length(RandomAccessfile.java:240) at java.util.zip.Zipfile.readCentralDir(Zipfile.java:386) at java.util.zip.Zipfile.<init>(Zipfile.java:175) at java.util.zip.Zipfile.<init>(Zipfile.java:142) at androID.webkit.WebVIEwFactory.getLoadFromApkPath(WebVIEwFactory.java:357) at androID.webkit.WebVIEwFactory.getWebVIEwNativelibraryPaths(WebVIEwFactory.java:407) at androID.webkit.WebVIEwFactory.loadNativelibrary(WebVIEwFactory.java:511) at androID.webkit.WebVIEwFactory.getProvIDerClass(WebVIEwFactory.java:188) at androID.webkit.WebVIEwFactory.getProvIDer(WebVIEwFactory.java:158) at androID.webkit.WebSettings.getDefaultUserAgent(WebSettings.java:1239) at com.Google.androID.gms.ads.internal.util.ai.a(:com.Google.androID.gms.DynamiteModulesA:414) at com.Google.androID.gms.ads.internal.util.y.a(:com.Google.androID.gms.DynamiteModulesA:419) at com.Google.androID.gms.ads.internal.state.h.a(:com.Google.androID.gms.DynamiteModulesA:349) at com.Google.androID.gms.ads.internal.a.<init>(:com.Google.androID.gms.DynamiteModulesA:153) at com.Google.androID.gms.ads.internal.c.<init>(:com.Google.androID.gms.DynamiteModulesA:104) at com.Google.androID.gms.ads.internal.c.<init>(:com.Google.androID.gms.DynamiteModulesA:92) at com.Google.androID.gms.ads.internal.g.<init>(:com.Google.androID.gms.DynamiteModulesA:55) at com.Google.androID.gms.ads.internal.o.<init>(:com.Google.androID.gms.DynamiteModulesA:89) at com.Google.androID.gms.ads.ChimeraAdManagerCreatorImpl.newAdManagerByType(:com.Google.androID.gms.DynamiteModulesA:66) at com.Google.androID.gms.ads.internal.clIEnt.al.onTransact(:com.Google.androID.gms.DynamiteModulesA:91) at androID.os.Binder.transact(Binder.java:387) at com.Google.androID.gms.ads.internal.clIEnt.am.newAdManagerByType(:com.Google.androID.gms:170) at com.Google.androID.gms.ads.AdManagerCreatorImpl.newAdManagerByType(:com.Google.androID.gms:90) at com.Google.androID.gms.ads.internal.clIEnt.al.onTransact(:com.Google.androID.gms:91) at androID.os.Binder.transact(Binder.java:387) at com.Google.androID.gms.ads.internal.clIEnt.zzv$zza$zza.zza(UnkNown Source) at com.Google.androID.gms.ads.internal.clIEnt.zze.zza(UnkNown Source) at com.Google.androID.gms.ads.internal.clIEnt.zzl.zzim(UnkNown Source) at com.Google.androID.gms.ads.internal.clIEnt.zzl.zzin(UnkNown Source) at com.Google.androID.gms.ads.internal.clIEnt.zzl.zza(UnkNown Source) at com.Google.androID.gms.ads.internal.clIEnt.zzl.zza(UnkNown Source) at com.Google.androID.gms.ads.internal.clIEnt.zzae.zzjn(UnkNown Source) at com.Google.androID.gms.ads.internal.clIEnt.zzae.zzjm(UnkNown Source) at com.Google.androID.gms.ads.internal.clIEnt.zzae.zza(UnkNown Source) at com.Google.androID.gms.ads.BaseAdVIEw.loadAd(UnkNown Source) at com.Google.androID.gms.ads.AdVIEw.loadAd(UnkNown Source) at com.xyz.xyz.xyz.MainActivity.LoadAd(MainActivity.java:539) at com.xyz.xyz.xyz.MainActivity.onCreate(MainActivity.java:323) at androID.app.Activity.performCreate(Activity.java:6237) at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2369) at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at androID.app.ActivityThread.handle@R_697_4404@Activity(ActivityThread.java:4077) at androID.app.ActivityThread.-wrap15(ActivityThread.java) at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1350) at androID.os.Handler.dispatchMessage(Handler.java:102) at androID.os.Looper.loop(Looper.java:148) at androID.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:72
广告的代码是这样的:
private voID LoadAd(){ Log.d(TAG, "LoadAd() called"); mAdVIEw = new AdVIEw(this); //Finds an ad that best fits a user's device. linearLayout adContainer = (linearLayout) findVIEwByID(R.ID.adVIEw_container); mAdVIEw.setAdSize(Utils.getBannerSize(this)); mAdVIEw.setAdUnitID(getString(R.string.banner_ad_unit_ID)); adContainer.addVIEw(mAdVIEw); AdRequest adRequest = new AdRequest.Builder().build(); mAdVIEw.loadAd(adRequest);}
解决方法:
如果通过detectAll()或detectdiskReads()将StrictMode设置为检测diskReads,则当应用程序读取磁盘时会发生StrictMode违规.
我认为diskReads对于正常情况来说不是问题.因此,您可以禁用以下违规行为:
StrictMode.ThreadPolicy threadPolicy = new StrictMode.ThreadPolicy.Builder() . ... .permitdiskReads() .permitdiskWrites() // If you also want to ignore diskWrites, Set this line too. . ... .build();StrictMode.setThreadPolicy(threadPolicy);
总结 以上是内存溢出为你收集整理的android – Adview loadAd()触发StrictMode违规全部内容,希望文章能够帮你解决android – Adview loadAd()触发StrictMode违规所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)