应用程序在模拟器中运行,但在手机中没有

问题描述 投票:1回答:1

我是新的android工作室程序员,当我在模拟器中尝试它的工作没有任何问题,但在我的手机或其他手机它不,显示不幸的MyApp已经停止然后出去?

我读了很多她的答案,所以我会为你提供logcat报告

03-02 16:34:06.788 1610-1623/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.mrwan.pharma/.MainActivity bnds=[32,319][307,755] (has extras)} from uid 10014 on display 0
03-02 16:34:06.861 1610-2651/? I/ActivityManager: Start proc 3848:com.example.mrwan.pharma/u0a71 for activity com.example.mrwan.pharma/.MainActivity
03-02 16:34:07.535 1610-1635/? I/Choreographer: Skipped 36 frames!  The application may be doing too much work on its main thread.
03-02 16:34:07.625 3848-3848/? I/InstantRun: starting instant run server: is main process
03-02 16:34:09.655 1610-1635/? I/ActivityManager: Displayed com.example.mrwan.pharma/.MainActivity: +2s824ms
03-02 16:34:09.655 3848-3848/? I/Choreographer: Skipped 32 frames!  The application may be doing too much work on its main thread.
03-02 16:34:11.190 1610-1733/? I/ActivityManager: START u0 {cmp=com.example.mrwan.pharma/.Main2Activity} from uid 10071 on display 0
03-02 16:34:12.371 3848-3848/? I/Choreographer: Skipped 66 frames!  The application may be doing too much work on its main thread.
03-02 16:34:13.363 3848-3848/? I/Choreographer: Skipped 40 frames!  The application may be doing too much work on its main thread.
03-02 16:34:13.624 1610-1635/? I/ActivityManager: Displayed com.example.mrwan.pharma/.Main2Activity: +2s383ms
03-02 16:34:14.014 3848-3848/? I/Choreographer: Skipped 38 frames!  The application may be doing too much work on its main thread.
03-02 16:34:16.560 1610-1624/? I/ActivityManager: START u0 {cmp=com.example.mrwan.pharma/.Main3Activity} from uid 10071 on display 0
03-02 16:34:17.190 3848-3848/? W/art: Verification of java.lang.Object com.example.mrwan.pharma.Main3Activity.access$super(com.example.mrwan.pharma.Main3Activity, java.lang.String, java.lang.Object[]) took 151.542ms
03-02 16:34:18.546 3848-3848/? I/Choreographer: Skipped 106 frames!  The application may be doing too much work on its main thread.
03-02 16:34:19.566 1610-1635/? I/ActivityManager: Displayed com.example.mrwan.pharma/.Main3Activity: +2s965ms

顺便提一下,如果我的项目在一个Activity中有很多代码,那么它会产生影响

在我的项目中这样

package com.example.mrwan.superway;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class Main2Activity extends AppCompatActivity {

    ImageView imageView2;
    Button    button2;
    Button    button3;
    Button    button4;
    Button    button5;
    Button    button6;
    Intent    i;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        imageView2 = (ImageView)findViewById(R.id.imageView2);
        button2 = (Button)findViewById(R.id.button2);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(Main2Activity.this,Main3Activity.class);
                startActivity(i);
            }
        });
        button3 = (Button)findViewById(R.id.button3);
        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(Main2Activity.this,Main4Activity.class);
                startActivity(i);
            }
        });
        button4 = (Button)findViewById(R.id.button4);
        button4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(Main2Activity.this,Main5Activity.class);
                startActivity(i);
            }
        });
        button5 = (Button)findViewById(R.id.button5);
        button5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(Main2Activity.this,Main6Activity.class);
                startActivity(i);
            }
        });
        button6 = (Button)findViewById(R.id.button6);
        button6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(Main2Activity.this,Main7Activity.class);
                startActivity(i);
            }
        });


    }
}

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.mrwan.superway.Main2Activity"
    android:background="@color/HeadBcakGrOuNd"
    >

    <RelativeLayout
        android:layout_width="368dp"
        android:layout_height="495dp"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="8dp">

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginBottom="322dp"
            app:srcCompat="@drawable/mt3am1" android:contentDescription="TODO"/>

        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="186dp"
            android:text="تعرف على مطعم SUPWAY" />

        <Button
            android:id="@+id/button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/button2"
            android:layout_alignStart="@+id/button2"
            android:layout_below="@+id/button2"
            android:layout_marginTop="14dp"
            android:text="وجبات الأفطار التي يقدمها supway" />

        <Button
            android:id="@+id/button4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/button3"
            android:layout_alignStart="@+id/button3"
            android:layout_below="@+id/button3"
            android:layout_marginTop="15dp"
            android:text="وجبات الغداء التي يقدمها supway" />

        <Button
            android:id="@+id/button5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/button4"
            android:layout_alignStart="@+id/button4"
            android:layout_below="@+id/button4"
            android:layout_marginTop="17dp"
            android:text="وجبات العشاء التي يقدمها supway" />

        <Button
            android:id="@+id/button6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginBottom="11dp"
            android:text="خدمة التوصيل المنزلي DELVIERY" />
    </RelativeLayout>
</android.support.constraint.ConstraintLayout>
android logcat
1个回答
0
投票

确保您的手机处于开发者模式。

© www.soinside.com 2019 - 2024. All rights reserved.