Android开发错误汇总

1、Caused by: android.view.InflateException: Binary XML file line #60: Error inflating class <unknown>文件布局解析错误:xml布局中存在错误,XML file line #60显示是在xml中60行

解决方式:找到错误指示解析的布局,修改对应行


2、Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)

文件读写错误:可能原因:1)文件读写权限没有加 


<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

2)文件路径错误,检查是否存在此路径

3、导工程进入studio时报错,Error:Execution failed for task':app:mergeDebugResources'.
> Some file crunching failed, see logs for details

解决办法,在项目目录下,app的build文件中加入(加入android标签内)

  1. defaultConfig {

    multiDexEnabled true

  2. }


4、 Error Loading Project: Cannot load 3 facets Details...

plugins插件加载错误:我所使用的办法,settings---->plugins然后选中


然后再reset一下

5、在做6.0动态权限时,如果有申请相机权限时,应该保证Manifest.permission.CAMERA和Manifest.permission.WRITE_EXTERNAL_STORAGE权限同时申请,不要漏掉后者。

6、使用Glide时,注意对传入的Acticity与Fragment进行判断,避免传入已经销毁Acticity,造成IllegalArgumentException异常。


7、adb已停止工作(不停弹出对话框)

真机问题,手机重启或取掉手机报错就不会出现了

8、安装studio SDK更新文件时报错

-=Warning !=-
A folder failed to be renamed or moved.On Windows this typically means
that  a program is using that folder (for example Windows Explorer or your anti-virus software.)
Please momentarily deactivate your anti-virus software
Please also close any running,programs that may be accessing the directory
'G:\software\android-sdk-windows\tools'.
When ready,press Yes to try again.

解决方法有两种:

第一种方法(貌似是从国外的网站上找来):

1), 复制 tools目录 为一个新的目录 tools-copy ,此时在android-sdk-windows 目录下有两个目录 tools 和 tools-copy
2), 在tools-copy目录运行 android.bat ,这样就可以正常 update all 了
3), 之后,关闭 sdk, 
4), 在 android-sdk-windows 目录运行 SDK Setup.exe


第二种方法:

 1), 进入sdk的temp文件夹,下载好后会有一个tools_r10-windows.zip(版本号可能会不一样,如r09)
 2), 解压此文件,如解压到tools_r10-windows目录
 3), 进入tools_r10-windows文件夹,将tools_r1006-windows里的文件复制
 4), 覆盖掉sdk根目录的tools文件夹中的文件


9、Error:Execution failed for task ':app:processDebugManifest'. > 

Manifest merger failed with multiple errors, see logs


文件冲突(重复问题)  此处为Manifest重文件冲突
导入module(vitamio)冲突,我的问题是,两个中的label和icon调用不一致导致,

修改方式,改为一致就好了


10、在使用webview加载url的时候出现错误: "TypeError: Cannot read property 'Token' of null
解决方式:可能是缓存问题,需要清除缓存(设置属性的时候加上下面这段代码就好了)

webView.clearCache(true); //清除缓存

11、Error:Execution failed for task ':app:prepareComAndroidSupportAnimatedVectorDrawable2421Library'.
> Could not initialize class com.android.ide.common.util.ReadWriteProcessLock

解决:
将gradle版本改为(2.4以后出现的问题)
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
12、Error:Failed to open zip file.Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a>
<a href="syncProject">Re-download dependencies and sync project (requires network)</a>
解决:
更改gradle中的版本为自己当前新建项目使用的版本。检查sdk版本号,编译工具版本号等是否正确


13、不要在Android的Application对象中缓存数据


Application对象并不是始终在内存中的,它有可能会由于系统内存不足而被杀掉。但Android在你恢复这个应用时并不是重新开始启动这个应用,它会创建一个新的Application对象并且启动上次用户离开时的activity以造成这个app从来没有被kill掉得假象。

  我们以为可以通过Application来缓存数据,却没想到恢复APP时直接跑了B Activity而不是先启动A Activity,最终导致的结果是程序意外的崩溃掉了


14、Error:Failed to complete Gradle execution.

Cause:
远程主机强迫关闭了一个现有的连接。
解决:
gradle版本异常,修改正确(studio可用的,gradle中的版本号可能不能用,或者是那个版本有为题导致不能用,可以删除掉不能用的版本)的版本

15、Toolbar去除标题与返回键间的间距

给toolbar加上以下属性:

 

app:navigationIcon="@drawable/icon_back" //这是设置返回键图标,这是必不可少的。 app:contentInsetStartWithNavigation="0dp"

为了保险起见,建议加上这两个属性:

 

app:contentInsetLeft="0dp" app:contentInsetStart="0dp"

完整的示范如下:

 

<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/title_tool_bar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/colorTheme" app:contentInsetLeft="0dp" app:contentInsetStart="0dp" app:contentInsetStartWithNavigation="0dp" app:layout_scrollFlags="enterAlways|scroll" app:navigationIcon="@drawable/icon_back" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:theme="@style/ToolbarStyle" app:title="标题" app:titleTextColor="@color/colorWhite">

关注公众号:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码农乐园

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值