Преобразовав мои оригинальные скрипты Kotlin Gradle с использования groovy на использование Kotlin DSL, используя следующие статьи в качестве ссылок: Лучший способ управления скриптом сборки Gradle и Перенос скриптов сборки Gradle на Kotlin DSL. После компиляции кода я получаю следующие ошибки сборки.
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could
not resolve project :app.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for
':app@debugAndroidTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for
':app@debugUnitTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@release/compileClasspath':
Could not resolve project :app.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for
':app@releaseUnitTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: app
Предыдущие вопросы, заданные на этой платформе, предполагают,
- Аннулирование кеша и перезапуск студии Android, что я пробовал, и это, похоже, не работает.
- Убедитесь, что глобальная настройка gradle не выбрана как автономная работа, это также было проверено, что она находится в автономном режиме, и проблема все еще сохраняется.
Я попытался решить проблему, используя предложенные решения. Мой build.gradle для модуля приложения выглядит следующим образом:
plugins {
id(Plugins.androidApplication)
kotlin(Plugins.kotlinAndroid)
kotlin(Plugins.kotlinExtensions)
kotlin(Plugins.kapt)
}
android {
compileSdkVersion(Configs.compileVersion)
defaultConfig {
applicationId = Configs.applicationId
minSdkVersion(Configs.minSdkVersion)
targetSdkVersion(Configs.targetSdkVersion)
testInstrumentationRunner = Configs.testInstrumentationRunner
var value = Integer.parseInt(project.property("build_version_code") as String?)
versionCode = value
versionName = project.property("build_version") as String?
}
signingConfigs {
getByName("debug") {
}
create("release") {
}
}
buildTypes {
getByName("debug") {
buildConfigField("boolean", "MOCK_HARDWARE", "false")
signingConfig = signingConfigs.findByName("debug")
applicationIdSuffix = ".debug"
matchingFallbacks = listOf("debug")
}
getByName("release") {
isMinifyEnabled = false
buildConfigField("boolean", "MOCK_HARDWARE", "false")
proguardFiles(getDefaultProguardFile(ProGuards.proguardTxt), ProGuards.androidDefault)
signingConfig = signingConfigs.findByName("release")
matchingFallbacks = listOf("release")
}
dataBinding {
isEnabled = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
repositories {
flatDir {
dirs("libs")
}
}
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to
listOf("*.jar", "*.arr"))))
implementation(Libs.stdLib)
implementation(Libs.sunmiui)
implementation(Libs.slf4j)
implementation(Libs.appCompact)
implementation(Libs.otpView)
implementation(Libs.vectordrawableAnimated)
implementation(Libs.materialComponents)
implementation(Libs.recyclerView)
implementation(Libs.constraintLayout)
implementation(Libs.junit)
implementation(Libs.testRunner)
implementation(Libs.expressoCore)
implementation(Libs.lifecyleExtensions)
kapt(Libs.lifecyleCompiler)
implementation(Libs.roomRuntime)
implementation(Libs.databindingCompiler)
implementation(Libs.rxjava)
implementation(Libs.rxjavaAndroid)
implementation(Libs.glide)
implementation(Libs.glideCompiler)
implementation(Libs.gson)
implementation(Libs.joda)
implementation(Libs.countrycodePicker)
implementation(Libs.timber)
implementation(Libs.daggerandroidSupport)
implementation(Libs.daggerandroidProcessor)
}
Мой Dependencecies.kts выглядит следующим образом:
object Versions
{
// kotlin
const val kotlin = "1.3.31"
const val buildToolsVersion = "28.0.3"
const val lifecycleExtensionVersion = "2.0.0"
const val lifecyleCompilerVersion = "2.0.0"
const val stdLibVersion = "1.3.21"
const val otpViewVersion = "2.0.3"
const val appCompactVersion = "1.1.0-alpha05"
const val constraintLayoutVersion = "2.0.0-beta1"
const val materialComponentsVersion = "1.1.0-alpha06"
const val recyclerViewVersion = "1.0.0"
const val junitVersion = "4.12"
const val testRunnerVersion = "1.1.1"
const val expressoCoreVersion = "3.1.1"
const val roomRuntimeVersion = "2.1.0-alpha04"
const val databindingCompilerVersion = "3.5.0-alpha06"
const val rxjavaVersion = "2.2.7"
const val rxjavaAndroidVersion = "2.1.1"
const val glideVersion = "4.8.0"
const val glideCompilerVersion = "4.8.0"
const val gsonVersion = "2.8.5"
const val jodaVersion = "2.7.2"
const val countrycodePickerVersion = "2.3.0"
const val timberVersion = "4.7.1"
const val daggerandroidSupportVersion = "2.19"
const val daggerandroidProcessorVersion = "2.19"
const val slf4jVersion = "1.7.21"
const val vectordrawableAnimatedVersion = "1.1.0-beta01"
const val sunmiuiVersion = "1.1.27"
}
object Libs
{
const val lifecyleExtensions = "androidx.lifecycle:lifecycle-extensions:${Versions.lifecycleExtensionVersion}"
const val lifecyleCompiler = "androidx.lifecycle:lifecycle-compiler:${Versions.lifecyleCompilerVersion}"
const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin}"
const val otpView = "com.github.mukeshsolanki:android-otpview-pinview:${Versions.otpViewVersion}"
const val appCompact = "androidx.appcompat:appcompat:${Versions.appCompactVersion}"
const val constraintLayout = "androidx.constraintlayout:constraintlayout:${Versions.constraintLayoutVersion}"
const val materialComponents = "com.google.android.material:material:${Versions.materialComponentsVersion}"
const val recyclerView = "androidx.recyclerview:recyclerview:${Versions.recyclerViewVersion}"
const val junit = "junit:junit:${Versions.junitVersion}"
const val testRunner = "androidx.test:runner:${Versions.testRunnerVersion}"
const val expressoCore = "androidx.test.espresso:espresso-core:${Versions.expressoCoreVersion}"
const val roomRuntime = "androidx.room:room-runtime:${Versions.roomRuntimeVersion}"
const val databindingCompiler = "androidx.databinding:databinding-compiler:${Versions.databindingCompilerVersion}"
const val rxjava = "io.reactivex.rxjava2:rxjava:${Versions.rxjavaVersion}"
const val rxjavaAndroid = "io.reactivex.rxjava2:rxandroid:${Versions.rxjavaAndroidVersion}"
const val glide = "com.github.bumptech.glide:glide:${Versions.glideVersion}"
const val glideCompiler = "com.github.bumptech.glide:compiler:${Versions.glideCompilerVersion}"
const val gson = "com.google.code.gson:gson:${Versions.gsonVersion}"
const val joda = "net.danlew:android.joda:${Versions.jodaVersion}"
const val countrycodePicker = "com.github.joielechong:countrycodepicker:${Versions.countrycodePickerVersion}"
const val timber = "com.jakewharton.timber:timber:${Versions.timberVersion}"
const val daggerandroidSupport = "com.google.dagger:dagger-android-support:${Versions.daggerandroidSupportVersion}"
const val daggerandroidProcessor = "com.google.dagger:dagger-android-processor:${Versions.daggerandroidProcessorVersion}"
const val slf4j = "org.slf4j:slf4j-api:${Versions.slf4jVersion}"
const val vectordrawableAnimated = "androidx.vectordrawable:vectordrawable-animated:${Versions.vectordrawableAnimatedVersion}"
const val sunmiui = "com.sunmi:sunmiui:${Versions.sunmiuiVersion}"
}
object Plugins
{
const val androidApplication = "com.android.application"
const val kotlinAndroid = "android"
const val kotlinExtensions = "android.extensions"
const val kapt = "kapt"
}
object ProGuards
{
val androidDefault = "proguard-rules.pro"
val proguardTxt = "proguard-android.txt"
}
object ClassPaths
{
const val gradlePlugin = "com.android.tools.build:gradle:3.4.1"
const val kotlinPlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31"
}
object Configs
{
const val applicationId = "eteetetet"
const val compileVersion = 28
const val minSdkVersion = 24
const val targetSdkVersion = 28
const val testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Мой build.gradle для модуля проекта выглядит следующим образом:
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath(ClassPaths.gradlePlugin)
classpath(ClassPaths.kotlinPlugin)
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
maven {
url = uri("https://maven.google.com")
}
maven { url = uri("https://jitpack.io") }
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
Мой файл settings.gradle.kts выглядит следующим образом:
include(":app",
":asterixclient",
":asterixtest",
":data",
":hardware",
":registrations",
":rewards",
":rules",
":rulescontracts",
":sdfclient",
":sdfservice",
":sunmiclient",
":sync",
":till",
":tsdevice",
":ui",
":webapi")
project(":asterixclient").projectDir =
File("../modules/sdfservice/asterixclient")
project(":asterixtest").projectDir =
File("../modules/sdfservice/asterixtest")
project(":data").projectDir = File("../modules/data/data")
project(":hardware").projectDir = File("../modules/hardware/hardware")
project(":registrations").projectDir = File("../modules/registrations/app")
project(":rewards").projectDir = File("../modules/rewards/rewards")
project(":rules").projectDir = File("../modules/rules/rules")
project(":rulescontracts").projectDir =
File("../modules/rules/rulescontracts")
project(":sdfclient").projectDir = File("../modules/sdfservice/sdfclient")
project(":sdfservice").projectDir = File("../modules/sdfservice/sdfservice")
project(":sunmiclient").projectDir =
File("../modules/sdfservice/sunmiclient")
project(":sync").projectDir = File("../modules/sync/sync")
project(":till").projectDir = File("../modules/till/till")
project(":tsdevice").projectDir = File("../modules/sdfservice/tsdevice")
project(":ui").projectDir = File("../modules/ui/ui")
project(":webapi").projectDir = File("../modules/webapi/webapi")