gpt4 book ai didi

android - 无法将子模块添加到android项目

转载 作者:搜寻专家 更新时间:2023-11-01 09:22:59 24 4
gpt4 key购买 nike

我正在尝试将我的子模块导入到我的项目中,但它总是会出现该错误。

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :sanservicelibrary.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :sanservicelibrary.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :sanservicelibrary.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :sanservicelibrary.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :sanservicelibrary.
Open File
Show Details

这些都没有帮助

Cant compile project with modules

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath', :app@debugAndroidTest/compileClasspath

应用程序等级。

apply plugin: 'com.android.application'

android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

compileSdkVersion 27
defaultConfig {
applicationId ".."
minSdkVersion 18
targetSdkVersion 27
versionCode 13
versionName "Beta 1.11"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:design:$supportLibVer"
implementation "com.android.support:appcompat-v7:$supportLibVer"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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 project(path:':libname', configuration: 'default')

}


}

库渐变

apply plugin: 'com.android.library'

android {
compileSdkVersion 28
defaultConfig {
applicationId "..."
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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:28.0.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'
}

我有

include ':app', ':libname'

在设置gradle中

最佳答案

您有几个选择。

选项 1)

通过文件菜单导入模块,让 Android 将其复制到您的根目录并更新 Gradle 和 IDEA 文件等。

选项 2)

可以通过相对路径导入。并不总是推荐,但可以解决问题。当然,您必须认识到您的相对路径可能与您的开发伙伴不匹配,因此如果您决定走这条路,则存储库的文件夹结构匹配很重要。

settings.gradle 应该包括

include 'app', ':Module 2'
project(':Module 2').projectDir = new File('../../YourPath/Project B/Module 2')

然后在您应该包含的应用程序的 build.gradle 中

implementation project(':Module 2')

公平警告,一些开发人员讨厌您这样做,但我个人看到了在开发周期中保持最新的 repo 的值(value),当您发现问题时,该 repo 可能仍在更改。所以在年轻的模块上有一个案例。

选项 3)

使用 Gradle 从 Maven、jitpack 或 Ivy 存储库导入已编译的二进制文件。这假设您的模块已经成熟并且可以打包和使用。

关于android - 无法将子模块添加到android项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53083669/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com