The app I'm developing works with no problem on emulator, but when I install the debug apk on a device, it takes 30 secs or maybe a minute to open for the first time (white screen for the entire time), and when finally it shows something and the app runs, it first shows me an error that the app takes too long, I choose to ignore it since the app finally show something. When it finally works for the first time, it runs with no problem at all. This only happened THE FIRST TIME the app is opened after installation.
So in summary:
The app works great on emulator.
The app is installed with no problem.
The first time the app is opened it shows nothing but a full white screen.
The app finally works just like in the emulator.
Shortly after the app starts working, the device shows me an error, to close or wait for the app.
After ignoring the error, the app works with no problem at all, all services working.
If the app is closed and opened again, it works perfectly.
Note: This app have multiDexEnabled true, I know this may be the cause, but in the emulator works fine.
Thanks for all the help you can give me here.
EDIT: Some more infor about the app: It uses maps, and firebae to give user notifications. The map service and activity is called only when the user enters the activity, firebase service on the other hand, is called when the app runs. this is the gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.example.andres.redfutbol"
multiDexEnabled true
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.android.support:design:24.1.0'
//compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.google.android.gms:play-services:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
Please if you need more information let me know. And i dont think this is a dublicate question as suggested below, that question is about the emulator, and as i mentioned before, in my case, my app runs fast and good in the emulator, is when i tested it in a real device when this problem happened, and to mention it again, it only happened THE FIRST TIME the app is opened after installation, later, i can close it, open it and close it again, it will work fine.