Android 开发中遇到的问题

问题1:

Error:Execution failed for task ':app:processDebugManifest'.> Manifest merger failed with multiple errors, see logs

在网上查到了一些这个问题的解决办法:

方法一:java

1)在Manifest根标签加上 xmlns:tools="http://schemas.android.com/tools"android

2)<user-sdk tools:overrideLibrary="本身须要强制替换的库"/>api

3)在Manifest.xml的application标签下添加 tools:replace="android:icon, android:label,android:theme"app

方法二:ide

在build.gradle根标签上加上useOldManifestMerger true (懒人方法)gradle

 

可是上边的方法并无解决个人问题,后来经过检查AndroidManifest.xml文件,发现、ui

 

<meta-data android:name="UMENG_APPKEY" android:value="*****">

 

被重复声明了两次,去掉其中一个就能够了,问题解决。code

问题2:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.>

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v7/appcompat/R$anim.class

报了这个问题,由于v7包冲突的问题,检测了整个项目,发现v7并无冲突。后来再网上看到说是由于gradle wrapper的问题。 在项目根目录下执行命令:gradlew clean便可(./表明根目录)。orm

问题3:

RecyclerView在更新数据是,出现:java.lang.IllegalArgumentException Scrapped or attached views may not be recycled. isScrap:false isAttached:true

问题是由于在获取新数据事将数据集合清除了,可是没有notifyDataSetChanged.能够将清除集合操做在获取数据以后将原来的集合清除,而后再将新数据加到集合中调用adapter的notifyDataSetChanged()方法.xml

问题4:

最近一个朋友问我一个问题:Toast中的内容不居中显示,一开始他传入的Context是Activity,我让他修改为getBaseContext()、getApplicationContext()都不行。后来查找到在Application 配置的主题中设置了fitsSystemWindows=true ,注释掉就能够了。

问题5:

最近觉得群友出现了一个问题:Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not requestWindow.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.

提示添加toolbar失败,已经存在了actionbar。

解决办法:

方式一:将主题替换为NoTitleBar主题;

方式二:将当期主题的notitle设置为true;