懒人包下载(上机即用):百度网盘 请输入提取码
提取码:6w73
7.0.2包下载:百度网盘 请输入提取码
提取码:wsdy
首先去 GitHub - llfjfz/NotePad 下载源码
解压,并在AS中将其打开
此时点击 Build 会报 Gradle版本不匹配 或 Gradle版本不支持 的错误
解决方法
此时修改 project 目录下的 build.gradle 文件为右图所示
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral ()
maven {url 'https://dl.bintray.com/jetbrains/anko'}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
修改 gradle 文件夹下的 gradle-wrapper.properties 的 distributionUrl 属性为
https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
修改 app 文件夹下 build.gradle 的代码如下(主要是修改SDK版本防止兼容性错误)
plugins {
id 'com.android.application'
}
android {
compileSdk 28
defaultConfig {
applicationId "com.example.myapplication"
minSdk 21
targetSdk 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
创建 .gradle 文件夹,并将 7.0.2 的 sdk文件夹 粘贴进去
然后重启AS,单击 Build ,看到已经在自动下载了
Build 成功
如果看到以下标识则点击 Gradle settings
将java版本改成与之对应的即可
修改完毕进行测试,可以看到模拟器测试成功。接下来就看你们的了:)