繁体   English   中英

如何修复android上地图应用程序的build.gradle

[英]how to fix build.gradle for map application on android

我正在开发一个基本的地图示例,但我在使用 android studio 时遇到了麻烦。

我收到此错误:

Error:(9, 0) Cause: startup failed:build file 'C:\Users\Tugrul\AndroidStudioProjects\ServiceTextSender\build.gradle': 9: expecting '}', found ':' @ line 9, column 31.
    compile ‘com.android.support:appcompat-v7:+’1 error

这里是我的 build.gradle 文件中的错误资源(依赖项:

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
    compile ‘com.android.support:appcompat-v7:+’
    compile ‘com.google.android.gms:play-services:3.1.36′

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

我怎样才能解决这个问题? 请问你能帮帮我吗? 我在使用 Android Studio 时遇到了麻烦。 我遇到了这个错误。

我认为你的问题是字符错误。 ' 和 ' 是不同的。 尝试改变这个:

classpath 'com.android.tools.build:gradle:1.3.0'
compile ‘com.android.support:appcompat-v7:+’
compile ‘com.google.android.gms:play-services:3.1.36′

对此

classpath 'com.android.tools.build:gradle:1.3.0'
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:3.1.36'

编辑:

这些是 gradle 文件:

你需要添加你的

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:3.1.36'
}

行到模块特定的 build.gradle 文件,如上所示。

关于错误:看起来您将此添加到错误的 gradle 文件中,应该添加到应用程序的 gradle 文件(应用程序文件夹中的那个),而不是模块(最上面的那个)。 顶部指定要使用的 gradle 插件,正如您在此处列出的那样,我假设您正在编辑错误的 build-gradle 文件。 如果您改为检查包含src 文件夹(不在src 内)的同一目录,您将找到应用程序的依赖项部分,您可以在其中添加该行。

和/或您只是使用错误的字符应该是'而不是'

建议的更简单的解决方案:在启动新项目时使用模板创建新的 Google 地图活动,或右键单击您的项目包并选择(在弹出菜单中):

New -> Google -> Google Maps Activity

一切都会为你准备好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM