本文介绍了该项目不是基于 Gradle 的项目.如何从根目录打开项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

这个问题我已经有一段时间了,一直在绞尽脑汁.

我用谷歌搜索了这个答案

感谢您的任何见解

Gradle 文件

//顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项.构建脚本{存储库{jcenter()}依赖{类路径 'com.android.tools.build:gradle:1.2.3'}}所有项目{存储库{jcenter()}}

应用级别:

buildscript {存储库{jcenter()MavenCentral()}依赖{类路径 'com.android.tools.build:gradle:1.2.3'类路径 'com.neenbedankt.gradle.plugins:android-apt:1.4'}}应用插件:'com.android.application'应用插件:'android-apt'def AAVersion = '4.0.0'def JacksonVersion = '2.6.0'def GPSVersion = '6.5.87'依赖{编译'com.android.support:appcompat-v7:23.0.0'编译'com.android.support:design:23.0.0'编译'com.android.support:recyclerview-v7:23.0.0'编译'com.android.support:preference-v7:23.0.0'}存储库{行家{网址https://repo.spring.io/libs-里程碑"}}适合{参数{androidManifestFile variant.outputs[0].processResources.manifestFile资源包名称应用程序名称"日志级别跟踪"logAppenderConsole '真'}}安卓 {compileSdkVersion 23构建工具版本22.0.1"默认配置{applicationId应用名称"minSdk 版本 14目标SDK版本23版本代码 1版本名称1.0"}构建类型{释放 {收缩资源错误minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}包装选项{排除 'META-INF/notice.txt'排除 'META-INF/license.txt'排除 'META-INF/ASL2.0'排除元信息/许可证"排除元信息/通知"}}所有项目{存储库{jcenter()MavenCentral()}}
解决方案

您的项目不是基于 Gradle,因为 settings.gradlebulid.gradle 不在 IDE 中项目目录,它们位于您图片中 .idea.gradle 下的黑色子文件夹中.

您必须关闭此项目.将该其他文件夹作为 Android Studio 项目打开,无论您从何处获得该项目.

对于 Github 中的库项目,它看起来像这样.任何人都可以按原样克隆它并作为项目打开.

对于应用程序,将 sample 替换为 app,并删除 library


最重要的是,buildscriptallprojects 部分不应该在 /app/build.gradle 中,只有 /build.gradle

此外,您的Gradle 构建插件已过时

I've been having this issue for a while and have been racking my brain.

I googled this answer here

Which the response is "Make sure you open the project from its root directory. i.e. the directory which contains the top level build.gradle file."

My question is: How the do I do that if I cloned the project from bitbucket?

Here's a screenshot of my file tree:

Thank you for any insights

Edit: Gradle files

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

allprojects {
    repositories {
        jcenter()
    }
}

app level:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '4.0.0'
def JacksonVersion = '2.6.0'
def GPSVersion = '6.5.87'

dependencies {
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:design:23.0.0'
    compile 'com.android.support:recyclerview-v7:23.0.0'
    compile 'com.android.support:preference-v7:23.0.0'
}

repositories {
    maven {
        url 'https://repo.spring.io/libs-milestone'
    }
}

apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName "appname"
        logLevel 'TRACE'
        logAppenderConsole 'true'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "appname"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            shrinkResources false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}
解决方案

Your project is not Gradle based because settings.gradle and bulid.gradle are not in the IDE project directory, they are in that blacked-out subfolder under .idea and .gradle in your picture.

You must close this project. Open that other folder as an Android Studio Project, regardless of where you got that project from.

For library projects in Github, it would look like this. Anyone can clone this as-is and open as a project.

For apps, replace sample with app, and remove library


Most importantly, buildscript and allprojects section should not be in /app/build.gradle, only /build.gradle

Additionally, your Gradle build plugin is outdated

这篇关于该项目不是基于 Gradle 的项目.如何从根目录打开项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 21:57