我正在尝试将子模块导入到我的项目中,但它总是给出该错误。
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
Run Code Online (Sandbox Code Playgroud)
这些没有帮助
无法解析“: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')
}
}
Run Code Online (Sandbox Code Playgroud)
库梯度
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'
}
Run Code Online (Sandbox Code Playgroud)
我有
include ':app', ':libname'
Run Code Online (Sandbox Code Playgroud)
在设置 gradle 中
您有几个选择。
选项1)
通过文件菜单导入模块,让 Android 将其复制到您的根目录中并更新 Gradle 和 IDEA 文件等。
选项 2)
您可以通过相对路径导入它。并不总是推荐,但确实有效。当然,您必须认识到您的相对路径可能与其他开发人员不匹配,因此如果您决定走这条路线,存储库的文件夹结构匹配非常重要。
settings.gradle 应该包括
include 'app', ':Module 2'
project(':Module 2').projectDir = new File('../../YourPath/Project B/Module 2')
Run Code Online (Sandbox Code Playgroud)
然后在您应该包含的应用程序的 build.gradle 中
implementation project(':Module 2')
Run Code Online (Sandbox Code Playgroud)
公平警告,一些开发人员讨厌您这样做,但我认为在开发周期中保留最新的存储库的价值,当您发现问题时,该存储库可能仍在变化。所以在年轻的模块上有这样的情况。
选项 3)
使用 Gradle 从 Maven、jitpack 或 Ivy 存储库导入已编译的二进制文件。这假设您的模块已经成熟并且可以打包和使用。
| 归档时间: |
|
| 查看次数: |
9920 次 |
| 最近记录: |