Android 开发问题汇总(四)
1.怎么给 Button 加上圆角?
A:Create an xml inside Drawable Folder with below code. Name it rounded_red_border.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Applying the border to a Layout or View
Set the above drawable as a background to your Layout or View like LinearLayout, FrameLayout, TextView, Button etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Reference:Add Rounded Corners to Views and Layouts Android
2.Error:All flavors must now belong to a named flavor dimension.
A:在主app的build.gradle里面的
1 2 3 4 5 6 7 8 9 |
|
Reference:解决Error:All flavors must now belong to a named flavor dimension.
3.error: resource android:attr/fontVariationSettings not found.
A:This is caused by an incompatibility with the android support library that changed to version 28 in the last day or so. Add follow contents to build.gradle:
1 2 3 4 5 |
|
Reference:Problem Isolated - Need Solution
4.Application error. The connection to the server was unsuccessful
A:Add the next line into the config.xml in side the tag.
1
|
|
Reference:Application error. The connection to the server was unsuccessful
5.How to get SQLite database from Android real device?
A:Device File Explorer can archive this goal. We can open it this way:
View -> Tool Windows -> Device File Explorer
Once you have Device File Explorer window open, use your mouse to navigate to the following path:
data -> data -> your.package.name -> databases
Inside the databases folder you should see the database you want to explore, do a right click and Save As… select your desired computer destination folder.
Reference:Get SQLite database from Android app
6.AAPT: error: file failed to compile
A:一个旧的工程编译报错,错误和 nine-patch 图片资源相关,详细的错误为:AAPT: error: file failed to compile,搜索了一圈没找到有效的解决办法。既然错误是和 aapt 相关,于是尝试使用 Android Studio 的命令行工具 aapt 来输出更多错误信息。
1 2 3 |
|
得到了无效的颜色的错误信息,但还是不知道如何解决。只能继续啃 Android Studio 用户指南的Create resizable bitmaps (9-Patch files), 及从中引申出来的 NinePatch drawables ,看完之后对 nine-patch 有了进一步的认识,但是还是不知道如何创建,先尝试用 GIMP 来设置可以拉伸区域,失败了,于是上 Google 搜索相关视频教程,原来是拖动来设置拉伸区域而不是官方文档上面的点击,难怪点击一直没有效果,设置好拉伸区域后就能成功编译了。
7.Android 工程设置 svn:global-ignores, svn:ignore
A:公司是使用 svn 来管理源代码,所以需要为 android 工程设置 svn ignore 规则。 svn 主要通过 svn:global-ignores, svn:ignore
来设置忽略规则。global-ignores 从名称可以看出它是全局相关的,ignore 则是和特定代码库相关的。
svn 的 ignore 规则是面向文件的,所以 global-ignores 可以忽略整个目录,但如果想忽略目录中部分文件则需要设置 ignore,例如可以配置 global-ignores 它可以忽略 .idea
目录,但如果想忽略 .idea
目录中部分文件则需要设置 ignore。个人觉得它不如 git ignore 方便。 下面我们参考 github 的 Android.gitignore 来为工程设置 svn global-ignores, ignore。
主要是使用 $svn propedit svn:global-ignores .
和 $ svn propedit svn:ignore .idea
。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
- Reference: Ignoring Unversioned Items
8..aidl
文件的目标位置
A:当我们使用 AIDL 调用方法时需要包含 .aidl
文件,官方文档上是说 Include the .aidl file in the project src/ directory.
我实际测试下来发现要包含在 src/main/
目录下才会生效。
1 2 3 |
|
9.Activity did not call finish() prior to onResume() completing
A:It was workaround by using Theme.Translucent instead of Theme.NoDisplay in the manifest.
Reference:
10.DownLoadManager failed with ERROR_UNKOWN
A:First check your url, http schema is disable by default on API level 27 or higher. If this is your case, you can change to https schema or enable http via network security configuration.
Second, you can find clue in logcat, remind change it to No Filter, search with DownLoadManager, I find file permission exception from here.
11.Logcat to file
A:
1 2 |
|
12.将 ionic 的 android 工程单独提交到 svn 仓库
A:
1 2 3 4 5 6 7 8 |
|