I'm developing an application for Android. The app uses Google Play services, and require some permission.
The launcher activity is very simple and does nothing more than set the content view. I'm testing it on various devices with following results:
HOMTOM HT3 PRO, Android 5.1 Fast on showing first activity.
HUAWEI P8 Lite, Android 6.0 Sometimes shows black screen for 5-10s before start
Galaxy A3, Android 6.1 It's stuck on the black screen.
Nexus 5 Stuck on black screen.
Here is some log from the Galaxy 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
My Start Activity
public class StartActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
//more code
}
}
But while debugging I clearly see that the waiting time is BEFORE the onCreate call. May it depends by huge number of file that the app is composed by? I have 73 java classes + ~100 drawable.
FYI this is my gradle file.
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'
And my Start layout
<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>