后端内部错误、AppModule dagger2 和 kotlin
Backend Internal error, AppModule dagger2 and kotlin
我在 MAC M1 上使用 Android studio 2021.1.1 时遇到问题!
我正在使用
kotlin 1.6.10
Java 1.8
dagger 2.25.2
使用多模块清理 arch 项目!
错误:
文件:
setting.gradle.kts 是:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
plugins {
id("com.android.application") version "7.1.1"
id("com.android.library") version "7.1.1"
id("org.jetbrains.kotlin.android") version "1.6.10"
id("org.jetbrains.kotlin.jvm") version "1.6.10"
id("org.jetbrains.kotlin.kapt") version "1.6.10-M1"
id("org.jetbrains.kotlin.plugin.parcelize") version "1.6.10-M1"
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "androidx.navigation.safeargs")
useModule("androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5")
if (requested.id.id == "com.google.gms.google-services")
useModule("com.google.gms:google-services:4.3.10")
}
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "xxxx"
include(":app")
include(":domain")
include(":data")
include(":presentaion")
include(":uikit")
build.gradle.kts 应用程序模块:
plugins {
id(AppConfig.androidApplication)
id(AppConfig.androidKotlin)
kotlin("kapt") version "1.3.70"
id(AppConfig.googleServicesPlugin)
}
android {
compileSdk = AppConfig.compileSdk
defaultConfig {
applicationId = AppConfig.applicationId
minSdk = AppConfig.minSdk
targetSdk = AppConfig.targetSdk
versionCode =
AppConfig.versionMajor * 100 + AppConfig.versionMinor * 10 + AppConfig.versionPatch
versionName =
"${AppConfig.versionMajor}.${AppConfig.versionMinor}.${AppConfig.versionPatch}"
multiDexEnabled = true
testInstrumentationRunner = AppConfig.androidTestInstrumentation
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
viewBinding {
android.buildFeatures.viewBinding = true
}
packagingOptions {
resources.excludes.add("META-INF/gradle/incremental.annotation.processors")
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kapt {
correctErrorTypes = true
generateStubs = true
}
kotlinOptions {
jvmTarget = "1.8"
}
configurations.forEach {
it.exclude("com.google.guava", "listenablefuture")
it.exclude(group = "org.jetbrains", module = "annotations")
}
}
dependencies {
implementation(project(mapOf("path" to ":data")))
api(project(mapOf("path" to ":domain")))
api(project(mapOf("path" to ":presentaion")))
implementation(AppDependencies.daggerLibraries)
implementation(AppDependencies.locationLibraries)
implementation(AppDependencies.appLibraries)
kapt(AppDependencies.compilerLibraries)
testImplementation(AppDependencies.testLibraries)
androidTestImplementation(AppDependencies.androidTestLibraries)
}
还有另一个 build.gradle 喜欢他们。
我能做什么?我花了 3 天时间阅读了很多链接,但帮不了我!我无法切换到刀柄。我应该将这个项目与这些方法一起使用。谢谢
我找到了我的解决方案:)))
从您的 build.gradle:
中删除它
configurations.forEach {
it.exclude("com.google.guava", "listenablefuture") it.exclude(group = "org.jetbrains", module = "annotations")
}
如果您使用 kotlin
,请像这样替换房间编译器 (kapt
),如果您使用 java
,请使用 annotaionProccor
:
实现(androidx.room:room-compiler:${Versions.roomVersion}
和
kapt("androidx.room:room-compiler:${Versions.roomVersion}")
我在 MAC M1 上使用 Android studio 2021.1.1 时遇到问题! 我正在使用
kotlin 1.6.10
Java 1.8
dagger 2.25.2
使用多模块清理 arch 项目!
错误:
文件:
setting.gradle.kts 是:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
plugins {
id("com.android.application") version "7.1.1"
id("com.android.library") version "7.1.1"
id("org.jetbrains.kotlin.android") version "1.6.10"
id("org.jetbrains.kotlin.jvm") version "1.6.10"
id("org.jetbrains.kotlin.kapt") version "1.6.10-M1"
id("org.jetbrains.kotlin.plugin.parcelize") version "1.6.10-M1"
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "androidx.navigation.safeargs")
useModule("androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5")
if (requested.id.id == "com.google.gms.google-services")
useModule("com.google.gms:google-services:4.3.10")
}
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "xxxx"
include(":app")
include(":domain")
include(":data")
include(":presentaion")
include(":uikit")
build.gradle.kts 应用程序模块:
plugins {
id(AppConfig.androidApplication)
id(AppConfig.androidKotlin)
kotlin("kapt") version "1.3.70"
id(AppConfig.googleServicesPlugin)
}
android {
compileSdk = AppConfig.compileSdk
defaultConfig {
applicationId = AppConfig.applicationId
minSdk = AppConfig.minSdk
targetSdk = AppConfig.targetSdk
versionCode =
AppConfig.versionMajor * 100 + AppConfig.versionMinor * 10 + AppConfig.versionPatch
versionName =
"${AppConfig.versionMajor}.${AppConfig.versionMinor}.${AppConfig.versionPatch}"
multiDexEnabled = true
testInstrumentationRunner = AppConfig.androidTestInstrumentation
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
viewBinding {
android.buildFeatures.viewBinding = true
}
packagingOptions {
resources.excludes.add("META-INF/gradle/incremental.annotation.processors")
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kapt {
correctErrorTypes = true
generateStubs = true
}
kotlinOptions {
jvmTarget = "1.8"
}
configurations.forEach {
it.exclude("com.google.guava", "listenablefuture")
it.exclude(group = "org.jetbrains", module = "annotations")
}
}
dependencies {
implementation(project(mapOf("path" to ":data")))
api(project(mapOf("path" to ":domain")))
api(project(mapOf("path" to ":presentaion")))
implementation(AppDependencies.daggerLibraries)
implementation(AppDependencies.locationLibraries)
implementation(AppDependencies.appLibraries)
kapt(AppDependencies.compilerLibraries)
testImplementation(AppDependencies.testLibraries)
androidTestImplementation(AppDependencies.androidTestLibraries)
}
还有另一个 build.gradle 喜欢他们。
我能做什么?我花了 3 天时间阅读了很多链接,但帮不了我!我无法切换到刀柄。我应该将这个项目与这些方法一起使用。谢谢
我找到了我的解决方案:)))
从您的
中删除它build.gradle:
configurations.forEach { it.exclude("com.google.guava", "listenablefuture") it.exclude(group = "org.jetbrains", module = "annotations")
}
如果您使用
kotlin
,请像这样替换房间编译器 (kapt
),如果您使用java
,请使用annotaionProccor
:
实现(androidx.room:room-compiler:${Versions.roomVersion}
和
kapt("androidx.room:room-compiler:${Versions.roomVersion}")