简体   繁体   English

Android清单中的微小变化会导致应用崩溃

[英]Small change in android manifests is causing app to crash

Very simple, I was changing my android manifest to remove the title bar. 很简单,我正在更改我的android清单以删除标题栏。 In the styles.xml file I changed the app style parent and in the android manifests I changed android:theme accordingly. 在styles.xml文件中,我更改了应用程序样式的父项,并在android清单中更改了android:theme。 Now however when I test on my android it just goes to white screen. 现在,但是当我在Android上进行测试时,它只会进入白屏。

My styles.xml: 我的styles.xml:

<resources>

<!-- Base application theme. -->
<style name="AppTheme"
    parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

My android_manifests: 我的android_manifests:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ali.colormatch2">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen">
    <activity android:name=".MainActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".ColorMatch2"
        android:screenOrientation="portrait">
    </activity>
    <activity android:name=".LoseScreen"
        android:screenOrientation="portrait">
    </activity>
</application>

</manifest>

My MainActivity.java, it's probably irrelevant but just in case it's the culprit: 我的MainActivity.java,可能无关紧要,但以防万一,这是罪魁祸首:

package com.example.ali.colormatch2;

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


public class MainActivity extends AppCompatActivity {

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

public void onSplashPageClick(View view){
    Intent intent = new Intent(MainActivity.this, ColorMatch2.class);
    startActivity(intent);
}

public void onQuitClick(View view){
    finish();
}
}

Corresponding activity_main.xml: 对应的activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#005825"
tools:context="com.example.ali.colormatch2.MainActivity"
android:onClick="onSplashPageClick"

android:baselineAligned="false">

<!--<Button
    android:text="Button"
    android:layout_width="159dp"
    android:layout_height="100dp"
    android:id="@+id/button5"
    android:onClick="sendMessage" />
    -->


<Button
    android:layout_width="35dp"
    android:layout_height="35dp"
    android:id="@+id/button"
    android:background="@android:drawable/btn_dialog"
    android:onClick="onQuitClick"
    android:layout_marginTop="16dp"
    android:layout_marginLeft="24dp"
    android:layout_marginStart="24dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<TextView
    android:text="Click anywhere to play"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textView5"
    android:textSize="30dp"
    android:textColor="#000000"
    android:layout_marginBottom="171dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fontFamily="sans-serif-thin"
    android:text="Color Match"
    android:gravity="center"
    android:textColor="#440027"
    android:textSize="75dp"
    android:id="@+id/textView"
    android:layout_marginBottom="12dp"
    android:layout_above="@+id/textView5"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />


</RelativeLayout>

Also it should be noted I also tried android:theme="@android:style/Theme.Light.NoTitleBar"> in android manifests but this also did not seem to work. 另外应该注意,我也在android清单中尝试了android:theme =“ @ android:style / Theme.Light.NoTitleBar”>,但这似乎也没有用。 Thank you 谢谢

EDIT---- 编辑 - -

Logcat output: Logcat输出:

3:21:37 PM Gradle sync started
3:22:01 PM Gradle sync completed
3:22:02 PM Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]
3:22:06 PM Gradle build finished in 5s 131ms
3:26:53 PM Executing tasks: [:app:assembleDebug]
3:26:58 PM Gradle build finished in 5s 281ms
3:37:53 PM Executing tasks: [:app:assembleDebug]
3:37:55 PM Gradle build finished in 2s 165ms
3:38:02 PM Performing full build and install:
       On devices with API level below 21, a full build is required if the app is not running.
       (Dont show again)
3:40:37 PM Executing tasks: [:app:assembleDebug]
3:40:40 PM Gradle build finished in 2s 187ms
3:40:47 PM Performing full build and install:
       On devices with API level below 21, a full build is required if the app is not running.
       (Dont show again)
11:15:21 PM Executing tasks: [:app:assembleDebug]
11:15:46 PM Gradle build finished in 24s 689ms
11:18:22 PM Executing tasks: [:app:assembleDebug]
11:18:27 PM Gradle build finished in 5s 487ms
11:18:34 PM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
11:19:52 PM Executing tasks: [:app:assembleDebug]
11:19:53 PM Gradle build finished in 1s 893ms
11:20:00 PM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
11:48:01 PM Executing tasks: [:app:assembleDebug]
11:48:05 PM Gradle build finished in 4s 209ms
11:48:13 PM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
11:48:52 PM Executing tasks: [:app:assembleDebug]
11:48:53 PM Gradle build finished in 1s 96ms
11:48:55 PM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
11:49:56 PM Executing tasks: [:app:assembleDebug]
11:49:58 PM Gradle build finished in 1s 735ms
11:50:05 PM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
11:52:14 PM Executing tasks: [:app:assembleDebug]
11:52:17 PM Gradle build finished in 3s 8ms
11:52:24 PM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
11:57:56 PM Executing tasks: [:app:assembleDebug]
11:58:02 PM Gradle build finished in 5s 654ms
11:58:08 PM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
11:59:12 PM Executing tasks: [:app:assembleDebug]
11:59:14 PM Gradle build finished in 1s 664ms
11:59:21 PM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
12:01:51 AM Executing tasks: [:app:assembleDebug]
12:01:53 AM Gradle build finished in 1s 917ms
12:01:59 AM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
12:13:12 AM Executing tasks: [:app:assembleDebug]
12:13:17 AM Gradle build finished in 5s 159ms
12:13:25 AM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
12:22:27 AM Executing tasks: [:app:assembleDebug]
12:22:32 AM Gradle build finished in 4s 708ms
12:22:39 AM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
12:23:38 AM Executing tasks: [:app:assembleDebug]
12:23:41 AM Gradle build finished in 2s 643ms
12:23:49 AM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
12:24:02 AM Executing tasks: [:app:assembleDebug]
12:24:05 AM Gradle build finished in 2s 215ms
12:24:23 AM Performing full build and install:
        On devices with API level below 21, a full build is required if the app is not running.
        (Dont show again)
12:24:23 AM Can't bind to local 8600 for debugger

将此android:theme="@android:style/Theme.Light.NoTitleBar.Fullscr‌​een"android:theme="@style/AppTheme"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM