android开发常见问题
android开发常见问题零碎点
1、 @android: 引用安卓内建的系统资源
android:background=“@android:drawable/ic_menu_delete”
2、 ?attr/: 引用应用内的属性资源
比如我在 styles 里定义了一个属性:
定义完之后,我就可以直接在 layout 中通过引用的方式去使用这个属性了:
android:background="?attr/colorReallyGreen"
3、 ?android: 引用系统内建的属性资源
4、app:和一般的android:
这两个是声明的不同的命名空间,android的是系统的,app是自定义的。
5、EditText去除下划线
android:background="@null"
6、ERROR: The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
解决方案:
把manifest.xml 里的sdk最小版本设置都删掉 Androidstudio3.0 以后 不能在manifest.xml 设置这些 必须在 gradle里设置/
7、Lint found fatal errors while assembling a release target的解决方案
解决方案;
在app的build.gradle中添加
android { lintOptions { abortOnError false }}
8、Didn`t find class BasicHttpParams
原因: Apache Http 客户端弃用
因为早在 Android 6.0 中,谷歌取消了对 Apache Http 客户端的支持。从 Android 9.0 开始, org.apache.http.legacy 将从 bootclasspath 中删除。
该修改对于大多数 taskVersion < 9.0 的应用没有影响,对所有 taskVersion > 9.0 的应用,如果继续使用 Apache Http 接口或者引用的 lib 包中用到该接口时,都会出现 Apache Http 接口找不到的异常。
解决方案:
在应用的 AndroidManifest.xml 文件的 中添加:
再次运行应用,完美运行。
9、Android studio MemoryLeakMonitor.jar is not exist!
华为手机调试性能优化,使用as的profiler时,无法选择memory的范围,报错信息。
原因:大概主要理解为华为部分手机出现的bug
解决:暂不知晓,换个手机就好了
10、 android debug卡在waiting for debugger,显示Could not connect to remote process. Aborting debug session
打开了多个IED,关闭其它的留下一个。就是打开了两个模拟设备,比如:一个手机,一个夜神模拟器。
或者
打开了DDMS 也要关掉
11、New Gradle Sync is not supported due to containing Kotlin modules using an unsupported plugin versio
gradle 配置的 kotlin插件版本和IDE(android-studio)中kotlin plugin版本不匹配,导致kotlin插件无法启用。
在android-studio中,kotlin是系统自带的plugins,android-studio根目录下plugins文件夹内的kotlin文件夹可看到
12、addView(View, LayoutParams) is not supported in AdapterView
==解决办法==:布局文件,
13、Android Studio waiting for build to finish...
==解决办法==:Gradle损坏,重新同步gradle, File ->Sync Project with Gradle Files
或者 Ctrl ShiftA Sync Project With Gradle Files
14、文件找不到(cannot resolve symbol R)
原因是Intellij IDEA对单个文件的大小默认限制为2500kb, android studio是基于Intellij IDEA的;
解决方法就是进入android studio的安装目录 ,我的是 D:\Program Files\android-studio\bin ,将里面的idea.max.intellisense.filesize=2500数值更改为5000,重启AS就能解决了。
15:安卓8以上无法显示通知
No Channel found for pkg=com.example.xx.xx, channelId=null, id=1001, tag=null…解决办法:
源代码 //设置channel NotificationChannel channel = new NotificationChannel("1", "mychannel", NotificationManager.IMPORTANCE_DEFAULT); channel.enableLights(true); channel.setLightColor(Color.GREEN); notificationManager.createNotificationChannel(channel); myBuilder.setContentTitle("叶良辰") .setContentText("我有一百种方法让你找不到bug") .setSubText("安卓8以上的通知需要设置channel!") .setTicker("收到叶良辰发来的消息") .setWhen(System.currentTimeMillis()) .setSmallIcon(R.drawable.yinlian) .setLargeIcon(LargeBitmap) .setAutoCancel(true) .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE) .setContentIntent(pit) .setChannelId("1");
15 glide无法使用
最新版本配置环境
解决办法:
添加
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
更多相关文章
- Android(安卓)Display System --- Surface Flinger
- Android中webview跟JAVASCRIPT中的交互
- 设置Android(安卓)SDK tools工作路径环境变量
- android小知识点
- Android中TextVIew一些属性
- 谷歌Android被Linux内核除名
- 设置TextView文字居中,代码实现android:layout_gravity
- Android核心模块及相关技术
- Android(安卓)Studio 如何引用aar包