android - 生成的 apk 崩溃了
问题描述
我刚刚完成了我的最后一个 android 项目,但我遇到了一个奇怪的问题。我一直在开发该应用程序时,我曾经通过单击那个绿色按钮在我的设备上运行它,它运行良好。但是现在我已经创建了我的应用程序的 apk 文件,它可以毫无问题地安装在设备上,但是当我想启动应用程序时,它崩溃了并且永远不会启动。
任何帮助将不胜感激。谢谢。
更新:依赖项:
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'
视图模型类:
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 ""
}
}
ViewModel 用法:
val model = ViewModelProviders.of(this).get(MyImageViewModel::class.java)
createdImageFile = model.returnImagePath()
if (createdImageFile != ""){
//do sth with the image file path
}
解决方案
感谢所有试图提供帮助的人,我发现了问题。这是一件有点愚蠢的事情。ViewModel 类不应该是私有的!而已。
推荐阅读
- javascript - 如何在反应中嵌套条件语句 - 变得未定义
- google-visualization - 谷歌可视化 - 选择处理程序不起作用
- report - 在 AdSense v2 中接收报告数据
- gradle - Gradle 守护进程类加载器
- php - 如何在我的页面上显示我教父的名字
- java - 将 MutableList 或 ArrayList 从 Activity A 传递和检索到 B
- python - AttributeError: set_model Error (Keras callbacks)
- arrays - 在 hive 中将字符串数组转换为 int 数组时保留顺序
- reactjs - 如何从material-ui返回值状态
使用 inputProps - powershell - PowerShell - 对存储在本地设备中的 Chrome 91.0.4472.106 cookie 应用 AES-256-GCM 解密