md_files/Java/安卓开发.md

52 lines
1.9 KiB
Markdown
Raw Normal View History

2025-03-18 12:46:59 +08:00
# 安卓开发
## 导入功能模块心得
最近想在我的书城中开发一下阅读器的功能难度颇高因此在github上找到了一个封装了阅读器功能的项目仅需获得文件本地存储地址调用其提供的函数即可进行阅读。
**但是**github介绍的使用方法并不总是有效比如我就经常无法正确添加依赖
2025-03-19 18:31:37 +08:00
![image-20240503200121198](https://pic.bitday.top/i/2025/03/19/u7dq7u-2.png)
2025-03-18 12:46:59 +08:00
因此,我将其项目代码拷贝到本地,手动集成。
2025-03-19 18:31:37 +08:00
![image-20240503200221147](https://pic.bitday.top/i/2025/03/19/u7djxz-2.png)
2025-03-18 12:46:59 +08:00
依据项目结构可以发现app是主项目hwtxtreaderlib是功能模块根据是这张图
2025-03-19 18:31:37 +08:00
![image-20240503200343665](https://pic.bitday.top/i/2025/03/19/u7dxvc-2.png)
2025-03-18 12:46:59 +08:00
build.gradle(:app)中引入了hwtxtreaderlib的依赖而app只是个demo测试模块相当于演示了如果在自己的项目中引用hwtxtreaderlib。因此手动步骤如下
- 将hwtxtreaderlib复制到自己的项目文件夹中
2025-03-19 18:31:37 +08:00
![image-20240503200651488](https://pic.bitday.top/i/2025/03/19/u7eub5-2.png)
2025-03-18 12:46:59 +08:00
- 在app的build.gradle中添加依赖
```text
2025-03-18 12:46:59 +08:00
implementation project(':hwtxtreaderlib')
```
- 在settings.gradle中设置项目包括的模块
```text
2025-03-18 12:46:59 +08:00
include ':app', ':hwtxtreaderlib'
```
- syn now 同步一下然后android studio中项目结构变成如下图
2025-03-19 18:31:37 +08:00
![image-20240503201012590](https://pic.bitday.top/i/2025/03/19/u7en9c-2.png)
2025-03-18 12:46:59 +08:00
- build没报错基本就稳了然后就运行试试
2025-03-19 18:31:37 +08:00
![image-20240503201211104](https://pic.bitday.top/i/2025/03/19/u7eesw-2.png)
2025-03-18 12:46:59 +08:00
这里可能AndroidManifest.xml报错需要查看原项目中app模块如何编写的做些适当的修改我这里卡了很久.
**非常重要!!!**有时候github项目会将项目的详细信息写在wiki中
2025-03-19 18:31:37 +08:00
![image-20240503213919450](https://pic.bitday.top/i/2025/03/19/u7e586-2.png)