Этот сбой происходит только, когда приложение загружается из Play Store. Активность открывается и остается в порядке в течение нескольких секунд, но сразу после этого... происходит следующее:
2022-02-12 22:32:50.927 6188-6283/? E/AndroidRuntime: FATAL EXCEPTION: firebase-installations-executor-2
Process: com.Sujal_Industries.Notes.SelfNotes, PID: 6188
java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:220)
at l6.c.g(SourceFile:346)
at l6.b.run(SourceFile:93)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Я пытался воспроизвести сбой в режиме отладки (включив proguard), но не смог, поэтому думаю, что это не имеет никакого отношения к оптимизации/исключениям proguard.
Вот код из MainActivity.java:
package com.Sujal_Industries.Notes.SelfNotes;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import androidx.activity.result.ActivityResultLauncher;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.splashscreen.SplashScreen;
import com.firebase.ui.auth.AuthUI;
import com.firebase.ui.auth.FirebaseAuthUIActivityResultContract;
import com.firebase.ui.auth.data.model.FirebaseAuthUIAuthenticationResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.messaging.FirebaseMessaging;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "SelfNotes";
private static final String spFileKey = "SelfNotes.SECRET_FILE";
private SharedPreferences sharedPreferences;
Button button;
private final ActivityResultLauncher signInLauncher = registerForActivityResult(
new FirebaseAuthUIActivityResultContract(),
this::onSignInResult
);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SplashScreen.installSplashScreen(this);
doInitialSetup();
}
private void doInitialSetup() {
sharedPreferences = getSharedPreferences(spFileKey, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
if (!sharedPreferences.getBoolean("FCM", false)) {
FirebaseMessaging.getInstance().subscribeToTopic("Global")
.addOnCompleteListener(task -> {
String msg = getString(R.string.msg_subscribed);
editor.putBoolean("FCM", true);
if (!task.isSuccessful()) {
msg = getString(R.string.msg_subscribe_failed);
editor.putBoolean("FCM", false);
}
editor.apply();
Log.d(TAG, msg);
});
}
Intent intent = new Intent(getApplicationContext(), App.class);
startActivity(intent);
finish();
}
setContentView(R.layout.activity_main);
button = findViewById(R.id.button);
button.setOnClickListener(v -> {
// Choose authentication providers
List providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build());
// Create and launch sign-in intent
Intent signInIntent = AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build();
signInLauncher.launch(signInIntent);
});
}
@Override
protected void onStart() {
super.onStart();
}
private void onSignInResult(FirebaseAuthUIAuthenticationResult result) {
SharedPreferences.Editor editor = sharedPreferences.edit();
if (result.getResultCode() == RESULT_OK) {
// Successfully signed in
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
if (!sharedPreferences.getBoolean("FCM", false)) {
FirebaseMessaging.getInstance().subscribeToTopic("Global")
.addOnCompleteListener(task -> {
String msg = getString(R.string.msg_subscribed);
editor.putBoolean("FCM", true);
if (!task.isSuccessful()) {
msg = getString(R.string.msg_subscribe_failed);
editor.putBoolean("FCM", false);
}
editor.apply();
Log.d(TAG, msg);
});
}
// Accessing Cloud FireStore...
FirebaseFirestore db = FirebaseFirestore.getInstance();
//Creating New User...
String name = user.getDisplayName();
String email = user.getEmail();
if (email != null && name != null) {
Map newUser = new HashMap();
newUser.put("Name", name);
db.collection("users")
.document(email)
.set(newUser);
}
Intent intent = new Intent(getApplicationContext(), App.class);
startActivity(intent);
finish();
} else {
// Sign in failed. If response is null the user canceled the
// sign-in flow using the back button. Otherwise check
// response.getError().getErrorCode() and handle the error.
// ...
Log.e(TAG, "Failure!");
}
}
}
}
Файл build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 32
defaultConfig {
applicationId "com.Sujal_Industries.Notes.SelfNotes"
minSdkVersion 21
targetSdkVersion 32
versionCode 18
versionName "1.4.7"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildToolsVersion '32.1.0-rc1'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.firebase:firebase-analytics:20.1.0'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.firebaseui:firebase-ui-auth:8.0.0'
implementation 'com.google.android.material:material:1.6.0-alpha02'
implementation 'com.google.firebase:firebase-messaging:23.0.0'
implementation 'com.google.firebase:firebase-firestore:24.0.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.github.satyan:sugar:1.5'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.core:core-splashscreen:1.0.0-beta01'
}
apply plugin: 'com.google.gms.google-services'
AndroidManifest.xml:
Полный код здесь: https://github.com/Sujal1245/SelfNotes
Ссылка на приложение: https://play.google.com/ store/apps/details?id=com.Sujal_Industries.Notes.SelfNotes
Я искал похожие ошибки, но не смог найти ни одной, похожей на мой случай. Логарифмический кот тоже меня немного сбивает с толку.
ОБНОВЛЕНИЕ:
Я удален библиотеку Firebase Analytics, и теперь нет сбоев, но мне все равно хотелось бы знать точную причину сбоя.
implementation 'com.google.firebase:firebase-analytics:20.1.0'
Подробнее здесь: https://stackoverflow.com/questions/710 ... -2-android
ФАТАЛЬНОЕ ИСКЛЮЧЕНИЕ: firebase-installations-executor-2 (Android) ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Firebase не работает com.google.firebase.installations.FirebaseInstallationsException
Anonymous » » в форуме Android - 0 Ответы
- 11 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Firebase не работает com.google.firebase.installations.firebaseinstallationsexception
Anonymous » » в форуме Android - 0 Ответы
- 2 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Результаты Flutter Android CCAveneue Payment SDK ФАТАЛЬНОЕ ИСКЛЮЧЕНИЕ: основное
Anonymous » » в форуме Android - 0 Ответы
- 27 Просмотры
-
Последнее сообщение Anonymous
-