Android 安卓:应用启动卡在黑屏上

Android 安卓:应用启动卡在黑屏上,android,startup,Android,Startup,我正在为Android开发一个应用程序。 该应用程序使用Google Play服务,需要一些许可 launcher活动非常简单,只需设置内容视图。 我正在各种设备上测试它,结果如下: HOMTOM HT3 PRO,安卓5.1快速显示第一个活动 华为P8 Lite、Android 6.0有时会在启动前显示5-10秒的黑屏 Galaxy A3,Android 6.1它被卡在了黑屏上 Nexus 5卡在黑屏上 下面是一些来自星系A3的日志: 12-01 15:38:02.911 16359-16359

我正在为Android开发一个应用程序。 该应用程序使用Google Play服务,需要一些许可

launcher活动非常简单,只需设置内容视图。 我正在各种设备上测试它,结果如下:

HOMTOM HT3 PRO,安卓5.1快速显示第一个活动

华为P8 Lite、Android 6.0有时会在启动前显示5-10秒的黑屏

Galaxy A3,Android 6.1它被卡在了黑屏上

Nexus 5卡在黑屏上

下面是一些来自星系A3的日志:

12-01 15:38:02.911 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:02.931 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59261438
12-01 15:38:03.291 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:03.331 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:03.331 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{ab1c097 I.ED..... R.....I. 0,0-0,0}
12-01 15:38:03.381 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59261887
12-01 15:38:03.731 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:03.761 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59262266
12-01 15:38:04.121 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:04.171 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:04.171 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{4f91b9e I.ED..... R.....I. 0,0-0,0}
12-01 15:38:04.221 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59262722
12-01 15:38:04.581 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:04.601 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59263105
12-01 15:38:04.961 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:05.001 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:05.001 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{1cf681 I.ED..... R.....I. 0,0-0,0}
12-01 15:38:05.051 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59263551
12-01 15:38:05.391 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:05.421 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59263921
12-01 15:38:05.761 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:05.811 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:05.811 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{7010fb0 I.ED..... R.....I. 0,0-0,0}
12-01 15:38:05.851 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59264352
12-01 15:38:06.181 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:06.211 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59264717
12-01 15:38:06.601 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:06.651 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:06.651 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{830db5b I.ED..... R.....I. 0,0-0,0}
12-01 15:38:06.691 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59265199
12-01 15:38:07.031 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:07.061 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59265564
12-01 15:38:07.431 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:07.491 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:07.491 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{7184a72 I.ED..... R.....I. 0,0-0,0}
12-01 15:38:07.531 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59266036
我的开始活动

public class StartActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        //more code
    }

}
但在调试过程中,我清楚地看到等待时间是在onCreate调用之前。这可能取决于应用程序由大量文件组成吗?我有73个java类+100个可绘制类

仅供参考,这是我的gradle文件

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.1'

    defaultConfig {
        applicationId "com.package.appname"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        manifestPlaceholders = [onesignal_app_id: "****",
                                onesignal_google_project_number: "*****"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:cardview-v7:24.2.0'
    compile 'com.android.support:recyclerview-v7:24.2.0'
    compile 'com.android.support:percent:24.2.0'
    compile 'com.bignerdranch.android:recyclerview-multiselect:+'
    compile 'com.google.android.gms:play-services-maps:9.6.0'
    compile 'com.google.android.gms:play-services-location:9.6.0'
    compile 'com.google.android.gms:play-services-auth:9.6.0'
    compile 'com.google.android.gms:play-services-gcm:9.6.0'
    compile 'com.google.firebase:firebase-messaging:9.6.0'
    compile 'com.google.firebase:firebase-database:9.6.0'
    compile 'com.google.firebase:firebase-storage:9.6.0'
    compile 'com.google.firebase:firebase-auth:9.6.0'
    compile 'com.google.firebase:firebase-crash:9.6.0'
    compile 'com.firebaseui:firebase-ui:0.6.0'
    compile 'com.firebaseui:firebase-ui-database:0.6.0'
    compile 'com.firebaseui:firebase-ui-auth:0.6.0'
    compile 'com.firebaseui:firebase-ui-storage:0.6.0'
    compile 'com.firebase:geofire-android:2.1.0'
    compile 'com.jakewharton:butterknife:8.2.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.github.machinarius:preferencefragment:0.1.1'
    compile 'commons-io:commons-io:2.4'
    compile 'com.soundcloud.android:android-crop:1.0.1@aar'
    compile 'br.com.instachat:emoji-library:1.0.8'
    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    compile 'org.apmem.tools:layouts:1.10@aar'
    compile 'com.github.chrisbanes:PhotoView:1.3.1'
    compile 'com.dinuscxj:circleprogressbar:1.1.1'
    testCompile 'junit:junit:4.12'
    apt 'com.jakewharton:butterknife-compiler:8.2.1'
}

apply plugin: 'com.google.gms.google-services'
和我的开始布局

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    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:background="#ffffff"
    android:gravity="center_vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:id="@+id/start_logo"
        >

        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="0.2"
            ></View>

        <ImageView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.6"
            android:adjustViewBounds="true"
            app:srcCompat="@drawable/logo"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="30dp"
            />

        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="0.2"
            ></View>

    </LinearLayout>

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        android:layout_below="@+id/start_logo"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:id="@+id/start_progress"/>

    <TextView
        android:text="Loading..."
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/start_progress"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:id="@+id/start_processing"
        android:textColor="#000000"/>


</RelativeLayout>


您使用什么API来开发您的简单应用程序?你说的“简单应用”是什么意思?你能给我们一个代码片段吗,也许是来自你的Java代码,也许是你的布局文件?你说你需要使用你的应用程序的权限,这些权限是被授予的吗?旧款手机有时不会显示弹出窗口,要求用户提供其所需的权限。你可以在手机应用程序的设置中启用它们。我说了“简单启动活动”,我把它附在了我的帖子上。我现在将尝试检查权限并让您知道。为什么m3View为空?您能否显示布局以及m3View的启动位置?m3View它不是“我的视图”。我认为这是与系统有关的。顺便说一句,我正在不同的设备上做更多的测试,我会尽快让你知道。很抱歉,onCreate方法上还有一些代码表现不好。开始时仍有一些加载时间,但可以通过在主题xml中设置
true
来平滑加载时间。