2

ここからの指示に従いましたhttps://firebase.google.com/docs/android/setup

Android アプリケーションは正常にコンパイルされましたが、デバイスにインストールするとすぐにクラッシュして、

07-07 12:42:43.534  5450  5450 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.NullPointerException: Application context cannot be null.
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.app.ActivityThread.installProvider(ActivityThread.java:5177)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4769)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4709)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.app.ActivityThread.-wrap1(ActivityThread.java)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1415)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:102)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:148)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:5443)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-07 12:42:43.534  5450  5450 E AndroidRuntime: Caused by: java.lang.NullPointerException: Application context cannot be null.
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at com.google.android.gms.common.internal.zzaa.zzb(Unknown Source)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    at android.app.ActivityThread.installProvider(ActivityThread.java:5174)
07-07 12:42:43.534  5450  5450 E AndroidRuntime:    

... 10以上

このUnable to get provider com.google.firebase.provider.FirebaseInitProviderで解決策を試しましたが、これは役に立ちませんでした。

google-gms 依存関係を追加し、google-services.json を app/ に追加しました

これは私の app/build.gradle です

apply plugin: 'com.android.application'

Repositories{
    mavenCentral()
}

android {
  project.archivesBaseName = "x_mno";

  useLibrary 'org.apache.http.legacy'
  compileSdkVersion 23
  buildToolsVersion "22.0.1"
  enforceUniquePackageName=false

  sourceSets {
     main {
         manifest.srcFile 'AndroidManifest.xml'
         res.srcDirs = ['res']
        java.srcDirs = ['src']
        aidl.srcDirs = ['src']
     }
  }
 defaultConfig {
     applicationId "com.example.ccc.mno"
     minSdkVersion 23
     targetSdkVersion 23
     multiDexEnabled true
 }
  packagingOptions {
     exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
 }
 lintOptions {
       abortOnError false
 }
 }
configurations {
}

dependencies {
  compile group: 'com.google.android.gms', name: 'play-services', version: '9.0.2'
  compile group: 'com.android.support', name: 'support-v4', version: '23.0'
  //aded this
  compile 'com.google.firebase:firebase-core:9.0.1'
}

//aded this
apply plugin: 'com.google.gms.google-services'

これは私のルートレベルのbuild.gradleです:

buildscript {
repositories {
   mavenCentral()
}

dependencies {
   classpath 'com.android.tools.build:gradle:1.+'
   // added this
   classpath 'com.google.gms:google-services:3.0.0'

} }

4

0 に答える 0