更新维护文档

master
pjh 3 years ago
parent 999fd16ce2
commit bfa79b9e87

@ -0,0 +1,123 @@
# 小米便签环境配置
## 一、安装Android Studio
### 1.下载Android Studio
下载网址:[Download Android Studio & App Tools - Android Developers (google.cn)](https://developer.android.google.cn/studio/)
(不确定怎么安装的话可以上网搜一下,我这里已经安好了)
### 2.下载SDK
### 3.下载小米便签开源代码并解压缩
## 二、导入项目
### 1.打开Android Studio
选择import Project导入。时间可能比较长稍微等一下。
![](D:\StudyNotes\imag\importproject.png)
### 2.编译环境
添加gradle如下配置即可
![](D:\StudyNotes\imag\9.png)
## 三、出现的bug
### 1.build.gradle文件设置
载入后是以下画面:
打开build.gradle先在以下箭头处增加google
若仍然有问题则增加,没问题就不用加:
```java
maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
//阿里云的maven仓库
```
然后在 classpath处最后更改一下gradle的版本我改成了7.2.2。都设置好后点击右上方的Try Again
![/imag/first](D:\StudyNotes\imag\first.png)
### 2.解决Cannot Resolve Symbol HttpEntity,HttpResponse和Google Play requires that apps target API level 29 or higher
1Cannot Resolve Symbol HttpEntity,HttpResponse
![](D:\StudyNotes\imag\2.png)
原因:`HTTP client`在sdk23就已经被分离了将下面的代码加入到你的build.gradle(:app)文件中:
```java
//下图有,可以对着看
android{
useLibrary 'org.apache.http.legacy'
}
```
2Google Play requires that apps target API level 29 or higher
将下图中targetSdkVersion更改成29或者30我这里更改成29会报错所以我改成了30
![](D:\StudyNotes\imag\3.png)
原因之前我们将下载源改为了谷歌之前添加的google())但是api的版本不同步故需要修改使之同步。
### 3.解决Cannot resolve method setLatestEventInfo in Notification
![](D:\StudyNotes\imag\4.png)
原因在低于API Level 11版本也就是Android 2.3.3以下的系统中setLatestEventInfo()函数是唯一的实现方法而在高于API Level 11的版本中setLatestEventInfo()函数已经被弃用了于是我们需要根据现有的Android版本进行相应地重写该函数
解决方法将GTaskASyncTask.java中的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), 0);
} else {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesListActivity.class), 0);
}
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);
}
```
然后编译一下就解决了:
![](D:\StudyNotes\imag\5.png)
### 4.解决Mising URL报错
app文件夹下的manifests文件夹的AndroidManifest.xml文件会出现以下报错
![](D:\StudyNotes\imag\6.png)
解决方式:
一直点第一行的红色小灯泡,直到不报错为止。
![](D:\StudyNotes\imag\7.png)
## 四、狠狠的编译
点上面的小绿色锤子,很很编译!
![](D:\StudyNotes\imag\8.png)
Loading…
Cancel
Save