From bfa79b9e878bd3f36ec6dc6a2df64e0ad90bd731 Mon Sep 17 00:00:00 2001 From: pjh <1963944395@qq.com> Date: Wed, 5 Oct 2022 10:15:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BB=B4=E6=8A=A4=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/小米便签环境配置与维护.md | 123 +++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 doc/小米便签环境配置与维护.md diff --git a/doc/小米便签环境配置与维护.md b/doc/小米便签环境配置与维护.md new file mode 100644 index 0000000..fa60bde --- /dev/null +++ b/doc/小米便签环境配置与维护.md @@ -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 + +(1)Cannot Resolve Symbol HttpEntity,HttpResponse + +![](D:\StudyNotes\imag\2.png) + +原因:`HTTP client`在sdk23就已经被分离了,将下面的代码加入到你的build.gradle(:app)文件中: + +```java +//下图有,可以对着看 +android{ + useLibrary 'org.apache.http.legacy' +} +``` + +(2)Google 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) \ No newline at end of file