Android应用程序崩溃应用程序开始在marshmallow和较低版本上调用一堆GC调用

时间:2018-04-20 03:45:26

标签: android

我已经在这个应用程序工作了一段时间,一些模块已经完成,我将最低SDK版本分配给16,目标是27,应用程序工作正常然后突然例如登录活动在它工作之前我现在有了只要应用程序启动了一堆GC调用并且应用程序崩溃,我的所有Activity都会出现此问题。该应用正在使用API​​ Level 24

04-20 11:33:26.307 20181-20181 I/art: Late-enabling -Xcheck:jni
04-20 11:33:26.662 20181-20181 I/art: Starting a blocking GC Explicit
04-20 11:33:26.688 20181-20181 I/art: Explicit concurrent mark sweep GC freed 
16658(848KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 7MB/12MB, paused 
249us total 25.863ms
04-20 11:33:26.812 20181-20238 E/StudioProfiler: Studio Profilers encountered 
an unexpected error. Consider reporting a bug, including logcat output below.
See also: https://developer.android.com/studio/report-bugs.html#studio-bugs

Failed to capture application

04-20 11:33:26.821 20181-20181 V/Monotype: SetAppTypeFace- try to flip, app = com.wog.himolly
04-20 11:33:26.823 20181-20238 V/StudioProfiler: Acquiring Application for Events
04-20 11:33:26.981 20181-20181 V/Monotype:     Typeface getFontPathFlipFont - systemFont = default#default
04-20 11:33:27.036 20181-20181 W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
04-20 11:33:27.050 20181-20181 V/Monotype: SetAppTypeFace- try to flip, app = com.wog.himolly
        Typeface getFontPathFlipFont - systemFont = default#default
04-20 11:33:27.250 20181-20263 D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
04-20 11:33:27.307 20181-20263 I/Adreno: QUALCOMM build                   : d842ad3, Ia10634f51b
    Build Date                       : 01/04/16
    OpenGL ES Shader Compiler Version: XE031.06.00.05
    Local Branch                     : mybranch17585849
    Remote Branch                    : quic/LA.BR.1.2.6_rb1.7
    Remote Branch                    : NONE
    Reconstruct Branch               : NOTHING
04-20 11:33:27.313 20181-20263 I/OpenGLRenderer: Initialized EGL, version 1.4
04-20 11:33:34.271 20181-20181 V/BoostFramework: mAcquireFunc method = public int com.qualcomm.qti.Performance.perfLockAcquire(int,int[])
    mReleaseFunc method = public int com.qualcomm.qti.Performance.perfLockRelease()
    mAcquireTouchFunc method = public int com.qualcomm.qti.Performance.perfLockAcquireTouch(android.view.MotionEvent,android.util.DisplayMetrics,int,int[])
    mIOPStart method = public int com.qualcomm.qti.Performance.perfIOPrefetchStart(int,java.lang.String)
    mIOPStop method = public int com.qualcomm.qti.Performance.perfIOPrefetchStop()
04-20 11:33:34.275 20181-20181 V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@bec09cc
04-20 11:33:34.700 20181-20181 D/AndroidRuntime: Shutting down VM
04-20 11:33:35.618 20181-20191 I/art: Background sticky concurrent mark sweep GC freed 134838(21MB) AllocSpace objects, 14(12MB) LOS objects, 0% free, 86MB/86MB, paused 904us total 800.604ms
04-20 11:33:35.798 20181-20191 I/art: Background partial concurrent mark sweep GC freed 95778(15MB) AllocSpace objects, 3(9MB) LOS objects, 14% free, 91MB/107MB, paused 526us total 179.163ms
04-20 11:33:36.114 20181-20181 I/art: Waiting for a blocking GC Alloc
04-20 11:33:36.155 20181-20191 I/art: Background partial concurrent mark sweep GC freed 102419(16MB) AllocSpace objects, 2(24MB) LOS objects, 15% free, 87MB/103MB, paused 460us total 188.308ms
04-20 11:33:36.155 20181-20181 I/art: WaitForGcToComplete blocked for 40.609ms for cause Alloc
    Starting a blocking GC Alloc
04-20 11:33:36.279 20181-20181 I/art: Waiting for a blocking GC Alloc
04-20 11:33:36.287 20181-20181 I/art: WaitForGcToComplete blocked for 7.760ms for cause Alloc
    Starting a blocking GC Alloc
04-20 11:33:36.364 20181-20181 I/art: Waiting for a blocking GC Alloc
04-20 11:33:36.371 20181-20193 I/art: Waiting for a blocking GC Alloc
04-20 11:33:36.442 20181-20240 I/art: Waiting for a blocking GC Alloc
04-20 11:33:36.472 20181-20191 I/art: Background partial concurrent mark sweep GC freed 49567(7MB) AllocSpace objects, 1(21MB) LOS objects, 14% free, 98MB/114MB, paused 461us total 184.882ms
04-20 11:33:36.472 20181-20181 I/art: WaitForGcToComplete blocked for 108.267ms for cause Alloc
    Starting a blocking GC Alloc
04-20 11:33:36.472 20181-20193 I/art: WaitForGcToComplete blocked for 101.522ms for cause Alloc
    Starting a blocking GC Alloc
04-20 11:33:36.472 20181-20240 I/art: WaitForGcToComplete blocked for 30.769ms for cause Alloc
    Starting a blocking GC Alloc
04-20 11:33:36.765 20181-20181 I/art: Starting a blocking GC Alloc
    Starting a blocking GC Alloc
04-20 11:33:36.785 20181-20181 I/art: Alloc sticky concurrent mark sweep GC freed 77130(12MB) AllocSpace objects, 0(0B) LOS objects, 14% free, 98MB/114MB, paused 443us total 19.318ms
    Starting a blocking GC Alloc
04-20 11:33:36.934 20181-20181 I/art: Alloc partial concurrent mark sweep GC freed 29(1744B) AllocSpace objects, 0(0B) LOS objects, 14% free, 98MB/114MB, paused 437us total 149.163ms
    Starting a blocking GC Alloc
04-20 11:33:37.091 20181-20181 I/art: Alloc concurrent mark sweep GC freed 15(416B) AllocSpace objects, 0(0B) LOS objects, 14% free, 98MB/114MB, paused 454us total 156.496ms
    Forcing collection of SoftReferences for 49MB allocation
    Starting a blocking GC Alloc
04-20 11:33:37.245 20181-20181 I/art: Alloc concurrent mark sweep GC freed 8(240B) AllocSpace objects, 0(0B) LOS objects, 14% free, 98MB/114MB, paused 448us total 153.720ms
04-20 11:33:37.245 20181-20181 W/art: Throwing OutOfMemoryError "Failed to allocate a 51394504 byte allocation with 16776144 free bytes and 29MB until OOM"
04-20 11:33:37.245 20181-20181 I/art: Starting a blocking GC Alloc
    Starting a blocking GC Alloc
04-20 11:33:37.250 20181-20181 I/art: Alloc sticky concurrent mark sweep GC freed 3(544B) AllocSpace objects, 0(0B) LOS objects, 14% free, 98MB/114MB, paused 431us total 5.082ms
    Starting a blocking GC Alloc
04-20 11:33:37.399 20181-20181 I/art: Alloc partial concurrent mark sweep GC freed 15(448B) AllocSpace objects, 0(0B) LOS objects, 14% free, 98MB/114MB, paused 434us total 148.573ms
    Starting a blocking GC Alloc
04-20 11:33:37.553 20181-20181 I/art: Alloc concurrent mark sweep GC freed 8(240B) AllocSpace objects, 0(0B) LOS objects, 14% free, 98MB/114MB, paused 448us total 153.768ms
    Forcing collection of SoftReferences for 49MB allocation
    Starting a blocking GC Alloc
04-20 11:33:37.710 20181-20181 I/art: Alloc concurrent mark sweep GC freed 12(352B) AllocSpace objects, 0(0B) LOS objects, 14% free, 98MB/114MB, paused 530us total 156.376ms
    Starting a blocking GC HomogeneousSpaceCompact
04-20 11:33:38.113 20181-20181 I/art: HomogeneousSpaceCompact marksweep + semispace GC freed 5(160B) AllocSpace objects, 0(0B) LOS objects, 14% free, 98MB/114MB, paused 403.065ms total 403.065ms
04-20 11:33:38.113 20181-20181 W/art: Throwing OutOfMemoryError "Failed to allocate a 51394504 byte allocation with 16769200 free bytes and 29MB until OOM"
04-20 11:33:38.114 20181-20181 E/AndroidRuntime: Error reporting crash
    java.lang.OutOfMemoryError: Failed to allocate a 51394504 byte allocation with 16769200 free bytes and 29MB until OOM
        at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
        at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:125)
        at java.lang.StringBuffer.append(StringBuffer.java:278)
        at java.io.StringWriter.write(StringWriter.java:123)
        at com.android.internal.util.FastPrintWriter.flushLocked(FastPrintWriter.java:358)
        at com.android.internal.util.FastPrintWriter.appendLocked(FastPrintWriter.java:303)
        at com.android.internal.util.FastPrintWriter.write(FastPrintWriter.java:625)
        at com.android.internal.util.FastPrintWriter.append(FastPrintWriter.java:658)
        at java.io.PrintWriter.append(PrintWriter.java:691)
        at java.io.PrintWriter.append(PrintWriter.java:31)
        at java.lang.Throwable.printStackTrace(Throwable.java:324)
        at java.lang.Throwable.printStackTrace(Throwable.java:300)
        at android.util.Log.getStackTraceString(Log.java:343)
        at com.android.internal.os.RuntimeInit.Clog_e(RuntimeInit.java:60)
        at com.android.internal.os.RuntimeInit.access$200(RuntimeInit.java:44)
        at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:86)
        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
04-20 11:33:38.114 20181-20181 I/Process: Sending signal. PID: 20181 SIG: 9

LoginActvity.class

    public class LoginActivity extends BaseClass {
    private static final String TAG = "LoginActivity";
    @BindView(R.id.txt_email)
    EditText txtEmail;
    @BindView(R.id.txt_password)
    EditText txtPassword;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this)
    }

    @OnClick(R.id.btn_submit)
    public void submit(View view) {
        hideKeyboard();


        if (validation){

        }else{
            Map map = new HashMap();
            map.put(APIKey.ACTION, APIAction.LOGIN);
            map.put("email", txtEmail.getText().toString());
            map.put("password", txtPassword.getText().toString());
            sendRequest(map, 1);
        }
    }

    @Override
    public void onAPIResponse(JSONObject data, Map map, int responseId) {
        super.onAPIResponse(data, map, responseId);
        // parse server response
    }
}

BaseClass的

public abstract class BaseClass extends AppCompatActivity implements APIResponse {

    private static final String TAG = "ActivityBaseClass";
    private CoordinatorLayout layoutRoot;
    private SwipeRefreshLayout layoutSwipe;
    private Snackbar snackbar;

    public void hideKeyboard() {
        //.....
    }

    public void sendRequest(Map map, int requestId) {
        new APIRequest(map, requestId).execute();
    }

    @Override
    public void onRequestBegin() {
    }

    @Override
    public void onAPIResponse(JSONObject data, Map map, int responseId) {
        if (snackbar != null)
            snackbar.dismiss();
    }

    public void onRequestBegin(int requestId) {
        onRequestBegin();
    }

    public void errorNotification(String message) {
       //......
    }

    private class APIRequest extends AsyncTask<String, String, String> {

        private RequestBody requestBody;
        private Request request;

        private Map map;
        private int requestId;
        private OkHttpClient okHttpClient = new OkHttpClient();

        private APIRequest(Map map) {
            this.map = map;
            requestId = 0;
        }

        private APIRequest(Map map, int requestId) {
            this.map = map;
            this.requestId = requestId;
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();

            requestBody = RequestBody.create(Constants.JSON, new JSONObject(map).toString());

            request = new Request.Builder().url(Config.BASE_URL).post(requestBody).build();

            if (requestId == 0)
                onRequestBegin();
            else
                onRequestBegin(requestId);
        }

        @Override
        protected String doInBackground(String... strings) {
            try {
                Response response = okHttpClient.newCall(request).execute();
                return response.body().string();
            } catch (IOException e)     {
                e.printStackTrace();
                return null;
            }
        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            if (result != null) {
                JSONObject jsonObject = null;
                try {
                    jsonObject = new JSONObject(result);
                } catch (JSONException e) {
                    e.printStackTrace();
                } finally {
                    if (jsonObject != null)
                        onAPIResponse(jsonObject, map, requestId);
                }
            } else
                onRequestFail("Can't connect right now", map, requestId);
        }
    }
}

0 个答案:

没有答案