2016-09-15 3 views
0

Google지도 API 작업을 사용하는 첫 번째 Android 앱을 제작할 예정입니다. 그것은 에뮬레이터에서 잘 작동합니다. 그러나 중포 기지를 추가 한 후,이 에뮬레이터에 충돌 :Firebase와 통합 한 후 앱이 손상됩니다.

09-15 03:30:39.836 3541-3541/com.example.googlemapsapi E/AndroidRuntime: FATAL EXCEPTION: main 
    java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions 
    at com.google.firebase.FirebaseApp.zzek(Unknown Source) 
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source) 
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1058) 
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
    at android.app.ActivityThread.installProvider(ActivityThread.java:4560) 
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4190) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4132) 
    at android.app.ActivityThread.access$1300(ActivityThread.java:130) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:4745) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:511) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
    at dalvik.system.NativeStart.main(Native Method) 

나 ':

Unfortunately, MyApp has stopped 

검색을 많이 후, 나는 그것이 로그 캣을 확인하는 것이 유용 것으로 나타났습니다, 다음과 같은 예외를 보여줍니다 이러한 솔루션

그러나 문제는 여전히 존재합니다.

MapsActivity.java 파일 :

package com.example.googlemapsapi; 

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { 

    private GoogleMap mMap; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_maps); 
     // Obtain the SupportMapFragment and get notified when the map is ready to be used. 
     SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 
       .findFragmentById(R.id.map); 
     mapFragment.getMapAsync(this); 
    } 


    /** 
    * Manipulates the map once available. 
    * This callback is triggered when the map is ready to be used. 
    * This is where we can add markers or lines, add listeners or move the camera. In this case, 
    * we just add a marker near Sydney, Australia. 
    * If Google Play services is not installed on the device, the user will be prompted to install 
    * it inside the SupportMapFragment. This method will only be triggered once the user has 
    * installed Google Play services and returned to the app. 
    */ 
    @Override 
    public void onMapReady(GoogleMap googleMap) { 
     mMap = googleMap; 

     // Add a marker in Sydney and move the camera 
     /*LatLng sydney = new LatLng(-34, 151); 
     mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); 
     mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); 
    */ 
     LatLng busLocation = new LatLng(37.783879,-122.401254); 

     mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(busLocation, 12)); 
     mMap.addMarker(new MarkerOptions() 
       .position(busLocation) 
       .title("Code the Road Bus") 
       .icon(BitmapDescriptorFactory.fromResource(R.drawable.bus))); 

    } 
} 

build.gradle 파일 :

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

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.1.3' 
     classpath 'com.google.gms:google-services:3.0.0' 
     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

configurations { 
    all*.exclude group: 'com.android.support', module: 'support-v4' 
} 

응용 프로그램/build.gradle : 내가 잘못을

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.2" 

    defaultConfig { 
     applicationId "com.example.googlemapsapi" 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 

    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
/* 
    packagingOptions { 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE-FIREBASE.txt' 
     exclude 'META-INF/NOTICE' 

    } 
    */ 
} 
dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:24.2.0' 
    compile 'com.android.support:multidex:1.0.1' 
    compile 'com.google.android.gms:play-services:9.4.0' 
    compile 'com.google.firebase:firebase-core:9.4.0' 
    // compile 'com.firebase:firebase-client-android:2.5.2+' 
} 
apply plugin: 'com.google.gms.google-services' 

을 뭐하는 거지? 미리 감사드립니다. 사무엘 패럿

+0

는 설정/앱으로 이동 _Google 재생 클릭 서비스_. 버전 번호는 9.4.52입니까? –

+0

스택 트레이스의 각 행 시작 부분에 4 개의 공백을 추가하여 읽기 쉽도록하십시오. –

+0

@qbix 예, 그렇습니다. –

답변

1

재생 서비스를 업데이트하거나 실제 기기에서 사용해보십시오. 작동합니다. Check this.

1

갱신하여 플레이 서비스 LIB 프로젝트 클래스 경로입니다-클래스 경로 'com.google.gms : 구글 - 서비스 : 3.0.0' 및 의존성이 컴파일 'com.google.android.gms입니다 : Play의 서비스 : 9.4.0 ' 컴파일'com.google.firebase : 중포 기지 코어 : 9.4.0 '

그래서 업데이트하여 플레이 서비스 LIB 에뮬레이터에

+0

재생 서비스 라이브러리를 어떻게 업데이트 할 수 있습니까? Android sdk 관리자를 통해 Google Play 서비스를 업데이트하는 경우 이미 업데이트되었습니다. –

+0

업데이트 build.gradle 파일 : defaultConfig { ... 사실 multiDexEnabled } 종속 { 컴파일 'com.android.support:multidex:1.0.0' } –

관련 문제