某些手机​​无法启动Android应用

时间:2018-01-25 07:36:03

标签: java android android-layout android-studio tic-tac-toe

我做了一个基本的TicTacToe游戏。它完美适用于Nexus 5X 1920x1080(仿真器),Pixel XL 1440x2560(仿真器),小米Mi5 1920x1080(我的手机),但应用程序无法打开三星S7 edge 1440x2560(我的手机),魅族MX4(1152x1920)。我尝试了一切。 Android Studio不会显示任何错误。

此外,我尝试使用Appetize.io模拟器进行测试,它也在那里工作。请帮帮我,我找不到问题。

**Log**

    01-25 07:46:04.892 29294-29294/? I/zygote: Not late-enabling -Xcheck:jni (already on)
01-25 07:46:04.920 29294-29294/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
01-25 07:46:05.388 29294-29294/com.sosisvesalam.kefelon.sossvesalam I/InstantRun: starting instant run server: is main process
01-25 07:46:05.773 29294-29314/com.sosisvesalam.kefelon.sossvesalam D/OpenGLRenderer: HWUI GL Pipeline
01-25 07:46:05.818 29294-29294/com.sosisvesalam.kefelon.sossvesalam D/android.widget.GridLayout: vertical constraints: y3-y0>=1047, y3-y2<=358, y2-y1<=358, y1-y0<=318 are inconsistent; permanently removing: y3-y2<=358. 

                                                                                                 [ 01-25 07:46:05.831 29294:29314 D/         ]
                                                                                                 HostConnection::get() New Host Connection established 0xa7ee4a00, tid 29314
01-25 07:46:05.832 29294-29314/com.sosisvesalam.kefelon.sossvesalam I/OpenGLRenderer: Initialized EGL, version 1.4
01-25 07:46:05.832 29294-29314/com.sosisvesalam.kefelon.sossvesalam D/OpenGLRenderer: Swap behavior 1
01-25 07:46:05.832 29294-29314/com.sosisvesalam.kefelon.sossvesalam W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
01-25 07:46:05.832 29294-29314/com.sosisvesalam.kefelon.sossvesalam D/OpenGLRenderer: Swap behavior 0
01-25 07:46:05.835 29294-29314/com.sosisvesalam.kefelon.sossvesalam D/EGL_emulation: eglCreateContext: 0xa7f050c0: maj 2 min 0 rcv 2
01-25 07:46:05.870 29294-29314/com.sosisvesalam.kefelon.sossvesalam D/EGL_emulation: eglMakeCurrent: 0xa7f050c0: ver 2 0 (tinfo 0xa7f030d0)
01-25 07:46:05.970 29294-29314/com.sosisvesalam.kefelon.sossvesalam D/EGL_emulation: eglMakeCurrent: 0xa7f050c0: ver 2 0 (tinfo 0xa7f030d0)


 **activity_main.xml and AndroidManifest.xml**

    <?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.sosisvesalam.kefelon.sossvesalam.MainActivity">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:contentDescription="@string/todo"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/board" />

    <GridLayout
        android:id="@+id/gridLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_margin="8dp"
        android:layout_marginTop="8dp"
        android:columnCount="3"
        android:rowCount="3"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/imageView"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.495">

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_margin="1dp"
            android:layout_marginLeft="13dp"
            android:layout_marginStart="13dp"
            android:layout_marginTop="10dp"
            android:contentDescription="@string/todo"
            android:onClick="onClick"
            android:padding="1dp"
            android:scaleType="fitStart"
            android:tag="1"
            />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_margin="1dp"
            android:layout_marginLeft="17dp"
            android:layout_marginStart="17dp"
            android:layout_marginTop="10dp"
            android:contentDescription="@string/todo"
            android:onClick="onClick"
            android:padding="1dp"
            android:scaleType="fitStart"
            android:tag="2"
            />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_margin="1dp"
            android:layout_marginLeft="13dp"
            android:layout_marginStart="13dp"
            android:layout_marginTop="10dp"
            android:contentDescription="@string/todo"
            android:onClick="onClick"
            android:padding="1dp"
            android:scaleType="fitStart"
            android:tag="3"
          />

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_margin="1dp"
            android:layout_marginLeft="13dp"
            android:layout_marginStart="13dp"
            android:layout_marginTop="25dp"
            android:contentDescription="@string/todo"
            android:onClick="onClick"
            android:padding="1dp"
            android:scaleType="fitStart"
            android:tag="4"
            />

        <ImageView
            android:id="@+id/imageView5"
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_margin="1dp"
            android:layout_marginLeft="17dp"
            android:layout_marginStart="17dp"
            android:layout_marginTop="25dp"
            android:contentDescription="@string/todo"
            android:onClick="onClick"
            android:padding="1dp"
            android:scaleType="fitStart"
            android:tag="5" />

        <ImageView
            android:id="@+id/imageView6"
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_margin="1dp"
            android:layout_marginLeft="13dp"
            android:layout_marginStart="13dp"
            android:layout_marginTop="25dp"
            android:contentDescription="@string/todo"
            android:onClick="onClick"
            android:padding="1dp"
            android:scaleType="fitStart"
            android:tag="6"
            />

        <ImageView
            android:id="@+id/imageView7"
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_margin="1dp"
            android:layout_marginLeft="10dp"
            android:layout_marginStart="10dp"
            android:layout_marginTop="25dp"
            android:contentDescription="@string/todo"
            android:onClick="onClick"
            android:padding="1dp"
            android:scaleType="fitStart"
            android:tag="7"
           />

        <ImageView
            android:id="@+id/imageView8"
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_margin="1dp"
            android:layout_marginLeft="17dp"
            android:layout_marginStart="17dp"
            android:layout_marginTop="25dp"
            android:contentDescription="@string/todo"
            android:onClick="onClick"
            android:padding="1dp"
            android:scaleType="fitStart"
            android:tag="8"
            />

        <ImageView
            android:id="@+id/imageView9"
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_margin="1dp"
            android:layout_marginLeft="13dp"
            android:layout_marginStart="13dp"
            android:layout_marginTop="25dp"
            android:contentDescription="@string/todo"
            android:onClick="onClick"
            android:padding="1dp"
            android:scaleType="fitStart"
            android:tag="9"
       />


    </GridLayout>

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"
        android:textColor="@android:color/holo_red_light"
        android:textStyle="bold"
        app:layout_constraintBottom_toTopOf="@+id/gridLayout"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/imageView" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:onClick="yenidenoyna"
        android:text="@string/sifirla"
        android:visibility="visible"
        app:layout_constraintBottom_toBottomOf="@+id/imageView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/gridLayout" />

</android.support.constraint.ConstraintLayout>


    **AndroidManifest.xml**

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sosisvesalam.kefelon.sossvesalam">
    <supports-screens
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

1 个答案:

答案 0 :(得分:1)

这是pastebin的错误...

    01 - 25 11: 37: 40.620 29867 - 29867 / ? E / AndroidRuntime : FATAL EXCEPTION: main
    Process: com.sosisvesalam.kefelon.sossvesalam, PID: 29867
    java.lang.RuntimeException: Unable to start activity ComponentInfo {
        com.sosisvesalam.kefelon.sossvesalam / com.sosisvesalam.kefelon.sossvesalam.MainActivity
    }: android.view.InflateException: Binary XML file line #0: Error inflating class android.widget.GridLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2335)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2397)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1310)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5268)
at at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
Caused by: android.view.InflateException: Binary XML file line # 0: Error inflating class android.widget.GridLayout
    at android.view.LayoutInflater.createView(LayoutInflater.java: 633)
...
"com.sosisvesalam.kefelon.sossvesalam:drawable/board" (7f060053)  is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060053 a=-1 r=0x7f060053}

因此错误是由board图像引起的。 首先尝试删除以下行app:srcCompat="@drawable/board"

更新2: 当您添加图像时,您的应用程序失败,检查图像大小,如果它们太大,请尝试调整它们的大小,只是为了使它们更轻和/或更小的分辨率。