2013-06-16 2 views
14

나는 정말로 여기에서 붙어 있습니다. 그래서, 나는 이것을 tutorial 단계별로 따르지만, 여전히 작동하지 않습니다.gradle 및 Google지도 v2가 포함 된 Android Studio

내가 튜토리얼의 모든 단계를 수행하고 발견 한 general->module에서 열린 run->edit 구성은 내가 GooglePlayServices이 표시되지 않는 경우, 나는이 문제 겠지,하지만 새로운 모듈 (GooglePlayServices)하지 모듈, 그럴 수 없어 그것을 고치기 위해해야 ​​할 일을 찾아라.

날 일찍 내가 같은 시도하지만,이 경우 모듈에 GooglePlayServices (나는 실제로 내가 무슨 짓을했는지 기억이 안나요) 내가 cannot resolve symbol 'maps'에 더 이상 문제가되지 않습니다,하지만 여전히 작동하지 않는 오류 Error inflating class fragment를 발생

내 활동은 튜토리얼처럼 두 경우 build.gradleFragmentActivity

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); 
    } 

} 

를 확장 :

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 
    } 
} 

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"/> 
+0

당신의 main.xml에 무엇입니까? –

+0

main.xml에는 Google 설명서의 조각이 있지만 MapFragment 대신 SupportMapFragment가 있습니다. 게시 할 코드를 추가하십시오. – Naitro

답변

16

.

난 그냥 내 Mac에서 안드로이드 스튜디오 0.2.3을 설치,이 날 신선한 안녕하세요 세계 프로젝트 템플릿에지도 조각을 볼 만든 단계는 다음과 같습니다 도구 모음에서 SDK 관리자 버튼을 클릭

1) Android Studio.

2) '부가 기능'에서 'Google play services'를 찾아 다운로드하십시오.) https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key

5 :

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

4) 주문이 튜토리얼 다음 귀하의 API 키를 설치하여 src 디렉토리에 build.gradle 파일에

3), 종속성이 줄을 추가 레이아웃에 조각을 추가하십시오. 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) 이제 장치에서 프로젝트를 실행할 수 있습니다. SDK 관리자에서

+2

이전 버전을 지원하는 경우 조각이 'com.google.android.gms.maps.SupportMapFragment' 여야합니다. – JJD

+0

감사합니다.이 도움이 – aashima

1

엑스트라에서 다음을 설치합니다

:

  • 안드로이드 지원 저장소
  • 구글 저장소는
  • 구글 서비스
  • 그런

build.gradle은 다음과 같아야합니다 플레이

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

dependencies { 
    //compile files('libs/android-support-v4.jar') 
    compile 'com.google.android.gms:play-services:3.1.36' 

} 

android { 
    compileSdkVersion 17 
    buildToolsVersion "17.0.0" 

    defaultConfig { 
     minSdkVersion 14 
     targetSdkVersion 14 
    } 
} 

이 줄을 주석으로 작성해야했습니다.Gradle을 :

이에
//compile files('libs/android-support-v4.jar') 

더 : https://plus.google.com/+AndroidDevelopers/posts/4Yhpn6p9icf

21

시도로 인해 패키지 크기로, 전체 구글 플레이 서비스 등이 multidex 수 있도록 당신을 강제 을 피하기 위해. 대신에, 개별적으로 포함 예 :

compile 'com.google.android.gms:play-services-maps:8.3.0' 

다른 서비스를 포함 할 경우, 여기를 참조하십시오

https://developers.google.com/android/guides/setup (아래로 스크롤)

+0

당신이 multidex를 사용하도록 강요했다면, 여기에 multidex 개발 속도를 높이는 방법에 대한 기사가 있습니다. http://stackoverflow.com/questions/30177495/gradle-android-studio-build-too-slow- 멀티 플렉스 애플리케이션 –

관련 문제