Unable to change configuration dependencies (after enabling instant start)

I just included instant run in my android studio project. (Follow the instructions here )

My project contains git submodules, and somehow they no longer compile.

This is the error I get:

Error: (8, 0) Cannot change the configuration dependencies ': 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.+' }} 

Build.gradle module:

 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 library

 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' } 
+47
android android-studio android-gradle gradle
Nov 23 '15 at 18:54
source share
8 answers

I had the same problem. I compared it with a (working) sample project from @RaGe and found a slight difference.

The subproject folder must begin with an uppercase letter.

Here is the change I made using @RaGes as an example to break it down and make it work again.

Broken structure:

 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 

leads to the following error:

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

Work structure (with upper case subproject)

 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 

the top level settings.gradle should also be changed:

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

and app/build.gradle should change this

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

Everything compiles

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

 git mv -f myApplication2 temp git mv -f temp MyApplication2 

to rename the folder.

+25
Jan 26 '16 at 12:13
source share

gradle reads and executes all build.gradle files in all folders of incoming modules. As the error shows, it is also trying to execute the root assembly script :libraries:my_library .

You must change your settings.gradle and enable the library project by setting it to "projectDir":

 include ':app' // Give your library project any module name, ie ':sdk' include ':sdk' // Then set the project path of the library module project(':sdk').projectDir = new File('libraries/my_library/sdk') 

With this settings.gradle you can reference the library project as gradle with:

 compile project(':sdk') 
+33
Apr 11 '16 at 9:31 on
source share

I had the same problem. I resolved it by deleting the classpath in the top-level file of the build.gradle submodule.

 dependencies { // classpath 'com.android.tools.build:gradle:1.0.0' } 

I'm not sure this is the best, but it worked for me.

+29
Nov 24 '15 at 15:03
source share

According to the official documentation for instant launch.

What happened behind the scenes is that we updated your build.Gradle project to use the latest version of the Android Gradle plugin that is needed for Instant Run to work. We are also updating the version of the Gradle wrapper to version 2.8 and are trying to update the version of the build tools in all of your modules to the latest version (23.0.2). This is not required for Instant Run, but it will use the new faster version of dex, which will help both instant start and full build to be a little faster.

The following is a snippet of the \ build.gradle application:

 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.0.0-alpha1' } } 

Known Issues with Instant Run

Using Instant Run with Reflection

Reflection can show unexpected things, for example:

  • All classes are published.
  • Many other things are also made public.

Performance Profiling Limitations

We suggest temporarily disabling Instant Run when profiling your debugging application.

When using Instant Run, there is very little impact on performance and a slightly larger impact when overriding methods.

Increased Application Methods

Instant Run adds some 140 methods plus three times the number of classes in your application and its local dependencies. If the application was previously just below the dex limit, enabling Instant Run may push your application to the dex limit. Learn how to fix this by optimizing Multi dex development builds.

Other known issues

  • Periodic problems can occur when the IDE loses connection with the application, which will result in a complete rebuild.
  • Third-party Gradle compatibility has not yet been tested, especially those that have not been updated to use the new transform APIs.
  • Data binding is currently broken in this assembly (recoverable).

, so if you encounter this problem, you can disable instant start

go to Settings β†’ Build, Run, Deploy β†’ Instant Launch and uncheck Enable Instant Launch ....

A better understanding of go instant launch here

+2
Jan 19 '16 at 16:23
source share

Extract your dependencies from your top level gradle build. Since you are creating a classpath with your top level gradle and then trying to overwrite it with your other build.gradles

From:

 buildscript { repositories { mavenCentral() jcenter() maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'com.android.tools.build:gradle:2.0.0-alpha6' classpath 'com.novoda:bintray-release:0.2.7' classpath 'io.fabric.tools:gradle:1.+' }} 

To: Note. I did not add this commented line, Android-Studio does it automatically

 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.0.0-alpha6' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } 

You should be able to add any necessary Maven repositories to your individual application gradients, as they must be specific, and jcenter will cover many of them, as @AndroidMechanic , and @Hi I Frogatto tried to say in previous answers and comments. Look here Bintray - JCenter

Another thing, I don’t understand why you manage your libraries by creating gradle in your project as part of your project. You must reference your library from your project using the build.gradle application. You treat the gradle library as a gradle application.

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

Make these changes, then see what duplicates, and you can manage it from there.

In addition, I recommend manually synchronizing the project with gradle files when making changes. I did not count on anything, it is important to take a step by step and analyze what is happening, especially when it will not be compiled. This is my opinion, only one way of programming in android.

If instant start creates chaos with a specific project, I will disable it for this project. It is enabled by default, and I had no problems with it. Damage to the assembly may be the result of fuzzy hail in your project.

also:

The gradle shell properties for classpath 'com.android.tools.build:gradle:2.0.0-alpha6' require class 2.10:

 distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 

Watch the latest news Android Tools project site

Or you can install the previous version of Android Studio and use the previous working version of your project.

If you have several git files, I suggest removing the extra ones, save only those that you use for version control.

+2
Jan 20 '16 at 9:06
source share

classpath 'com.android.tools.build: gradle: 2.0.0-alpha1'

try changing it to

  classpath 'com.android.tools.build:gradle:2.0.0-alpha6' 

alpha1 seems deprecated from today (?) and no longer compiles. You will also need to upgrade your gradle to the latest 2.10 to work with alpha6

0
Jan 19 '16 at 15:36
source share

Two things you can try

Change your plugin to "android"

With the new gradle tools, you need to specify the correct plugin for your gradle module, as well as the gradle library file. If you look closely, your gradle library file is correct: '

 apply plugin: 'com.android.library' 

Change the gradle module:

 apply plugin: "android" -> apply plugin: 'com.android.application' 
Classes

org.apache is now printed

It could also be a possible reason why your application no longer compiles. Remove this:

 useLibrary 'org.apache.http.legacy' 

See Deprecated List .

0
Jan 25 '16 at 8:01
source share

The build.gradle library project is causing a configuration error (due to some unclear reason). For me, this was enough to add a library project (which is a git submodule) to settings.gradle instead of adding a library project module.

Instead: include ':libraries:my_library:sdk'

try to include both the library subproject and the subproject module: include ':libraries:my_library' include ':libraries:my_library:sdk'

0
May 21 '16 at 14:07
source share



All Articles