1、Android 新创建的项目找不到R文件。
2、解决方式:
在项目的XML文件中添加
注意:这个就能解决问题了,如果不能解决,下方的对齐一下。
3、gradle也要同步一下
1、全局的build.gradle
buildscript {
//1.4.10
ext{
kotlin_version = '1.6.10'
}
repositories {
google()
mavenCentral()
//阿里云jcenter仓库
maven{ url 'https://maven.aliyun.com/repository/jcenter' }
maven {
url 'https://jitpack.io'
}
}
dependencies {
//4.1.1
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
allprojects {
repositories {
google()
mavenCentral()
//阿里云jcenter仓库
maven{ url 'https://maven.aliyun.com/repository/jcenter' }
maven {
url 'https://jitpack.io'
}
}
//配置这个
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2、gradle-wrapper.properties
#Mon Nov 20 13:48:45 CST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3、app的build.gradle
buildscript {
//1.4.10
ext{
kotlin_version = '1.6.10'
}
repositories {
google()
mavenCentral()
//阿里云jcenter仓库
maven{ url 'https://maven.aliyun.com/repository/jcenter' }
maven {
url 'https://jitpack.io'
}
}
dependencies {
//4.1.1
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
allprojects {
repositories {
google()
mavenCentral()
//阿里云jcenter仓库
maven{ url 'https://maven.aliyun.com/repository/jcenter' }
maven {
url 'https://jitpack.io'
}
}
//配置这个
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
最后
如果想要成为架构师或想突破20~30K薪资范畴,那就不要局限在编码,业务,要会选型、扩展,提升编程思维。此外,良好的职业规划也很重要,学习的习惯很重要,但是最重要的还是要能持之以恒,任何不能坚持落实的计划都是空谈。
如果你没有方向,这里给大家分享一套由阿里高级架构师编写的《Android八大模块进阶笔记》,帮大家将杂乱、零散、碎片化的知识进行体系化的整理,让大家系统而高效地掌握Android开发的各个知识点。
相对于我们平时看的碎片化内容,这份笔记的知识点更系统化,更容易理解和记忆,是严格按照知识体系编排的。
欢迎大家一键三连支持,若需要文中资料,直接扫描文末CSDN官方认证微信卡片免费领取↓↓↓(文末还有ChatGPT机器人小福利哦,大家千万不要错过)
PS:群里还设有ChatGPT机器人,可以解答大家在工作上或者是技术上的问题