Fragment
中的以下行正在抛出一个我无法找到根本原因的异常。
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_player_pane, container, false);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) rootView.getLayoutParams();
// set width height
params.height = (getArguments().getInt(HEIGHT));
params.width = (getArguments().getInt(WIDTH));
fragmentHeight = (getArguments().getInt(HEIGHT));
fragmentWidth = (getArguments().getInt(WIDTH));
// substitute parameters for left,top, right, bottom, (All 4 not necessary)
params.setMargins((getArguments().getInt(LEFT_MARGIN)),
(getArguments().getInt(TOP_MARGIN)),
(getArguments().getInt(RIGHT_MARGIN)),
(getArguments().getInt(BOTTOM_MARGIN)));
youTubePlayerNecessary = getArguments().getBoolean(REQUIRE_YOUTUBE);
rotate = getArguments().getBoolean(REQUIRE_ROTATION);
muteAudio = getArguments().getBoolean(MUTE_AUDIO);
rootView.setLayoutParams(params);
return rootView;
}
例外:
11-02 11:36:04.966 3440-3452/com.blynq.app.multipaneplayer E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'close' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:184)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:127)
at com.android.webview.chromium.WebViewChromiumFactoryProvider.startChromiumLocked(WebViewChromiumFactoryProvider.java:16107)
at com.android.webview.chromium.WebViewChromiumFactoryProvider.ensureChromiumStartedLocked(WebViewChromiumFactoryProvider.java:333)
at com.android.webview.chromium.WebViewChromiumFactoryProvider.startYourEngines(WebViewChromiumFactoryProvider.java:427)
at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:162)
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 java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at com.blynq.app.fragments.PlayerPane.onCreateView(PlayerPane.java:181)
at android.app.Fragment.performCreateView(Fragment.java:2053)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:894)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.app.BackStackRecord.run(BackStackRecord.java:834)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1454)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:447)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
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:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
我目前正在调试模式下运行app来检查所有可能的内存泄漏。
if (BuildConfig.DEBUG) {
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build());
}
清单文件中的所有标记也已正确关闭。我无法确定哪个资源未经处理就保持打开状态。我该如何解决这个问题?
P.S。在提出问题之前,我已经提到thread,这是一个非常通用的问题,没有为我提供新的必要见解。这个问题对于上面提到的细节非常具体,我在这里寻求帮助,找出导致泄漏的资源..
答案 0 :(得分:2)
有人在此提出了一个问题:https://code.google.com/p/android/issues/detail?id=226751
我一直有同样的问题,看起来它是API中的一个错误&lt; 25.使用API 25在模拟器中试用您的程序,看看它是否有效。如果它在那里工作,那么它很可能是同样的问题,你可以解决这个问题。
答案 1 :(得分:0)
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog()
.penaltyDeath().build());
了解更多信息请关注此网址 Error Solve Url