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
}
Related
I created my first expo app, who can send notification to multiple users. I use the expo-notification package to generate the ExponentToken and handle incoming notification.
Everythings works perfecly when I use the expo go app, but recently I build my app in apk with eas
$ eas build -p android --profile genAPK
//the genAPK profile :
build: {
"genAPK":{
"android": {
"buildType":"apk"
}
}
}
I downloaded the builded apk, but when my real app want to generate the ExponentToken it just not works and return me a empty string... (I know it because my app crash do a alert() if the token is empty)
I don't know if this help, but I dont use the firebase way, I use the expo node sdk and my own database and API to store tokens and send notifications
Is this a common mistake and how can I fix this ?
Or at least can I see the output of my package even if this is a apk ?
Thanks in advance
My notification is also not working when i upgrade to EAS.
And i found this in Expo discord group:
No experienceId or projectId found. If one or the other can't be inferred from the manifest (eg. in bare workflow), you have to pass one in yourself.
at http://192.168.7.186:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:102608:321 in _createSuperInternal
at node_modules/expo-modules-core/build/errors/CodedError.js:10:8 in constructor
at http://192.168.7.186:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:313197:49 in getExpoPushTokenAsync$
There is a problem with ExpoPushToken, and you can see the source of this error from here expo-notifications-repo. The cause of this error in my case is the projectId, because in the expo-notifications-repo they use expo-constant package which have change in the latest SDK. So i need to add projectId to my app.json
"extra":{
"eas":{
"projectId":"(PROJECT_ID-Expo.dev)"
}
}
I am implementing Map Kit on my Android app. After following the official documentation on installing the HMS Core SDK, I have:
Enabled Map Kit, Location Kit and Site Kit on AppGallery Connect.
Added agconnect-services.json
Encoded my API key using URLEncoder and utf-8.
Copied my SHA-256 certificate fingerprints for my release version AND debug version (using different keystore entries).
Asked for location permission.
Setting my API key on MapsInitializer before it's loaded.
In summary, my code looks like this:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
try {
API_KEY = URLEncoder.encode(
getString(R.string.api_key),
"utf-8"
)
MapsInitializer.setApiKey(API_KEY)
} catch (ignored: UnsupportedEncodingException) {
}
binding = ActivityMapBinding.inflate(layoutInflater)
setContentView(binding.root)
viewModel = ViewModelProvider(
this,
MapViewModel.MyViewModelFactory(application)
)[MapViewModel::class.java]
var mapViewBundle: Bundle? = null
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY)
}
mMapView = binding.mapView
mMapView.onCreate(mapViewBundle)
mMapView.getMapAsync(this)
siteInfo = binding.siteInfo
siteInfo.visibility = View.GONE
// ...
}
But all I get when entering the activity is the blue point of my location over a blank map and a Toast saying REQUEST_DENIED.
Checking the logs, there seems not to be an API authentication or signing error, but most likely Petal Maps API being down:
E/HmsMapKit_ErrorTraceLogPusher_4: cache error trace log : ErrorTraceLogDTO{ scenario = ACCESS_SERVICE_ERROR', message='060001 : NETWORK_ERROR'}
com.huawei.hms.maps.foundation.client.mac: *e*v*r*A*d*e*s*f*o* *R* *s*e*p*y*
at com.huawei.hms.maps.foundation.client.mac$maa.b(Unknown Source:25)
This is disturbing, because there's no sign of this error code in the official Map Kit error codes documentation. Does anyone know what's going on? Thanks in advance!
Solved it! Here's my config:
HMS Core: latest version as of 14/03/2022 (6.4.0.306)
Map Kit: latest version as of 14/03/2022 (implementation 'com.huawei.hms:maps:6.3.1.300')
Main cause: my app signing configuration was missing in my build.gradle file.
Steps to solve it:
Deleted my existing keystore (.jks). DISCLAIMER: you will lose the capacity to update your app if it's released in AppGallery. Please do it as a last resort.
Created a new keystore INSIDE my Android Studio project, under the app directory.
Generated a signed APK for release and obtained the SHA-256 fingerprint.
Replaced my former fingerprint with the new one in AppGallery Connect.
In my map activity, DIDN'T encode my API key (thanks shirley!)
Rebuilt my project.
Complete instructions are here.
Update
This problem has been fixed in the latest version of the HMS Core. Try to upgrade the HMS Core apk to the latest version which may solve this issue.
Currently, the latest version of the HMS Core is 6.5.0.312.
Thank you for providing the information regarding this issue. We have reported this issue to the R&D team for handling, may i confirm is the HMS Core 6.4.0 installed on your device? You are advised to roll back to HMS Core 6.3 version apk. And we will release a patch package as soon as possible to fix this issue.
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 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!