Monthly Archives: June 2022

GOOGLE_APPLICATION_CREDENTIALS alternatives

I couldn’t set GOOGLE_APPLICATION_CREDENTIALS variable on a production server environment that runs a Java war application under a Jboss Wildfly 9 server.

I tried setting at .bashrc, .profile, .bash_profile. I tried even include the variable on standalone.sh. Nothing.

So, I remember that the GoogleCredentials function acepts a FileInputStream that reads the path of the json file.

FirebaseOptions options = FirebaseOptions.builder()
			    .setCredentials(GoogleCredentials.fromStream(new FileInputStream(<<path>>)))
			    .build();

So, after two days, finally, it works.

The solution’s explanation is here.

Android App crashes after flutterfire configure

If your app is crashing on startup when runnging a AVD, you should analyse the logcat from ‘View > Tool Windows > Logcat.

In my case, the crash cause was:

Caused by: java.lang.ClassNotFoundException: Didn't find class "br.com.sidroniolima.medo_e_delirio_app.MainActivity" 

The problem was at AndroidManifest.xml file.

The activity was pointing to a .MainActivity that is not there. It maybe have been occurred when I configure the flutterfire on project.

The Android Plugin upgrade page shows at the 5th step the following:

Android Plugin update page.

(Optional) If you removed MainActivity.java, update the <plugin_name>/example/android/app/src/main/AndroidManifest.xml to use io.flutter.embedding.android.FlutterActivity. For example:

The solution was replace the old block to the new one. As follows.

<activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
<activity
            android:name="io.flutter.embedding.android.FlutterActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">