Android的工作室摇篮找不到方法编译() [英] Android studio Gradle Could not find method compile()

查看:699
本文介绍了Android的工作室摇篮找不到方法编译()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两天我试图找到解决这个问题,但没有运气。

The past two days i have tried to find a solution to this problem but with no luck.

我想包括 GSON 库。到我的Andr​​oid项目。

I am trying to include GSON lib. Into my android project.

下面是我的文件夹结构的画面:

Here is a picture of my folder structure:

现在在我的build.gradle我有以下几点:

Now in my build.gradle i have the following:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

dependencies {
    compile files('libs/gson-2.2.4.jar')
}

我还右点击GSON-2.2.4.jar并添加它作为一个lib。

i have also right clicked gson-2.2.4.jar and added it as a lib.

当我编译出现以下错误:

When i compile i get the following error:

    Gradle: A problem occurred evaluating root project 'notebox-android'.
> Could not find method compile() for arguments [directory 'libs'] on root project 'notebox-android'.

谁能帮助我?

Can anyone help me with this?

请告诉我,如果你需要了解更多信息!

please tell me if you need more information!

推荐答案

在这个问题的答案可以帮助你正确地导入GSON库,并避免任何编译/链接问题:<一href="http://stackoverflow.com/questions/16779959/android-studio-importing-external-library-jar">Android工作室 - 导入外部库/罐。另一个相关链接: Android的工作室:添加的水瓶中库中公认的答案?这两个答案说同样的话。 gradlew干净后添加/导入的jar文件并编辑build.gradle文件。

The answer to this question might help you to import your gson library correctly and avoid any compile/link issues: Android Studio - Importing external Library/Jar. Another related link: Android Studio: Add jar as library? with accepted answer. Both answers say the same thing. gradlew clean after you add/import the jar file and edit the build.gradle file.

HTH。

编辑:有两个build.gradle文件。你应该编辑build.gradle这是在你的项目文件夹,而不是在你的项目的根文件夹中的之一。

There are two build.gradle files. You should be editing the build.gradle that's under your project folder and not the one under your project-root folder.

这篇关于Android的工作室摇篮找不到方法编译()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆