Cannot change dependencies of configuration (after enabling instant run)

后端 未结 8 2146
眼角桃花
眼角桃花 2020-12-08 04:05

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

My project contains git submodules and somehow th

相关标签:
8条回答
  • 2020-12-08 04:40

    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
        + myApplication2
        - .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
        + MyApplication2     // 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 sensitive by default. Use

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

    to rename the folder.

    0 讨论(0)
  • 2020-12-08 04:44

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

    You have to change your settings.gradle and include the library project by setting its 'projectDir':

    include ':app'
    
    // Give your library project any module name, i.e. ':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 dependency with:

    compile project(':sdk')
    
    0 讨论(0)
提交回复
热议问题