我为项目创建了一些子模块,这些子模块是从 git 导入的。
当我BuildConfig
为应用程序导入时出现错误,com.app.BuildConfig
.
只有我可以导入BuildConfig
的是我的子模块之一,如com.submodule.BuildConfig
.
我认为 Gradle 文件没有什么特别之处,但只有我能想象的是 gradle 问题......
所以请检查我的gradle文件。
项目等级
buildscript {
apply from: ‘dependencies.gradle’
repositories {
google()
jcenter()
}
dependencies {
classpath “com.android.tools.build:gradle:$gradleVersion”
classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion”
classpath “org.jetbrains.kotlin:kotlin-android-extensions:$kotlinVersion”
classpath “android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0"
}
}
allprojects {
repositories {
maven {
url “https://maven.google.com”
}
google()
jcenter()
}
}
subprojects {
configurations {
ktlint
}
dependencies {
ktlint “com.github.shyiko:ktlint:0.31.0"
}
task ktlint(type: JavaExec) {
main = ‘com.github.shyiko.ktlint.Main’
classpath = configurations.ktlint
args ‘../**/*.kt’
}
task ktlintFormat(type: JavaExec) {
main = ‘com.github.shyiko.ktlint.Main’
classpath = configurations.ktlint
args ‘-F’, ‘../**/*.kt’
}
afterEvaluate { project ->
check.dependsOn ktlint
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用程序分级
apply plugin: ‘com.android.application’
apply plugin: ‘kotlin-android’
apply plugin: ‘kotlin-android-extensions’
apply plugin: ‘kotlin-kapt’
apply plugin: “androidx.navigation.safeargs”
android {
compileSdkVersion project.compileSdkVersion
buildToolsVersion project.buildToolsVersion
defaultConfig {
applicationId “--------”
minSdkVersion project.minSdkVersion
targetSdkVersion project.targetSdkVersion
versionCode 1
versionName “1.0”
testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
packagingOptions {
pickFirst ‘META-INF/atomicfu.kotlin_module’
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
kotlinOptions {
jvmTarget = “1.8”
}
androidExtensions {
experimental = true
}
}
dependencies {
implementation fileTree(dir: ‘libs’, include: [‘*.jar’])
implementation project(‘:submodule1’)
implementation project(‘:submodule2’)
implementation project(‘:submodule3’)
implementation “org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion”
implementation ‘androidx.appcompat:appcompat:1.0.2’
implementation ‘androidx.constraintlayout:constraintlayout:1.1.3’
implementation “io.reactivex.rxjava2:rxjava:${rxJava2Version}”
implementation “io.reactivex.rxjava2:rxandroid:${rxAndroid2Version}”
implementation ‘org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1’
implementation “androidx.lifecycle:lifecycle-extensions:$archLifecycleVersion”
implementation “androidx.lifecycle:lifecycle-viewmodel:$archLifecycleVersion”
implementation “androidx.lifecycle:lifecycle-livedata:$archLifecycleVersion”
implementation “org.jetbrains.anko:anko-sdk25:${ankoVersion}”
implementation “org.jetbrains.anko:anko-appcompat-v7-commons:${ankoVersion}”
implementation “org.jetbrains.anko:anko-appcompat-v7:${ankoVersion}”
implementation “com.squareup.moshi:moshi-kotlin:1.8.0”
implementation “androidx.navigation:navigation-ui-ktx:$navigation”
implementation “androidx.navigation:navigation-fragment-ktx:$navigation”
implementation “androidx.core:core-ktx:1.2.0-beta01"
implementation “com.trello.rxlifecycle3:rxlifecycle-android-lifecycle-kotlin:${trelloRxLifeCycle}”
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"
implementation (‘com.airbnb.android:lottie:3.0.0’)
}
子模块1 gradle
apply plugin: ‘com.android.library’
apply plugin: ‘kotlin-android’
apply plugin: ‘kotlin-android-extensions’
apply plugin: ‘kotlin-kapt’
android {
compileSdkVersion project.compileSdkVersion
buildToolsVersion project.buildToolsVersion
defaultConfig {
minSdkVersion project.minSdkVersion
targetSdkVersion project.targetSdkVersion
versionCode 1
versionName “1.0”
testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
androidExtensions {
experimental = true
}
}
dependencies {
implementation fileTree(dir: ‘libs’, include: [‘*.jar’])
implementation “org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion”
implementation ‘androidx.appcompat:appcompat:1.0.2’
implementation ‘androidx.constraintlayout:constraintlayout:1.1.3’
implementation ‘org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1’
implementation “io.reactivex.rxjava2:rxjava:${rxJava2Version}”
implementation “io.reactivex.rxjava2:rxandroid:${rxAndroid2Version}”
implementation “androidx.lifecycle:lifecycle-extensions:$archLifecycleVersion”
implementation “androidx.lifecycle:lifecycle-viewmodel:$archLifecycleVersion”
implementation “androidx.lifecycle:lifecycle-livedata:$archLifecycleVersion”
implementation “org.jetbrains.anko:anko-sdk25:${ankoVersion}”
implementation “org.jetbrains.anko:anko-appcompat-v7-commons:${ankoVersion}”
implementation “org.jetbrains.anko:anko-appcompat-v7:${ankoVersion}”
implementation “com.squareup.moshi:moshi-kotlin:1.8.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”
}
谢谢你的任何建议。