FirebaseInitProvider Crash

瀏覽次數:822 次
跳到第一則未讀訊息

Elias O. R.

未讀,
2016年9月5日 中午12:16:092016/9/5
收件者:Firebase Google Group
Hi !

I'm trying to use Firebase Messaging to get Push notifications,

I followed the tutorials in Firebase web, but It crash when I try to run the app.

The log file loos like:

E/AndroidRuntime: FATAL EXCEPTION: main
                 
Process: es.in2.otr.app.im, PID: 12048
                  java
.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.res.Resources.getResourcePackageName(int)' on a null object reference
                      at android
.app.ActivityThread.installProvider(ActivityThread.java:6770)
                      at android
.app.ActivityThread.installContentProviders(ActivityThread.java:6362)
                      at android
.app.ActivityThread.handleBindApplication(ActivityThread.java:6302)
                      at android
.app.ActivityThread.access$1800(ActivityThread.java:222)
                      at android
.app.ActivityThread$H.handleMessage(ActivityThread.java:1861)
                      at android
.os.Handler.dispatchMessage(Handler.java:102)
                      at android
.os.Looper.loop(Looper.java:158)
                      at android
.app.ActivityThread.main(ActivityThread.java:7229)
                      at java
.lang.reflect.Method.invoke(Native Method)
                      at com
.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                      at com
.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
                   
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.res.Resources.getResourcePackageName(int)' on a null object reference
                      at com
.google.android.gms.common.internal.zzai.<init>(Unknown Source)
                      at com
.google.firebase.FirebaseOptions.fromResource(Unknown Source)
                      at com
.google.firebase.FirebaseApp.zzek(Unknown Source)
                      at com
.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
                      at android
.content.ContentProvider.attachInfo(ContentProvider.java:1789)
                      at android
.content.ContentProvider.attachInfo(ContentProvider.java:1764)
                      at com
.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
                      at android
.app.ActivityThread.installProvider(ActivityThread.java:6767)
                      at android
.app.ActivityThread.installContentProviders(ActivityThread.java:6362)
                      at android
.app.ActivityThread.handleBindApplication(ActivityThread.java:6302)
                      at android
.app.ActivityThread.access$1800(ActivityThread.java:222)
                      at android
.app.ActivityThread$H.handleMessage(ActivityThread.java:1861)
                      at android
.os.Handler.dispatchMessage(Handler.java:102)
                      at android
.os.Looper.loop(Looper.java:158)
                      at android
.app.ActivityThread.main(ActivityThread.java:7229)
                      at java
.lang.reflect.Method.invoke(Native Method)
                      at com
.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                      at com
.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

What I have is:

build.gradle (top-level):

dependencies {
 classpath
'com.android.tools.build:gradle:2.2.0-rc1'
 classpath
'com.google.gms:google-services:3.0.0'


buidl.gradle (module-level):

...

compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
 applicationId
'es.in2.otr.app.im'
 minSdkVersion
16
 targetSdkVersion
24
 multiDexEnabled
true}



dependencies
{
 compile fileTree
(include: ['*.jar'], dir: 'libs')
 
...
 compile
'com.google.firebase:firebase-messaging:9.4.0'
 
....
 
}
apply plugin
: 'com.google.gms.google-services'


For some who will ask, YES I have the applicationId in the file.

Is there any solutuion for this problem?

P.S: Yes , I tried to use version of firebase 9.0.0 / 9.0.2

Thanks!

Doug Stevenson

未讀,
2016年9月5日 下午5:19:132016/9/5
收件者:Firebase Google Group
Elias,

Is any comment from this issue in Stack Overflow helpful?  It looks like the same stack trace.

Doug

Elias O. R.

未讀,
2016年9月7日 上午10:31:502016/9/7
收件者:Firebase Google Group
Sorry for delay, I was on Holidays.

But no, there's no way to fix it.

I take a look to the famous "You got the applicationId? -> YES I got it."
I put the 2 SHA1 (debug, and release) on the firebase console, and downloaded again the json file.
I'm tested the 9.0.0 /9.2.0/9.4.0 versions of firebase-messaging.


And always is the same error.

Doug Stevenson

未讀,
2016年9月7日 下午3:39:262016/9/7
收件者:fireba...@googlegroups.com
Elias, can you show your entire build.gradle, or at least all the dependencies you're referencing?  I am also curious what happens if you put in *only* the firebase-core dependency with google-services.json without coding to any specific Firebase feature.

Doug

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/nJOPNXSrmyY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/635bed74-2a81-4768-b02e-62fce5fdd6cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Elias O. R.

未讀,
2016年9月8日 上午10:58:552016/9/8
收件者:Firebase Google Group

Hi Doug,

Here is the 2 build gradle files:

Top-Level

// 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.2.0-rc1'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.g radle files
    }
}

allprojects
{
    repositories
{
        jcenter
()
   
}
}

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

App-Module:


apply plugin: 'com.android.application'
import java.util.regex.Pattern

android
{
    signingConfigs
{

   
}
    compileSdkVersion
24
    buildToolsVersion "24.0.2"

    defaultConfig {

        applicationId
'es.XXX.XXX.XXX.XXX'

        //applicationId  = doExtractStringFromManifest("package")
        minSdkVersion 16
        targetSdkVersion 24
        useLibrary 'org.apache.http.legacy'
        multiDexEnabled true

        testApplicationId "es.XXX.XXX.XXX.XXX.test"
        testInstrumentationRunner "android.test.InstrumentationTestRunner"
    }

    dexOptions
{
        javaMaxHeapSize
"4g" //specify the heap size for the dex process
    }
    lintOptions
{
        checkReleaseBuilds
false
        abortOnError false
    }
    buildTypes
{
        release
{
            minifyEnabled
false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
   
}
    packagingOptions
{
        exclude
'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

dependencies
{
    compile fileTree
(include: ['*.jar'], dir: 'libs')

    compile project
(':androidEmojiInput')
    compile project
(':cachewordlib')
    compile project
(':viewPagerIndicator')
    compile project
(':tibetanTextLibrary')
    compile project
(':memorizingTrustManagermaster')
    compile project
(':slidingMenu')
    compile project
(':volley')

    compile
'com.google.firebase:firebase-messaging:9.4.0'



    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okio:okio:1.9.0'   /*Used for OKHTTP*/

    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.android.support:support-v13:24.2.0'
    compile 'com.android.support:recyclerview-v7:24.2.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.github.navasmdc:MaterialDesign:1.+@aar'
    compile 'com.android.support:cardview-v7:24.2.0'
    compile 'com.bignerdranch.android:expandablerecyclerview:2.1.1'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
    compile 'com.rengwuxian.materialedittext:library:1.8.3'
    compile 'com.github.hotchemi:permissionsdispatcher:2.0.8'

    compile 'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0'

    compile('com.github.justzak:dilatingdotsprogressbar:1.0.1') {
        exclude
group: 'com.android.support', module: 'appcompat-v7'
    }
}

apply
plugin: 'com.google.gms.google-services'


def doExtractStringFromManifest(name) {
   
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
   
def pattern = Pattern.compile(name + "=\"(\\S+)\"")
   
def matcher = pattern.matcher(manifestFile.getText())
    matcher
.find()
   
return matcher.group(1)
}


As you can see I only import de firebase-messaging:9.4.0 library. I don't have any code , no service... etc referencing the library,

JSon File is under app module:



And the content of the google-services.json is:

{
 
"project_info": {
   
"project_number": "283882435243",
   
"firebase_url": "https://XXX-4c159.firebaseio.com",
   
"project_id": "XXX-4c159",
   
"storage_bucket": "XXX-4c159.appspot.com"
 
},
 
"client": [
   
{
     
"client_info": {
       
"mobilesdk_app_id": "1:283882435243:android:632a71ea9a8c9b21",
       
"android_client_info": {
         
"package_name": "es.in2.otr.app.im"
       
}
     
},
     
"oauth_client": [
       
{
         
"client_id": "283882435243-XXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com",
         
"client_type": 1,
         
"android_info": {
           
"package_name": "es.in2.otr.app.im",
           
"certificate_hash": "BBF36F4B768DB90A430982C473638B72A4A7B204"
         
}
       
},
       
{
         
"client_id": "283882435243-XXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com",
         
"client_type": 1,
         
"android_info": {
           
"package_name": "es.in2.otr.app.im",
           
"certificate_hash": "A0BEF12A8F196B4C900F3CF2CBC037F0E7ED6FAA"
         
}
       
},
       
{
         
"client_id": "283882435243-XXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com",
         
"client_type": 3
       
}
     
],
     
"api_key": [
       
{
         
"current_key": "AIzaXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXUTM"
       
}
     
],
     
"services": {
       
"analytics_service": {
         
"status": 1
       
},
       
"appinvite_service": {
         
"status": 2,
         
"other_platform_oauth_client": [
           
{
             
"client_id": "283882435243-XXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com",
             
"client_type": 3
           
}
         
]
       
},
       
"ads_service": {
         
"status": 2
       
}
     
}
   
}
 
],
 
"configuration_version": "1"
}

At least In the Firebase console I have set the 2 SHA1 fingerprints:




Finally as I said before, I dont have any type of code or service declarated on Manifest, just the import of the library. And here is the log file:

09-08 09:10:16.150 2899-2899/es.in2.otr.app.im E/AndroidRuntime: FATAL EXCEPTION: main
                                                                 
Process: es.in2.otr.app.im, PID: 2899

                                                                 java
.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.res.Resources.getResourcePackageName(int)' on a null object
reference
                                                                     at android
.app.ActivityThread.installProvider(ActivityThread.java:5002)
                                                                     at android
.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
                                                                     at android
.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
                                                                     at android
.app.ActivityThread.access$1500(ActivityThread.java:151)
                                                                     at android
.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                                                                     at android
.os.Handler.dispatchMessage(Handler.java:102)
                                                                     at android
.os.Looper.loop(Looper.java:135)
                                                                     at android
.app.ActivityThread.main(ActivityThread.java:5254)
                                                                     at java
.lang.reflect.Method.invoke(Native Method)
                                                                     at java
.lang.reflect.Method.invoke(Method.java:372)
                                                                     at com
.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                                     at com
.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

                                                                 
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.res.Resources.getResourcePackageName(int)' on a null object reference
                                                                     at com
.google.android.gms.common.internal.zzai.<init>(Unknown Source)
                                                                     at com
.google.firebase.FirebaseOptions.fromResource(Unknown Source)
                                                                     at com
.google.firebase.FirebaseApp.zzek(Unknown Source)
                                                                     at com
.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)

                                                                     at android
.content.ContentProvider.attachInfo(ContentProvider.java:1696)
                                                                     at android
.content.ContentProvider.attachInfo(ContentProvider.java:1671)
                                                                     at com
.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
                                                                     at android
.app.ActivityThread.installProvider(ActivityThread.java:4999)
                                                                     at android
.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
                                                                     at android
.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
                                                                     at android
.app.ActivityThread.access$1500(ActivityThread.java:151)
                                                                     at android
.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                                                                     at android
.os.Handler.dispatchMessage(Handler.java:102)
                                                                     at android
.os.Looper.loop(Looper.java:135)
                                                                     at android
.app.ActivityThread.main(ActivityThread.java:5254)
                                                                     at java
.lang.reflect.Method.invoke(Native Method)
                                                                     at java
.lang.reflect.Method.invoke(Method.java:372)
                                                                     at com
.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                                     at com
.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

And just as "bonus track", I f dont compile any firebase library, I got the same problem.

Wel.. thats all..

I'm really stucked  on this :/


Thanks for all
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.
Auto Generated Inline Image 1
Auto Generated Inline Image 2

Doug Stevenson

未讀,
2016年9月8日 中午12:47:472016/9/8
收件者:fireba...@googlegroups.com
Thanks for the info - your build.gradle looks good to me.  I don't think the dependency on Firebase messaging is having any effect on your app.  The google services plugin actually adds a core Firebase dependency to your app whether or not you declare any dependencies.  You can see that if you run ./gradlew androidDependencies to see everything that gets added to your app from any source.

Could you try one more thing?  Manually add the dependency "com.google.firebase:firebase-core:9.4.0" to your app to make sure it's at the latest version (in case the plugin didn't add that correctly for some reason).  The crash is happening in a ContentProvider that comes from firebase-core, and this gets invoked as soon as your app launches.

If that doesn't help, there are two things left:

1. Start with a bare project, add Firebase, and see if it launches OK.  Then gradually add in your other dependencies to see if anything interferes.  We need to identify the *minimal* conditions where this is happening for you.  There could be a conflict in one of your other dependencies.
2. If that doesn't yield any information, please log all this information in a bug report at https://firebase.google.com/support/contact/bugs-features/ and be sure to add a link to this conversation as a reference.  We'll make sure this gets routed to the right people.  But the most important thing is that we have a situation that we can reproduce on our own.

Thanks so much for sticking with this.  :-)

Doug


To unsubscribe from this group and all its topics, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Elias O. R.

未讀,
2016年9月12日 清晨6:30:532016/9/12
收件者:Firebase Google Group
Hi Doug,

Finally I have done all the test you said, here is how it went:


ON ORIGINAL PROJECT
TEST
1:

    compile
'com.google.firebase:firebase-core:9.4.0' --> FAIL: same error

NEW PROJECT TO TEST POSSIBLE CRASHING LIBRARY
:

TEST
2:Add basic library

    classpath
in toplevel, and apply plugin in applevel --> OK

TEST
3: add library

    compile
'com.android.support:support-v4:24.2.0' --> OK

TEST
4: add library

    compile
'com.android.support:support-v13:24.2.0' --> OK

TEST
5: add library

    compile
'com.android.support:recyclerview-v7:24.2.0' --> OK

TEST
6: add library

    compile
'com.android.support:multidex:1.0.1' --> OK

TEST
7: add multidex option to gradle

     multiDexEnabled
true --> OK

TEST
8: add library

    compile
'com.android.support:cardview-v7:24.2.0' --> OK

TEST
9: add library

    compile
'com.google.code.gson:gson:2.6.2' --> OK

TEST
10: add library

    compile
'com.squareup.okio:okio:1.9.0' --> OK

TEST
11: add library

    compile
'com.squareup.okhttp3:okhttp:3.4.1' --> OK

TEST
12: add library

    compile
'com.github.navasmdc:MaterialDesign:1.+@aar' --> OK

TEST
13: add library

    compile
'com.bignerdranch.android:expandablerecyclerview:2.1.1' --> OK

TEST
14: add library

    compile
'com.melnykov:floatingactionbutton:1.3.0' --> OK

TEST
15: add library

    compile
'com.rengwuxian.materialedittext:library:1.8.3' --> OK

TEST
17: add library

   
    compile
'com.github.hotchemi:permissionsdispatcher:2.0.8' --> OK

TEST
18: add library

    compile
'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0' --> OK

TEST
19: add library

    compile
('com.github.justzak:dilatingdotsprogressbar:1.0.1') {

        exclude
group: 'com.android.support', module: 'appcompat-v7'

   
} --> OK

(IN SETTINGS.GRADLE TOP-LEVEL)
TEST
20: added modules

    include
':app', ':androidEmojiInput' --> OK

TEST
21: added modules

   
':androidPinning' --> OK

TEST
22: added modules

   
:cachewordlib --> OK

TEST
23: added modules

   
':expandablerecyclerview-2.1.1'--> OK

TEST
24: added modules

   
':memorizingActivity' --> OK

TEST
25: added modules

   
':memorizingTrustManagermaster' --> OK

TEST
26: added modules

   
':slidingMenu' --> OK

TEST
27: added modules

   
':tibetanTextLibrary' --> OK

TEST
28: added modules

   
':viewPagerIndicator' --> OK

TEST
29: added modules

   
':volley' --> OK

TEST
30: add

    compile
'com.google.firebase:firebase-messaging:9.4.0' --> OK

TEST
31: add

    compile project
(':androidEmojiInput')
    tools
:replace="android:icon" , internet permission in Manifest  --> OK

TEST
32: add

    compile project
(':androidEmojiInput')
    tools
:replace="android:icon" in Manifest  --> OK

TEST
33: add

    compile project
(':cachewordlib')  --> OK

TEST
34: add

    compile project
(':viewPagerIndicator') --> OK

TEST
35: add

    compile project
(':tibetanTextLibrary')  --> OK

TEST
36: add

    compile project
(':memorizingTrustManagermaster')  --> OK

TEST
37: add

    compile project
(':androidPinning')  --> OK

TEST
38: add

    compile project
(':slidingMenu')  --> OK

TEST
39: add

    compile project
(':androidPinning')  --> OK

TEST
40.... :  adding jars.
   
Adding all jars to project in 'lib' folder --> OK

As a resume,  first I tried to compile just firebase-messaging:9.4.0 , it crashed again. So I created a new Project as you recomended me.

I started to add library to library , and jar to jar.. but, All compiled perfect, and launched perfect. Just as remark,  I added In the exactly order I paste before.
So, right now .. I'm really lost.

I'll send as you told me a bug report to the link you gave to me.


Thanks for all the help. If I found some solution to my problem I'll post here for sure.

Doug Stevenson

未讀,
2016年9月12日 上午10:46:142016/9/12
收件者:fireba...@googlegroups.com
In your new project, did you also apply the google service plugin in the very first step?  Remember that adds a library dependency as well.

To unsubscribe from this group and all its topics, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Elias O. R.

未讀,
2016年9月13日 凌晨4:15:592016/9/13
收件者:Firebase Google Group
Yes I did, it was the first dependecy/library I add. :/

Elias O. R.

未讀,
2016年9月13日 清晨7:29:232016/9/13
收件者:Firebase Google Group
Just to know, and to move foward int he project..

Is there some workaround to Push notifications ?  I mean, some way to in client, Identify the push notification without the firebase library?

Doug Stevenson

未讀,
2016年9月13日 晚上7:14:462016/9/13
收件者:Firebase Google Group
Sorry, not that I know of.

Elias O. R.

未讀,
2016年9月14日 凌晨4:47:402016/9/14
收件者:Firebase Google Group
No problem ^^
a lot of thanks for your time.

Just one more thing, I'm still reading  a lot about this, almost trying to find the solution.

It's possible that the problem comes por the 65K method limit? I had to set "multiDexEnabled true" and compiled  "compile 'com.android.support:multidex:1.0.1' "

But nothing more, can my problem be originated by the moment where is (I dont know how to explain it) compiled and "dexed" ?

Thanks!

Doug Stevenson

未讀,
2016年9月14日 上午11:16:482016/9/14
收件者:fireba...@googlegroups.com
If you are seeing the crash on a clean project with only the plugin applied, it's definitely not a problem with dex limit.  If you see the issue only after you apply many libraries, then I imagine it could possibly be a dex limit issue.

To unsubscribe from this group and all its topics, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Thai Dang

未讀,
2016年11月6日 中午12:22:002016/11/6
收件者:Firebase Google Group
Hi @Elias O.R

As i see your gradle file, i think we use the same chat open source and i also face to this bug for a day.

I don't know it too late or not but finally, i find a solution for this.

Let check on your ImApp.java and disable function onConfigurationChanged() and everything will be find.

Hope this will help.

Vào 23:16:09 UTC+7 Thứ Hai, ngày 05 tháng 9 năm 2016, Elias O. R. đã viết:

vyus...@65apps.com

未讀,
2016年11月7日 下午5:38:372016/11/7
收件者:Firebase Google Group
I have similar issue.
I'm doing some experiments with square/mortar library and had to override getSystemService() at class that extend Application 

public Object getSystemService(String name) {
if (TextUtils.equals(name, "appops")) { //this is workaround, i'm getting crash otherwise.
return super.getSystemService(name);
}
return mortarScope.hasService(name) ? mortarScope.getService(name) : super.getSystemService(name);
}

Maybe someone knows better solution?

воскресенье, 6 ноября 2016 г., 21:22:00 UTC+4 пользователь Thai Dang написал:
回覆所有人
回覆作者
轉寄
0 則新訊息