我被这个问题困扰有一段时间了,绞尽脑汁。
我用谷歌搜索了这个答案here https://stackoverflow.com/questions/23752077/no-gradle-file-shown-while-importing-project-in-android-studio-0-5-2
响应是“确保从根目录打开项目。即包含顶级 build.gradle 文件的目录。”
我的问题是:如果我从 bitbucket 克隆项目,我该怎么做?
Here's a screenshot of my file tree:
感谢您的任何见解
编辑:Gradle 文件
// 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()
}
}
应用级别:
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()
}
}
您的项目不是基于 Gradle 的,因为settings.gradle
and bulid.gradle
不在 IDE 项目目录中,它们位于下面的黑色子文件夹中.idea
and .gradle
在你的照片中。
您必须关闭该项目。打开那个其他文件夹作为 Android Studio 项目,无论您从哪里获得该项目。
对于 Github 中的库项目,它看起来像这样。任何人都可以按原样克隆它并作为项目打开。
对于应用程序,替换sample
with app
,并删除library
最重要的是,buildscript
and allprojects
部分不应位于/app/build.gradle
, only /build.gradle
此外,您的Gradle 构建插件已过时 https://developer.android.com/studio/releases/gradle-plugin
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)