简体   繁体   English

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

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

I am developing a basic map example but I'm in trouble with android studio.我正在开发一个基本的地图示例,但我在使用 android studio 时遇到了麻烦。

I got this error :我收到此错误:

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

And here an error resource from my build.gradle file(dependencies :这里是我的 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
}

How can I fix this?我怎样才能解决这个问题? Could you help me please?请问你能帮帮我吗? I'm in trouble with Android Studio.我在使用 Android Studio 时遇到了麻烦。 I'm in trouble with this error.我遇到了这个错误。

I think your problem is character error.我认为你的问题是字符错误。 ' and ' are different. ' 和 ' 是不同的。 Try change this :尝试改变这个:

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′

to this对此

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'

Edit:编辑:

These are gradle Files:这些是 gradle 文件:

You need to add your你需要添加你的

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

lines to Module Specific build.gradle file shown as above.行到模块特定的 build.gradle 文件,如上所示。

Regarding the error: Looks like you are adding this to the wrong gradle file, should be added to the app's gradle file (the one in the app's folder), not the module (the top one).关于错误:看起来您将此添加到错误的 gradle 文件中,应该添加到应用程序的 gradle 文件(应用程序文件夹中的那个),而不是模块(最上面的那个)。 The top one specifies the gradle plugin to use and as you have it listed here, I'm assuming you are editing the wrong build-gradle file.顶部指定要使用的 gradle 插件,正如您在此处列出的那样,我假设您正在编辑错误的 build-gradle 文件。 If you instead check in the same directory that contains the src-folder ( not inside src) you will find the app's dependencies section where you can add that line.如果您改为检查包含src 文件夹(不在src 内)的同一目录,您将找到应用程序的依赖项部分,您可以在其中添加该行。

And/Or you are just using the wrong characters should be ' and not ' .和/或您只是使用错误的字符应该是'而不是'

Suggested easier solution: Create a new Google Map Activity using the template when starting a new project, or right click in your project package and choose (in the popup menu):建议的更简单的解决方案:在启动新项目时使用模板创建新的 Google 地图活动,或右键单击您的项目包并选择(在弹出菜单中):

New -> Google -> Google Maps Activity

And everything will be set up for you.一切都会为你准备好。

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

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