无法更改配置的依赖(采用即时运行后) [英] Cannot change dependencies of configuration (after enabling instant run)

查看:2877
本文介绍了无法更改配置的依赖(采用即时运行后)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚启用即时运行在我的Andr​​oid Studio项目。 (随后这里的指令)

我的项目包含混帐子模块,不管怎样,这些不要再编译。

这是错误我得到:


  

错误:(8,0)无法更改配置的依赖
  ':库:my_library:类路径。它已被解决后


任何想法可能是错误的呢?

顶级的build.gradle:

  buildscript {
库{
    mavenCentral()
    jcenter()
    行家{URLhttps://maven.fabric.io/public'}
}依赖{
    类路径'com.android.tools.build:gradle:2.0.0-alpha1
    类路径'com.novoda:bintray释放:0.2.7
    类路径'io.fabric.tools:gradle:1.+
}}

模块的build.gradle:

 应用插件:'机器人'
应用插件:'io.fabric安卓{    defaultConfig {
       版本code 4850
       的versionName'4850'
       compileSdkVersion 23
       buildToolsVersion '23 .0.1
    }    packagingOptions {
        排除META-INF / LICENSE
        排除META-INF / MANIFEST.MF
        排除META-INF /注意事项
    }    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }    useLibraryorg.apache.http.legacy
}库{
    mavenCentral()
    jcenter()
}
依赖{
    [跳跃]
    编制项目(':库:my_library:SDK)
}

图书馆的build.gradle

 应用插件:'com.android.library安卓{
    compileSdkVersion 23
    buildToolsVersion '23 .0.2    defaultConfig {
        14的minSdkVersion
        targetSdkVersion 23
    }    lintOptions {
        abortOnError假
    }
}库{
    mavenCentral()
}依赖{
    编译文件树(包括:的* .jar,导演:库)
    编译com.android.support:support-v4:23.1.0
    编译com.android.support:appcompat-v7:23.1.0    testCompile'的JUnit:JUnit的:4.12}


解决方案

我有同样的问题。我将它比作由@RaGe的(工作)示例项目,发现微小的差别。

的子项目文件夹中有开始一个大写字母。

下面是我做@RaGes样打破它,并把它再次合作的转变。<​​/ P>

破碎结构:

  Android的多项目样本
    + .gralde
    + .idea
    +应用
    +编译
    的gradle +
    + myAppliaction2
     - 的.gitignore
     - Android的多项目sample.iml
     - 的build.gradle
     - gradle.properties
     - gradlew
     - gradlew.bat
     - local.properties
     - settings.gradle

导致以下错误:

错误:(8,0)无法更改配置的依赖关系:myApplication2:类路径。它已被解决后

工作结构(以大写字母子项目)

  Android的多项目样本
    + .gralde
    + .idea
    +应用
    +编译
    的gradle +
    + MyAppliaction2 //大写!!!!!!
     - 的.gitignore
     - Android的多项目sample.iml
     - 的build.gradle
     - gradle.properties
     - gradlew
     - gradlew.bat
     - local.properties
     - settings.gradle

也是顶级 settings.gradle 已经被改变:

  +包括':应用',':MyApplication2:在MyLibrary
- 把':应用',':myApplication2:在MyLibrary

应用程序/的build.gradle 有可能改变这种

  +编制项目(':MyApplication2:在MyLibrary')
- 编制项目(':myApplication2:在MyLibrary')

一切编译

小心! Git是默认情况下不区分sesitive。使用

  git的MV -f myAppliaction2温度
Git的MV -f临时MyAppliaction2

重命名文件夹。

I just enabled instant run in my android studio project. (Followed the instructions here)

My project contains git submodules and somehow these do not compile anymore.

This is the error i get:

Error:(8, 0) Cannot change dependencies of configuration ':libraries:my_library:classpath' after it has been resolved.

Any idea what could be wrong there ?

Top level 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.+'
}}

Module 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')
}

Library 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'

}

解决方案

I had the same problem. I compared it to the (working) sample project by @RaGe and found the minor difference.

The sub project folder has to start with a Upper case letter.

Here is the change I did on @RaGes sample to break it and get it working again.

Broken structure:

android-multi-project-sample
    + .gralde
    + .idea
    + app
    + build
    + gradle
    + myAppliaction2
    - .gitignore
    - android-multi-project-sample.iml
    - build.gradle
    - gradle.properties
    - gradlew
    - gradlew.bat
    - local.properties
    - settings.gradle

results in the following error:

Error:(8, 0) Cannot change dependencies of configuration ':myApplication2:classpath' after it has been resolved.

Working structure (with upper case sub project)

android-multi-project-sample
    + .gralde
    + .idea
    + app
    + build
    + gradle
    + MyAppliaction2     // upper case!!!!!!
    - .gitignore
    - android-multi-project-sample.iml
    - build.gradle
    - gradle.properties
    - gradlew
    - gradlew.bat
    - local.properties
    - settings.gradle

also the top level settings.gradle has to be changed:

+ include ':app', ':MyApplication2:mylibrary'
- include ':app', ':myApplication2:mylibrary'

and app/build.gradle has to change this

+ compile project(':MyApplication2:mylibrary')
- compile project(':myApplication2:mylibrary')

Everything compiles

Be careful! Git is not case sesitive by default. Use

git mv -f myAppliaction2 temp
git mv -f temp MyAppliaction2

to rename the folder.

这篇关于无法更改配置的依赖(采用即时运行后)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆