Missing top-level build.gradle in multi-module project

前端 未结 6 416
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 14:15

I\'m missing the \"Top-Level\" project build.gradle script from my project:

\"enter

相关标签:
6条回答
  • 2021-01-01 14:37
    1. close your project
    2. rename the project directory (in the workspace)
    3. open the project with the new name
    4. wait for gradle sync, build.gradle (project) should be added to the Gradle scripts
    5. close the project
    6. rename the project directory with the original name
    7. reopen the project with its good name
    8. wait gradle sync, the build.gradle should be here again...
    0 讨论(0)
  • 2021-01-01 14:40
    1. Close project.
    2. Remove ".idea\project_name.iml" (name are usually same as project folder).
    3. Remove reference to this file from ".idea\modules.xml".
    4. Open project.

    IDEA will re-create this file in projec's root folder instead of ".idea" and project-level "build.gradle" appears. This makes me think that better solution could be just moving this file outside ".idea" and correct reference in ".idea\modules.xml".

    0 讨论(0)
  • 2021-01-01 14:42

    You can just add build.gradle for root folder which contains gradle.properties and settings.gradle file

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.0.0'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    
    0 讨论(0)
  • 2021-01-01 14:43

    The following steps resolved the issue for me:

    1. Close project.
    2. Remove ".idea\project_name.iml" (name are usually same as project folder).
    3. Remove reference to this file from ".idea\modules.xml".
    4. Open project in IDE
    0 讨论(0)
  • 2021-01-01 14:50

    I had the same issue on my multi-module project, this solution worked for me.

    1. Closed all the open projects.
    2. Removed project from recent projects in "Welcome to Android Studio" window.
    3. Now click "Open existing android studio project" & browse to the project repo & select top level build.gradle.
    0 讨论(0)
  • 2021-01-01 14:56
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    
    }
    allprojects {
    repositories {
        jcenter()
    }
    }
    

    It really doesn't matter from my experience, what you need to do is make a build.gradle file, with your favorite .txt writer (make sure it says .gradle). If your root foldere app name is say "Archiver", then you put the gradle file where you see folders like app, .idea, gradle, e.t.c.

    One thing you have to keep in mind is that you may need to add a pointer to this gradle if your project can't find it for some reason.

    To make sure your project looks good, go to File >> Project Structure >> Module (and every other menu you feel you implemented). If you don't see any red x's then you may be good to go.

    0 讨论(0)
提交回复
热议问题