相关疑难解决方法(0)

Android gradle build错误:(9,0)未找到Gradle DSL方法:'compile()'.

我尝试同步项目时遇到以下构建错误:

Error:(9, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'AlexTest' may be using a version of Gradle that does not contain the method.
The build file may be missing a Gradle plugin.
link: Apply Gradle plugin
Run Code Online (Sandbox Code Playgroud)

我已经尝试将他们链接到我的每一个gradle插件应用到底部的那个链接,但同样的问题,所以我得出结论,第一个错误是原因.

这是AlexTest的build.gradle文件(项目目录):

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.13.2'
        compile 'com.google.android.gms:play-services:6.1.11'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
} …
Run Code Online (Sandbox Code Playgroud)

android build gradle

58
推荐指数
2
解决办法
9万
查看次数

Android Studio 1.0.1添加外部库

我刚下载了Android Studio 1.0.1,这是新的项目结构

在此输入图像描述

当我在资源管理器中看到它时,有一个空的libs文件夹 在此输入图像描述

我想导入我想要使用的3个外部库.

build.gradle已经定义了这个

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
Run Code Online (Sandbox Code Playgroud)

但是当我在libs文件夹中复制我的库时,我的项目仍然不认识它,我如何利用libs文件夹并将我的库复制到这个文件夹中并使用它?任何帮助?

编辑:这是一个简单的问题,如何像在eclipse中那样在Android Studio中添加库,例如我有一个库项目(文件夹,而不是jar!).在我的情况下,我有一个库项目'viewPagerIndicator'(再次是一个库文件夹,而不是一个jar!)我必须将它添加到我的项目,就像我用eclipse通过导入项目,右键单击 - > properties-> android - >库 - > add->选择库项目

PS:我现在找到了答案.假设我的库项目名称为'viewPagerIndicator' - 在我的Android Studio项目的根目录下复制库项目 - 在build.gradle下(在您的Android Studio项目文件夹下)在依赖项下编写项目编译项目(':viewPagerIndicator') - 将其包含在设置中.gradle,write:include':viewPagerIndicator' - 使用gradle文件同步项目

这就是项目结构现在的样子:

在此输入图像描述

很抱歉,管理员在不理解的情况下停止了这个问题.

android libs android-studio

12
推荐指数
1
解决办法
4万
查看次数

标签 统计

android ×2

android-studio ×1

build ×1

gradle ×1

libs ×1