This is the exact same problem presented in this question: Unity Firebase is not initializing on Android
But the solution to that one doesn't work for me because the code is different.
When I run the app in Unity, Firebase is initialized correctly, but when I build the app, for Android or PC, it doesn't initialize.
I write my code from this tutorial: https://www.youtube.com/watch?v=A6du3DUTIPI
using System;
using System.Collections;
using System.Collections.Generic;
using Firebase;
using Firebase.Analytics;
using Firebase.Extensions;
using UnityEngine;
using UnityEngine.Events;
public class FirebaseInit : MonoBehaviour
{
public UnityEvent OnFirebaseInitialized = new UnityEvent();
private void Start()
{
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
{
FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
if (task.Exception != null)
{
Debug.LogError($"Error al inicializar Firebase con {task.Exception}");
return;
}
OnFirebaseInitialized.Invoke();
});
}
}
I have Unity 2019.4.4f1 and the latest Firebase SDK
I found a solution, but without fixing the actual problem.
I installed the Unity Editor using the offline installation, so it appears that this method doesn't download all the needed Android dependencies, because I tried installing again the Editor, but through the Unity Hub this time and the problem disappeared.
Related
I'm trying to add Google Play Services on my Unity Android project.
I've got already implement google play services plugin to my project. Filling the all crediantials. I've got 2 different internal test accounts on developer console.
Here is my question:
Account A: SignInStatus Success and not showing welcome pop-up
message.
Account B: SignInStatus Canceled and not sign in.
Is it because internal test or something?
unity version: 2019.4.16f1
gpgs plugin verison: 0.11.01
Here is my code:
referanced: https://github.com/playgameservices/play-games-plugin-for-unity
using GooglePlayGames;
private bool Authenticated;
public void Start() {
PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
}
internal void ProcessAuthentication(SignInStatus status) {
if (status == SignInStatus.Success) {
// Continue with Play Games Services
Authenticated = true;
} else {
// Disable your integration with Play Games Services or show a login button
// to ask users to sign-in. Clicking it should call
// PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication).
Authenticated = false;
}
}
There is nothing wrong with your code.
I just created a new project, got a new SHA-1, added my account to the new google play console and verified that everything was tested successfully.
In doing so, we found the following problems:
If you are using the 11.01 version, please check if there is a problem by following the procedure below.
Follow the steps below to check.
(Assets → External Dependency Manager → Android Resolver → Force Resolve)
Assets/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPluginDependencies.xml:11: Repo path 'Packages/com.google.play.games/Editor/m2repository' does not exist.
If the above error occurs, you can solve it by choosing one of two solutions.
First, see comments by #greg-hanes here.
The specific method is to create a GooglePlayGamesPluginDependencies.xml file inside the Assets/GooglePlayGames/com.google.play.games/Editor/m2repository folder and paste the following contents.
<?xml version="1.0" encoding="UTF-8" ?>
<dependencies>
<!-- Internal library dependency generated at build time.
It also defines the transitive dependencies on play-services
-->
<androidPackages>
<androidPackage spec="com.google.games:gpgs-plugin-support:0.11.01">
<repositories>
<repository>Assets/GooglePlayGames/com.google.play.games/Editor/m2repository</repository>
</repositories>
</androidPackage>
</androidPackages>
</dependencies>
And then Force Resolve again.
(Gradle failed to fetch dependencies on the way. If you get an error, make sure your JDK path is set correctly.)
Second, downgrade the version to version 10.14.
Here is my code that I wrote to run only once at runtime. It works successfully when I run it.
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
public static class Login
{
[RuntimeInitializeOnLoadMethod]
public static void SignIn()
{
PlayGamesPlatform.Instance.Authenticate(success =>
{
Debug.Log(success ? "Success Login" : "Failed Login");
});
}
}
You can check the logs on Android by installing the Android Logcat package.
I hate the 11.01 version so I'm using the 10.14 version :)
Hope your problem is solved!
I'm using capacitor v3 beta and there are no problem working in web and iOS but can't run android app.
Build is done fine but when running the app appears this error:
E/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 41296 - Msg: ERROR Error: Uncaught (in promise): Error: "Storage" plugin is not implemented on android
Error: "Storage" plugin is not implemented on android
To solve this error I've removed the storage plugin and replaced with ionic/storage plugin. But when I use other plugin, for example the Keyboard, the error shows up saying that Keyboard plugin is not implemented on android.
So I suppose that there is some problem with Android builds or project configuration.
These are de node dependencies in my package.json
"#capacitor/android": "^3.0.0-beta.6",
"#capacitor/core": "^3.0.0-beta.1",
"#capacitor/storage": "^0.3.1",
And my capacitor.config.json file
{
"appId": "net.flowww.me",
"appName": "FLOWwwMe",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"cordova": {}
}
iOS version works well with this configuration.
Storage plugin not worked after Ionic v3 upgrades from v2.
It work after manually adding a plugin to MainActivity.java for me:
package com.ionic.app;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.capacitorjs.plugins.storage.StoragePlugin;
public class MainActivity extends BridgeActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerPlugin(StoragePlugin.class);
}
}
I also faced the same problem when upgrading from capacitor 2 to 3
As it turned out, I forgot to execute:
npx cap sync android
This solved the problem
you must in mainActivity : add(StoragePlugin.class);
After creating new project and reviewing file differences saw that I have not installed
"#capacitor/cli": "^3.0.0-beta.6"
So I installed it and all compiles successfully.
In Capacitor's v2 doc, in the page dedicated to Storage Plugin (https://capacitorjs.com/docs/apis/storage) the import is done like:
import { Storage } from '#capacitor/storage';
Then in the Capacitor's v2 doc for Using Plugins (https://capacitorjs.com/docs/v2/apis) you'll find that:
Import the Plugins object. It represents the registry of all Capacitor plugins.
import { Plugins } from '#capacitor/core';
Get a plugin from the Plugin Registry (Plugins object).
const { Browser } = Plugins;
Use the plugin API:
async openBrowser() {
// On iOS, for example, open the URL in SFSafariViewController (the in-app browser)
await Browser.open({ url: "https://ionicframework.com" });
}
A common mistake is to import a plugin directly, then use the plugin API >immediately, resulting in the web implementation being used:
import { Browser } from '#capacitor/core';
async openBrowser() {
// On iOS, for example, this will open the URL in Safari instead of
// the SFSafariViewController (in-app browser)
await Browser.open({ url: "https://ionicframework.com" });
}
By using the plugins from the plugin registry (Plugins object), the native implementation of the plugin is used (if available), with fallback to the web version.
So if you're using Quasar with Capacitor v2 you probably gone crazy like me. Just replace Browser with Storage.
Maybe in v3 that problem is solved and that's why legomolina's answer works.
For Capacitor V3 plugins (tested on Android 11 & Ionic 5)
capacitor.plugins.json has the entry for Storage plugin,
MainActivity.java should not have the onCreate function, where CapV3 uses native API,
Try setting minifyEnabled=false in build.gradle.
If error disappears, create pro-guard rules in proguard-rules.pro as in https://github.com/ionic-team/capacitor/issues/739
I found the issue was solved by simply starting up Android Studio. It sync'd Gradle automatically and then I just restarted my Android dev environment - the error was gone and I was able to access Storage as per the capaitor plugin docs.
See https://capacitorjs.com/docs/android/troubleshooting#plugin-not-implemented
I'm trying to incorporate Stripe payments into my Xamarin app. I've installed the latest Stripe NuGet Package and have included the following code in my .cs:
using System;
using System.Collections.Generic;
using Stripe;
using Xamarin.Forms;
namespace CampaignFinanceNew
{
public partial class CreditCardProcess : ContentPage
{
StripeClient paymentClient = new StripeClient("[test key here]");
public CreditCardProcess()
{
InitializeComponent();
CreditCard currentCard = new CreditCard();
currentCard.Number = creditCardNumber.Text;
currentCard.ExpMonth = Convert.ToInt32(ccExpiryMonth.Text);
currentCard.ExpYear = Convert.ToInt32(ccExpiryYear.Text);
StripeObject newToken = paymentClient.CreateCardToken(currentCard);
}
}
}
When I build the project, it gives me the following error:
Error XA2002: Can not resolve reference: Stripe, referenced by CampaignFinanceNew. Please add a NuGet package or assembly reference for Stripe, or remove the reference to CampaignFinanceNew. (XA2002) (CampaignFinanceNew.Android)
I've tried to add the Stripe package to both my iOS and Android projects, but it tells me that it's incompatible. What should I do? Would I be better off implementing it individually for both iOS and Android then just accessing it via DependencyService?
Upon further research, it appears there are 2 different Stripe NuGet Packages, one specifically written for .NET applications (as opposed to the one I was using). I've downloaded the new package and things seem to be working fine now.
I wish to use this native plugin for Android devices via Unity.
For some reason the plugin is just now working. When I run it on a real device the game crashes. I am using Unity 5.5.2f1 personal, my phone is Samsung Edge 6 with Marshmallow api.
I have placed the jar file inside Assest/Plugins/Android. I can't figure out what is the cause for this error. Do you know what is wrong here?
This is part of my code:
private AndroidJavaObject plugin;
void Start ()
{
plugin = new AndroidJavaClass("jp.kshoji.unity.sensor.UnitySensorPlugin").CallStatic<AndroidJavaObject>("getInstance");
//Init the ambienttemperature sensor
if (plugin != null)
{
plugin.Call("startSensorListening", "ambienttemperature");
}
}
In My ionic Cordova Application, I am using In App Purchase Plugin: https://github.com/j3k0/cordova-plugin-purchase
Here is the method that I use to initialise store:
storekit.init({
debug: true, // Enable IAP messages on the console
ready: service.IAP.onReady,
purchase: service.IAP.onPurchase,
restore: service.IAP.onRestore,
error: service.IAP.onError
});
This Initialization works fine with iOS and all the products loading fine as well, But Android device does not load In Purchase.
I guess, For android there is a different initialization method.
I have added plugin in app:
cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="<BILLING_KEY>"
Please help.
Firstly, when I was using it, the npm version was a little buggy on android. Try removing it and adding it from Git.
cordova plugin add https://github.com/j3k0/cordova-plugin-purchase.git --variable BILLING_KEY="MIIB...AQAB"
Secondly, it looks like you are maybe using some older syntax. The doco for this plugin doesnt really have very good version control. There are different versions of doco all over the net. I think this is the latest version.
This is my initialisation code. See if it works for you too.
products = ["my.test.product"];
for (var i = 0; i < products.length; i++) {
if (window.store) {
store.register({
id: products[i],
alias: 'alias '+i,
type: store.NON_CONSUMABLE
});
}
}
// When everything goes as expected, it's time to celebrate!
if (window.store) store.ready(function() {
console.log("\\o/ STORE READY \\o/");
});
// After we've done our setup, we tell the store to do
// it's first refresh. Nothing will happen if we do not call store.refresh()
if (window.store) store.refresh();
You can also send the store object to console.log to have a good look at it in chrome debugger.
Oh, and if you have more than one app, make sure you are using the correct BILLING_KEY by removing and readding the plugin.
Good Luck!