I've been building a game with Unity which I've hooked up to Firebases Auth and Database in order to store data and handle login and so far I've had no trouble with the project in the Unity Editor.
However, once I build for Android it seems like everything that has to do with Firebase is missing. So far I've tried changing the Android Manifest, updating play services, deleting and reimporting everything that has to do with Firebase.
This is where I Initialize Firebase:
public class FirebaseLogin : MonoBehaviour {
public InputField emailField;
public InputField passwordField;
protected FirebaseAuth auth;
private FirebaseAuth otherAuth;
protected Dictionary<string, FirebaseUser> userByAuth = new Dictionary<string, FirebaseUser> ();
DependencyStatus dependencyStatus = DependencyStatus.UnavailableOther;
void Awake () {
//So far my code runs this line
DebugHelper.instance.Add ("Beginning");
//When I try to debug the following line nothing happens, so it probably produces an error
DebugHelper.instance.Add (FirebaseAuth.DefaultInstance.ToString ());
FirebaseApp.CheckAndFixDependenciesAsync ().ContinueWith (task => {
dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available) {
InitializeFirebase ();
} else {
DebugHelper.instance.Add("Failed to initialize firebase");
Debug.LogError("Failed");
}
});
}
}
When I look at my logcat I'm getting the following error:
Unable to find FirebaseCppApp-5.1.1
E/Unity: DllNotFoundException: FirebaseCppApp-5.1.1 at (wrapper
managed-to-native)
Firebase.AppUtilPINVOKE/SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_AppUtil(Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExc
eptionHelper/ExceptionDelegate)
at Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor () [0x00000] in
:0
Rethrow as TypeInitializationException: An exception was thrown by the
type initialize
I have been struggling to find an answer for this, but as far as I could tell no one has had the same issue.
Thanks in advance for taking the time to help!
For anyone who might have the same issue, here's how I solved it:
I updated my android studios, twice apparently I was that far behind
Then I installed the newest build tools SDK along with any google play service updates
Then I updated the JDK, I was very far behind which made the PlayServicesResolver give me all sorts of errors
I went back into unity, ran the PlayServicesResolver tools which fixed most of my issues
Then I reimported the Unitypackages for Database and Auth
I believe this should be every step you need to solve this issue, however there might be a couple of problems with Android Manifests or the build gradle. I'm not entirely sure if it had an impact or not, but I added multiDexEnabled true to the build gradle. My Android Manifest underwent a lot of changes, but now that I look at it, I believe it's back to where it started when I first imported the Unitypackages
I hope my discoveries might help you, otherwise feel free to ask
Best of luck
Posting an additional gotcha with this issue that may help others who land here.
I upgraded our project's Unity Firebase plugin from 5.4.2 to 5.4.3 and everything worked fine locally but our Jenkins build server would generate builds that failed with lots of these errors in logcat;
2019-02-14 10:52:53.183 21504-21551/? E/Unity: DllNotFoundException: Unable to load DLL 'FirebaseCppApp-5.4.2': The specified module could not be found.
at Firebase.AppUtilPINVOKE.PollCallbacks () [0x00000] in :0
at Firebase.AppUtil.PollCallbacks () [0x00000] in :0
at Firebase.Platform.FirebaseHandler.Update () [0x00000] in :0
The problem turned out to be that the Firebase .unitypackages gave files that did not change name between versions (eg. Firebase.App.dll or maven-metadata.xml) the same timestamp from version to version which caused svn to not see those files as changed and therefore not committing them to version control.
To solve this I simply touched all the Firebase files by going into Assets/Firebase and Assets/Plugins in terminal and running "find . -exec touch {} \;" (Mac). svn would then show the changed files.
If anyone from the Firebase Unity team reads this, may I request in future releases you update the timestamps on all files in the Firebase*.unitypackages to prevent version control systems (like svn) that use timestamp as a first pass change check ignoring the changes. Thanks!
Related
To start, this setup does work on Windows without issue, it only proceeds to break once I try and run the Android version of the application. I presume I am missing an important .dll file that is required.
I am building a .net Standard 2.1 application and am using the 5.0.17 version of all the EntityFrameworkCore libraries, which in turn largely depend on 5.0.0 versions of the various underlying Microsoft Libraries. I had to manually go through on nuget and find every package that was required in the dependency tree and manually place them in /assets/Plugins/
I am trying to utilize Microsoft.Entityframeworkcore.Sqlite and the sticking point primarily seems to be with SQLitePCLRaw.lib.e_sqlite3 Package at the bottom of everything, which rather than a singular .dll, it has a multitude for various platforms.
To get it working on Windows, all I did was create the folder Assets/Plugins/Windows/x64/ and place the e_sqlite3.dll file from the SQLitePCLRaw.lib.e_sqlite3's package, specifically from its folder /runtimes/win-x64/native/e_sqlite3.dll
The application compiled and ran perfectly fine for windows and I was able to successfully utilize EntityFrameworkCore. This following code worked just fine and the .db file was produced and it had the migrations applied successfully!
var saveFolder = Path.Join(Application.persistentDataPath, "Saves");
if (!Directory.Exists(saveFolder))
{
_ = Directory.CreateDirectory(saveFolder);
}
var dbPath = Path.Join(saveFolder, "saves.db");
var options = new DbContextOptionsBuilder<GameContext>()
.UseSqlite($"Data Source={dbPath}")
.Options;
var gameContext = new GameContext(options);
_ = gameContext.Database.EnsureCreated();
_ = Container.Bind<GameContext>().FromInstance(gameContext);
I then proceeded to repeat the process for android, copying the dll from the package at /runtimes/linux-arm64/native/libe_sqlite3.so and copied it to my project, placing it in the folder at /Assets/Plugins/Android/x64/libe_sqlite3.so and then clicking on it and configuring in the inspector for it's Platform to be Android, and CPU to be ARM64
It compiles, and the application runs, however the Entity Framework code fails when I call .EnsureDatabase(), and it throws the following exception:
The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteRelationalConnection.CreateDbConnection () [0x00006] in <f30b26b830734f4186e498a166035372>:0
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection () [0x00025] in <97c0a4be397640809d61259a928dc93a>:0
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open (System.Boolean errorsExpected) [0x00000] in <97c0a4be397640809d61259a928dc93a>:0
at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteDatabaseCreator.Exists () [0x0003b] in <f30b26b830734f4186e498a166035372>:0
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreated () [0x00008] in <97c0a4be397640809d61259a928dc93a>:0
at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureCreated () [0x0000b] in <2d572abcbb2148e78ec2a14611543f20>:0
at SceneInstaller.InstallBindings () [0x000c3] in <26c8bef0ce894a5aa4311a4f895e1158>:0
Looking this error up, it seems to be related to the library missing, but Im not sure what other .dll or .so file I would need aside from libe_sqlite3.so
I also, to be safe, I then did a second pass of copying /runtimes/linux-arm/native/libe_sqlite3.so to Assets/Plugins/Android/v7/libe_sqlite3.so and set that one to target Android ARMv7 in the inspector. This did not resolve the issue.
Am I missing some form of .dll file?
Currently using Unity version 2022.2.0b10
I feel like I have tried every possible combination of ways to report a crash on the firebase crashlytics console for the android side of my react-native application.
I have followed the rnfirebase setup instructions and triple checked that everything is where it should be: https://rnfirebase.io/crashlytics/android-setup
I have read in several forums that the app needs to be run in 'release' mode for the crash to be reported and then the app must be closed and opened once again for the report to be sent, I have done this multiple times:
firstly i've tried:
./gradlew installRelease
secondly I tried a method recommended in a github issue forum:
./gradlew assembleRelease
adb install ./app/build/outputs/apk/release/app-release.apk
both methods ran on my emulator and I was able to use the crashlytics().crash() method to cause a crash, alas nothing appears in the console.
I have also added this into a firebase.json file in the root of my project like the docs explain:
{
"react-native": {
"crashlytics_debug_enabled": true
}
}
any help is greatly appreciated as I really don't know where the issue lies.
PS. I have registered my app with the FB console and enabled crashlytics
in firebase.json
{
"react-native": {
"crashlytics_disable_auto_disabler": true,
"crashlytics_debug_enabled": true
}
}
make sure that crashanalytics sdk is installed/initialised
follow: https://rnfirebase.io/crashlytics/android-setup
When I transitioned to Expo's Managed Workflow (SDK 37 and now 38 as well), in-app update checking broke.
My code:
import * as Updates from 'expo-updates';
async checkForUpdate() {
const update = await Updates.checkForUpdateAsync();
if (update.isAvailable) {
this.updateApp();
}
}
async updateApp() {
await Updates.fetchUpdateAsync();
Updates.reloadAsync();
}
Logcat shows me that the checkForUpdateAsync() promise is being rejected with this message:
Error: The method or property Updates.checkForUpdateAsync is not available on android, are you sure you’ve linked all the native dependencies properly?
For the record I did install it via expo install expo-updates
Thanks.
I solved this by creating a new Expo project and looking for differences from my many-times-upgraded one. I found two:
I was using off-the-shelf React Native instead of the Expo build, so I changed the dependency in package.json to "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.1.tar.gz"
I also updated my expo version to ^38.0.8, as used by the new project.
Finally, I also deleted some build relics that I had generated during the way, but I think the fix came from one of the steps above.
I've created an Android app and I am trying to set up Google Play services as I want to use the leader board etc.
I downloaded and imported the latest plugin "GooglePlayGamesPlugin-0.9.50 " and had no errors during the import.
I then go to assets/ play service resolver/android/force resolve and run that.
After running I end up with the following error:
Resolution failed
Failed to fetch the following dependencies:
com.google.games:gpgs-plugin-support:0.9.50
UnityEngine.Debug:LogError(Object)
Google.Logger:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:Log(String, LogLevel)
GooglePlayServices.ResolverVer1_1:LogMissingDependenciesError(List`1)
GooglePlayServices.c_AnonStorey18:<>m_26(List`1)
GooglePlayServices.c_AnonStorey14:<>m_1F(Result)
GooglePlayServices.c_AnonStorey15:<>m_28()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
If I ignore the error and compile the app it works fine but does not connect to the Google service. I can publish and use the app without crashes etc but I can't log on to Google or view leader boards.
I am using: unity 2017.1.1f1 personal 64bit
Windows 10 64 bit
jdk1.8.0_162
You may refer with the workaround given in this thread.
Reimported Google Play Games Plugin (It will select the missing files by default).
Go to Assets menu => Play Services Resolver => Android Resolver => Force Resolve.
After resolving dependencies , Resolve Conflict window pops up. Click NO.
Build and Test your application
Add Debug.Log to check your authenticate status.
Social.localUser.Authenticate (success => {
if (success) {
Debug.Log ("SignIn successful");
} else {
Debug.Log ("SignIn failed");
}
});
Here are some additional references:
Resolution fails everytime trying to fetch gpgs-plugin-support
Gradle failed to fetch dependencies.
Hope this helps!
Navigate to your GooglePlayGamesPluginDependencies.xml file and make sure that the path mentioned for "com.google.games:gpgs-plugin-support:x.x.xx" exists and is valid. Then try Force Resolve again.
I face issue with get token from firebase (push notification)
Default FirebaseApp is not initialized in this process com.ready_apps.Nebka.Business. Make sure to call FirebaseApp.initializeApp(Context) first.
even I called FirebaseApp.InitializeApp(this); in many places
MyApplication (that extend Application) , in onCreate of Activity where I call FirebaseInstanceId.Instance?.Token;
Edit: This bug has been fixed in Xamarin.Firebase version 57.1104.0-beta1.
This error seems to be present in the newer versions of Firebase for Xamarin. I am also experiencing this error as of today, using the latest stable version 42.1021.1. (The error is also present in the latest beta build).
I found that a bug report has been filed for the issue here.
As mentioned in the bug report, deleting both the /obj and /bin folders in your Android project, and/or cleaning the project in Visual Studio should fix the problem temporarily until you update any resource that would change the Resource.Designer.cs file.
Downgrading to an older version of Firebase and Google Play Services is also possible before a permanent solution is available. I did not experience this error on Firebase and Google Play Services version 32.961.0, for example.
Just Clean the solution once and run the app again.
This bug is already reported to Xamarin.
https://bugzilla.xamarin.com/show_bug.cgi?id=56108
This solution is provided in their comment thread, it might get fixed in the newer release of xamarin NuGet package.
I didnt fix it but I find walkaround this issue in debug mode only
I called this method onCreate() in activit I need to request the token
FirebaseInstanceId.Instance?.Token
here is the method
private void ConfigureFireBase()
{
#if DEBUG
try
{
Task.Run(() =>
{
var instanceId = FirebaseInstanceId.Instance;
instanceId?.DeleteInstanceId();
//Log.Debug("TAG", "{0} {1}", instanceId?.Token?.ToString(), instanceId.GetToken(GetString(Resource.String.gcm_defaultSenderId), Firebase.Messaging.FirebaseMessaging.InstanceIdScope));
});
// For debug mode only - will accept the HTTPS certificate of Test/Dev server, as the HTTPS certificate is invalid /not trusted
ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
}catch (Exception e)
{
Log.Debug("TAG", e.Message);
}
#endif
}