|
|
|
@ -0,0 +1,90 @@
|
|
|
|
|
# 小米便签项目日志
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### 导入文档
|
|
|
|
|
|
|
|
|
|
直接使用老师提供压缩包文档用Android studio打开,出现报错显示检测不到build.gradle文件
|
|
|
|
|
|
|
|
|
|
原因分析:
|
|
|
|
|
|
|
|
|
|
1.项目构建工具的变更:项目为旧版本小米便签,没有采用gradle作为构建工具
|
|
|
|
|
|
|
|
|
|
2.代码有遗漏不完整,但是在github上发现源码与文件一致没有遗漏
|
|
|
|
|
|
|
|
|
|
解决方法:
|
|
|
|
|
|
|
|
|
|
直接使用安卓studio创建新的文件,再搬运小米便签的源代码(res、src等等),之后文件目录增加gradle模块
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### GTaskASyncTask.java修改
|
|
|
|
|
|
|
|
|
|
出现报错:80: 错误: 找不到符号
|
|
|
|
|
notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
|
|
|
|
|
^
|
|
|
|
|
|
|
|
|
|
分析原因:版本问题,新版本的安卓项目对notification.builder不兼容了,需要把showNotification函数进行修改
|
|
|
|
|
|
|
|
|
|
修改代码:
|
|
|
|
|
|
|
|
|
|
```java
|
|
|
|
|
private void showNotification(int tickerId, String content) {
|
|
|
|
|
PendingIntent pendingIntent;
|
|
|
|
|
if (tickerId != R.string.ticker_success) {
|
|
|
|
|
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
|
|
|
|
|
NotesPreferenceActivity.class), PendingIntent.FLAG_IMMUTABLE);
|
|
|
|
|
} else {
|
|
|
|
|
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
|
|
|
|
|
NotesListActivity.class), PendingIntent.FLAG_IMMUTABLE);
|
|
|
|
|
}
|
|
|
|
|
Notification.Builder builder = new Notification.Builder(mContext)
|
|
|
|
|
.setAutoCancel(true)
|
|
|
|
|
.setContentTitle(mContext.getString(R.string.app_name))
|
|
|
|
|
.setContentText(content)
|
|
|
|
|
.setContentIntent(pendingIntent)
|
|
|
|
|
.setWhen(System.currentTimeMillis())
|
|
|
|
|
.setOngoing(true);
|
|
|
|
|
Notification notification=builder.getNotification();
|
|
|
|
|
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### build.gradle(Module:app)修改
|
|
|
|
|
|
|
|
|
|
出现报错:3 files found with path 'META-INF/DEPENDENCIES'.
|
|
|
|
|
Adding a packaging block may help, please refer to https://developer.android.com/reference/tools/gradle-api/8.3/com/android/build/api/dsl/Packaging for more information
|
|
|
|
|
|
|
|
|
|
分析原因:不同的依赖库中包含了相同路径和文件名的文件,报错显示的是有相同的路径META-INF/DEPENDENCIES,所以gradle无法处理重复的文件
|
|
|
|
|
|
|
|
|
|
在build.gradle中添加packing函数,让gradle在相同路径时进行选择处理
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
packaging {
|
|
|
|
|
resources.excludes.add("META-INF/DEPENDENCIES");
|
|
|
|
|
resources.excludes.add("META-INF/NOTICE");
|
|
|
|
|
resources.excludes.add("META-INF/LICENSE");
|
|
|
|
|
resources.excludes.add("META-INF/LICENSE.txt");
|
|
|
|
|
resources.excludes.add("META-INF/NOTICE.txt");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### gradle.properties修改
|
|
|
|
|
|
|
|
|
|
在文件NoteEditActivity.java中对switch语句报错Constant expression required
|
|
|
|
|
|
|
|
|
|
分析:在Android studio中使用了JDK17以上的版本 switch语句的条件表达式不支持使用枚举类型
|
|
|
|
|
|
|
|
|
|
但是在代码中使用了case R.id.menu_new_note:
|
|
|
|
|
|
|
|
|
|
解决方法:在gradle.propertties中添加语句/改变switch用if-else来做条件语句(选择前者)
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
android.nonFinalResIds=false //让资源 ID 恢复为 `final` 常量
|
|
|
|
|
```
|
|
|
|
|
|