配置更改两个地方,本人亲测
1.app中
apply plugin: 'com.android.application'
def AAVersion = '4.4.0'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions{
annotationProcessorOptions{
arguments = ['resourcePackageName':"com.example.myapplication"]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
implementation "org.androidannotations:androidannotations-api:$AAVersion"
}
2.全部中:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
第一步:
在res/layout文件夹下创建自己想要的目录(有几个模块就建几个目录)
第二步:
在创建好的模块目录下,创建layout文件夹
第三步:
将布局文件放入相应的layout文件夹
第四步:
打开app/build.gradle,在android{}中加入以下代码
sourceSets { main { res.srcDirs = [ 'src/main/res/layout/account', 'src/main/res/layout/around', 'src/main/res/layout/home', 'src/main/res/layout/map', 'src/main/res/layout/pay', 'src/main/res/layout/umeng', 'src/main/res/layout', 'src/main/res' ] } }
最后,编译一下,成功解决问题。