|
|
|
@ -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导入。时间可能比较长,稍微等一下。
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
### 2.编译环境
|
|
|
|
|
|
|
|
|
|
添加gradle,如下配置即可:
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
## 三、出现的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:
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
### 2.解决Cannot Resolve Symbol HttpEntity,HttpResponse和Google Play requires that apps target API level 29 or higher
|
|
|
|
|
|
|
|
|
|
(1)Cannot Resolve Symbol HttpEntity,HttpResponse
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
原因:`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)
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
原因:之前我们将下载源改为了谷歌(之前添加的google()),但是api的版本不同步,故需要修改使之同步。
|
|
|
|
|
|
|
|
|
|
### 3.解决Cannot resolve method ‘setLatestEventInfo’ in ‘Notification’
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
原因:在低于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);
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
然后编译一下就解决了:
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
### 4.解决Mising URL报错
|
|
|
|
|
|
|
|
|
|
app文件夹下的manifests文件夹的AndroidManifest.xml文件,会出现以下报错:
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
解决方式:
|
|
|
|
|
|
|
|
|
|
一直点第一行的红色小灯泡,直到不报错为止。
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
## 四、狠狠的编译
|
|
|
|
|
|
|
|
|
|
点上面的小绿色锤子,很很编译!
|
|
|
|
|
|
|
|
|
|

|