Android的工作室摇篮和谷歌地图V2摇篮、工作室、地图、Android

2023-09-07 08:37:40 作者:淡忘你的爱

我真的被困在这里。于是,我按照这个教程通过一步一步:但它仍然无法正常工作

我所做的教程中的所有步骤,并找出新的模块(GooglePlayServices)不在模块,如果打开运行 - >编辑配置,常规 - >模块我没有看到 GooglePlayServices ,我想这就是问题所在,但我找不到我有什么做来解决它。

提前一天我试过相同的,但在这种情况下,(其实我不记得我就是这样做) GooglePlayServices 模块和我没有了问题无法解析符号'地图',但它仍然无法正常工作,激发误差错误充气类片段

我的活动来延长 FragmentActivity

 进口android.os.Bundle;
进口android.support.v4.app.FragmentActivity;

公共类MainActivity扩展FragmentActivity {

    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);
    }

}
 

在这两种情况下, build.gradle 就像在教程:

  buildscript {
    库{
        mavenCentral()
    }
    依赖{
        类路径com.android.tools.build:gradle:0.4
    }
}
应用插件:'机器人'

依赖{
    编译文件(库/ Android的支持 -  v4.jar)
    编制项目(:GooglePlayServices)
}

安卓{
    compileSdkVersion 17
    buildToolsVersion17.0.0

    defaultConfig {
        的minSdkVersion 9
        targetSdkVersion 17
    }
}
 

settings.gradle

 包括:Roadatus',':GooglePlayServices
 
谷歌地图推出新功能 显示共享单车位置及数量

main.xml中:

 < XML版本=1.0编码=UTF-8&GT?;
<片段的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
          机器人:ID =@ + ID /图
          机器人:layout_width =match_parent
          机器人:layout_height =match_parent
          机器人:名称=com.google.android.gms.maps.SupportMapFragment/>
 

解决方案

我试图和这个失败了很多的教程,但最后找到一个简单的解决方案,似乎工作。

我刚刚安装的Andr​​oid 0.2.3工作室在我的Mac,而这些都是让我查看新的Hello World项目模板的地图碎片的步骤:

1)单击工具栏上的Andr​​oid工作室在SDK管理器按钮。

2)在'附加'定位'谷歌播放服务并下载。

3)在你的src目录下的build.gradle文件,这一行添加到依赖性:

 编译com.google.android.gms:玩-服务:3.1.36
 

4)订购并安装你的API密钥下面这个教程:https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key

5)的片段添加到您的布局XML:

 <片段的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
          机器人:ID =@ + ID /图
          机器人:layout_width =match_parent
          机器人:layout_height =match_parent
          机器人:名称=com.google.android.gms.maps.MapFragment/>
 

6)你现在应该能够在设备上运行项目。

I'm really stuck here. So, I follow this tutorial step by step: but it still doesn't work.

I've done all steps from tutorial and find out what new module(GooglePlayServices) not in modules, if open run->edit configurations in general->module i don't see GooglePlayServices, I suppose this is the problem, but I can't find what I have to do to fix it.

Day early I tried same, but in this case (I actually don't remember what I did) GooglePlayServices in modules and I don't have anymore problem with cannot resolve symbol 'maps', but it still doesn't work, fires error Error inflating class fragment

my activity extends FragmentActivity

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class MainActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

}

in both case build.gradle just like in tutorial:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
    compile project(':GooglePlayServices')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 17
    }
}

and settings.gradle:

include ':Roadatus', ':GooglePlayServices'

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.SupportMapFragment"/>

解决方案

I have tried and failed many a tutorial on this, but finally find a simple solution that seem to work.

I just installed Android Studio 0.2.3 on my mac, and these are the steps that made me view a maps fragment on a fresh hello world project template:

1) Click the SDK manager button in the toolbar in Android Studio.

2) Under 'Extras' locate 'Google play services' and download it.

3) in your build.gradle file in your src directory, add this line to dependencies:

compile 'com.google.android.gms:play-services:3.1.36'

4) order and install your API-key following this tutorial: https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key

5) add the fragment to your layout xml:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.MapFragment"/>

6) you should now be able to run your project on your device.