ClassNotFoundException:"com.android.tools.fd.runtime.BootstrapApplication"
2016-07-19 15:11
453 查看
异常原因
使用AndroidStudio及API23打包并编译的APK,在部分机型上无法正常打开,会出现闪退现象.连接调试可以发现程序报错提示没有找到类
com.android.tools.fd.runtime.BootstrapApplication.
AndroidRuntime: FATAL EXCEPTION: main Process: com.efamily.platform, PID: 26372 java.lang.RuntimeException: Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication: java.lang.ClassNotFoundException: Didn't find class "com.android.tools.fd.runtime.BootstrapApplication" on path: DexPathList[[zip file "/data/app/com.efamily.platform-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.efamily.platform-1, /vendor/lib, /system/lib]]
但是实际上我们并没有创建这个,明显是来自系统的.查了一下可以发现这个是跟AndroidStudio启用的一个叫
Instant Run的功能有关.
Instant Run
根据官方文档说明:Although your first build may take longer to complete, Instant Run pushes subsequent updates to your app without building a new APK, so changes are visible much more quickly.
尽管第一次build的时间会花费更长的时间,但是Instant Run可以在后续更新APP时不需要创建新的APK,所以改变是快速可见的.
Instant Run的缺陷
在测试的时候对代码进行修改时,再运行会很快打开当前已经打开的Activity并更新内容(当修改UI时会非常明显).更新APK的速度确实是会非常快.但是他的缺点也是很明显的:Instant Run is supported only when you deploy the debug build variant, use Android Plugin for Gradle version 2.0.0 or higher, and set minSdkVersion to 15 or higher in your app’s module-level build.gradle file. For the best performance, set minSdkVersion to 21 or higher.
首先只有使用Gradle 2.0以上版本可用,最低minSdkVersion必须是15或者以上,需要得到更好体验应该设置SDK 21以上.另外,只会在部署变化的调试版本时支持
(部分翻译有误请指出)
所以这就说明了当系统API并没有达到21时非常有可能是无法支持的.虽然在实际中不能用的机子有一部分是5.0系统的,但并没有什么卵用…
解决方案
解决方案是建议在发部测试版本的时候如果测试的机子系统覆盖范围比较大(包括很多低版本系统时),可以关闭该功能并重新打包发布即可.官方说明关闭方法如下:
To disable Instant Run:
Open the Settings or Preferences dialog.
Navigate to Build, Execution, Deployment > Instant Run.
Uncheck the box next to Enable Instant Run.
打开设置->Build->Execution->Deployment->Instant Run->取消Enable即可
我在我的Android Studio上并没有发现这个结构层次,建议用以下的办法会更容易也比较适用所有类型的Android Studio
打开Preferences或者Settings
在左上角搜索框中搜索
Instant Run
左侧边选择
Instant Run选项,选择第一个
Enable取消打勾
我的选项显示的是:
Enable Instant Run to hot swap code/resource changes on deploy(default enabled)
官方文档
https://developer.android.com/studio/run/index.html#instant-run可能需要翻墙才能看
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories