Tuesday, 29 May 2018

FireBase getInstance crashed with my Wrapped APK through MDX Tool

I am trying to find the crash happening with the app i developed

App is getting crashed while getting the instance of firebase, this happens only with the app downloaded from MDM App hub, works fine with emulator and device launch thru direct flash or download from playstore, this exception occurs with the app downloaded from MDM App hub from the client

client has included the senderid and API key on MDX tool before wrapping it.

below is the logs

Caused by: java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.content.pm.PackageItemInfo.name' on a null object reference
 at com.citrix.mdx.f.a.a(Unknown Source)
 at com.citrix.mdx.f.a.a(Unknown Source)
 at com.citrix.MAM.Android.ManagedApp.l.a(Unknown Source)
 at com.citrix.MAM.Android.ManagedApp.l.a(Unknown Source)
 at com.citrix.MAM.Android.ManagedApp.l.invoke(Unknown Source)
 at com.citrix.mdx.e.d.b(Unknown Source)
 at citrix.android.content.pm.PackageManager.queryIntentServices_aroundBody5$advice(Unknown Source)
 at citrix.android.content.pm.PackageManager.queryIntentServices(Unknown Source)
 at com.google.firebase.iid.zzl.zzdf(Unknown Source)
 at com.google.firebase.iid.FirebaseInstanceIdService.zzem(Unknown Source)
 at com.google.firebase.iid.FirebaseInstanceIdService.zza(Unknown Source)
 at com.google.firebase.iid.FirebaseInstanceId.<init>(Unknown Source)
 at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
 at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
 at citrix.android.content.pm.PackageManager.queryIntentServices_aroundBody5$advice(Unknown Source)
 at citrix.android.content.pm.PackageManager.queryIntentServices(Unknown Source)
 at com.google.firebase.iid.zzl.zzdf(Unknown Source)
 at com.google.firebase.iid.FirebaseInstanceIdService.zzem(Unknown Source)
 at com.google.firebase.iid.FirebaseInstanceIdService.zza(Unknown Source)
 at com.google.firebase.iid.FirebaseInstanceId.<init>(Unknown Source)
 at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
 at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)

exception is thrown at this line in the code

  case R.id.register_btn:
            if (validateInput()) {
                showProgress("Loading...");
                String android_id = Settings.Secure.getString(this.getContentResolver(),
                        Settings.Secure.ANDROID_ID);
        //here is where am getting null pointer exception only with wrapped apk 
                     final String firebaseId = FirebaseInstanceId.getInstance().getToken();
                String myVersion = android.os.Build.VERSION.RELEASE;

                final LoginData signUpData = new LoginData(userId_et.getText().toString().trim(), password_et.getText().toString(), "ANDROID " + myVersion, phone_et.getText().toString(), firebaseId);
                apiService.userLogin(signUpData).enqueue(new Callback<LoginResult>() {
                    @Override
                    public void onResponse(Call<LoginResult> call, Response<LoginResult> response) {
                        dismissProgress();
  }

below is my gradle level code

dependencies {

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

compile 'com.google.firebase:firebase-messaging:11.4.2'
compile 'com.google.firebase:firebase-crash:11.4.2'
}
apply plugin: 'com.google.gms.google-services'      

Project level Gradle file

 dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath 'com.google.gms:google-services:3.1.0'
    classpath 'com.google.firebase:firebase-plugins:1.1.1'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}   

FireBase Service Registration in Manifest

        <!-- [START firebase_service] -->
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <service
        android:name=".service.MyFirebaseMessagingService"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

    <receiver
        android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="com.fc.debug" />
        </intent-filter>
    </receiver>
    <!-- [END firebase_service] -->
    <!-- [START firebase_iid_service] -->
    <service android:name=".service.MyFirebaseInstanceIDService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>


    <!-- [END firebase_iid_service] -->

Class MyFirebaseInstanceIDService

      public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {


private static final String TAG = "MyFirebaseIIDService";

/**
 * Called if InstanceID token is updated. This may occur if the security of
 * the previous token had been compromised. Note that this is called when the InstanceID token
 * is initially generated so this is where you would retrieve the token.
 */
// [START refresh_token]
@Override
public void onTokenRefresh() {
    // Get updated InstanceID token.
         //        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    String refreshedToken = " ";
    Log.d(TAG, "Refreshed token: " + refreshedToken);

    // If you want to send messages to this application instance or
    // manage this apps subscriptions on the server side, send the
    // Instance ID token to your app server.
    sendRegistrationToServer(refreshedToken);
}
// [END refresh_token]

/**
 * Persist token to third-party servers.
 * <p>
 * Modify this method to associate the user's FCM InstanceID token with any server-side account
 * maintained by your application.
 *
 * @param token The new token.
 */
private void sendRegistrationToServer(String token) {
    // TODO: Implement this method to send token to your app server.
}

}

MyApplication Class

public class MyApplication extends MultiDexApplication {

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}
@Override
public void onCreate() {
    super.onCreate();
    FirebaseApp.initializeApp(this);

}

}

Any help will be much appreciated. Thanks



from FireBase getInstance crashed with my Wrapped APK through MDX Tool

No comments:

Post a Comment