无法更改配置的依赖项(启用即时运行后) [英] Cannot change dependencies of configuration (after enabling instant run)
问题描述
我刚刚在我的 android studio 项目中启用了 instant run
.(按照此处的说明)
I just enabled instant run
in my android studio project. (Followed the instructions here)
我的项目包含 git
子模块,但不知何故它们不再编译.
My project contains git
submodules and somehow these do not compile anymore.
这是我得到的错误:
错误:(8, 0) 无法更改配置的依赖项':libraries:my_library:classpath' 解决后.
Error:(8, 0) Cannot change dependencies of configuration ':libraries:my_library:classpath' after it has been resolved.
知道那里有什么问题吗?
Any idea what could be wrong there ?
顶级 build.gradle:
buildscript {
repositories {
mavenCentral()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
classpath 'com.novoda:bintray-release:0.2.7'
classpath 'io.fabric.tools:gradle:1.+'
}}
模块 build.gradle:
apply plugin: 'android'
apply plugin: 'io.fabric'
android {
defaultConfig {
versionCode 4850
versionName '4850'
compileSdkVersion 23
buildToolsVersion '23.0.1'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/MANIFEST.MF'
exclude 'META-INF/NOTICE'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
useLibrary 'org.apache.http.legacy'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
[skip]
compile project(':libraries:my_library:sdk')
}
库 build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
}
lintOptions {
abortOnError false
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
testCompile 'junit:junit:4.12'
}
推荐答案
我遇到了同样的问题.我将它与@RaGe 的 (工作)示例项目 进行了比较,发现了次要区别.
I had the same problem. I compared it to the (working) sample project by @RaGe and found the minor difference.
子项目文件夹必须以大写字母开头.
这是我对@RaGes 示例所做的更改,以破坏它并使其重新工作.
Here is the change I did on @RaGes sample to break it and get it working again.
破碎的结构:
android-multi-project-sample
+ .gralde
+ .idea
+ app
+ build
+ gradle
+ myApplication2
- .gitignore
- android-multi-project-sample.iml
- build.gradle
- gradle.properties
- gradlew
- gradlew.bat
- local.properties
- settings.gradle
导致以下错误:
错误:(8, 0) 无法更改配置:myApplication2:classpath"的依赖项,解决后无法更改.
工作结构(带大写子项目)
Working structure (with upper case sub project)
android-multi-project-sample
+ .gralde
+ .idea
+ app
+ build
+ gradle
+ MyApplication2 // upper case!!!!!!
- .gitignore
- android-multi-project-sample.iml
- build.gradle
- gradle.properties
- gradlew
- gradlew.bat
- local.properties
- settings.gradle
还必须更改顶级settings.gradle
:
+ include ':app', ':MyApplication2:mylibrary'
- include ':app', ':myApplication2:mylibrary'
和 app/build.gradle
必须改变这个
+ compile project(':MyApplication2:mylibrary')
- compile project(':myApplication2:mylibrary')
一切正常
小心!默认情况下,Git 不区分大小写.使用
Be careful! Git is not case sensitive by default. Use
git mv -f myApplication2 temp
git mv -f temp MyApplication2
重命名文件夹.
这篇关于无法更改配置的依赖项(启用即时运行后)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!