I've just finished my last android project but I'm facing a weird problem. All the time I was working on the app, I used to run it on my device by clicking that green button and it worked fine. But now that I've created my app's apk file, it installes on device with no problem, but at the time I want to start the app, it crashes out and never starts.
Any help will be appreciated. Thanks.
UPDATE: Dependencies:
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation 'com.android.support:preference-v14:26.1.0'
implementation 'com.github.codekidX:storage-chooser:2.0.4.2'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'android.arch.lifecycle:viewmodel:1.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:26.1.0'
ViewModel Class:
private class MyImageViewModel: ViewModel(){
fun returnImagePath(): String{
return createdImageFile
//createdImageFile is a global string that contains the path of an image and its default value is ""
}
}
ViewModelUsage:
val model = ViewModelProviders.of(this).get(MyImageViewModel::class.java)
createdImageFile = model.returnImagePath()
if (createdImageFile != ""){
//do sth with the image file path
}