Integrate Flurry SDK and plugin for Unity - android

I want to add Flurry SDK to my project, but I have a question.
If you go to Flurry's GitHub, if you want to use the push function, it tells you to edit "AndroidManifest.
After installing the Firebase SDK, the "AndroidManifest.xml" file is installed. Delete this file and rename the file "Assets/Plugins/Android/AndroidManifest_Flurry-template.xml" provided by Flurry to "AndroidManifest.xml". Guernsey?
Or I want to know if it is necessary to copy and paste only meta-data in "Flurry AndroidManifest_Flurry-template.xml" to "AndroidManifest.xml" installed when installing Firebase.
Thanks.

If you want to do the merge as the docs also mentioned, then you need to remove the Firebase's part. Keeping those parts will introduce push conflict between Flurry Push and Firebase Messaging.
Yes, you can merge your settings in the same file "AndroidManifest.xml" whenever they won't have any conflict.

Related

Unity Generation of the Firebase Android resource file google-services.xml from Assets/GoogleService-Info.plist failed

I would like to setup Firebase in Unity 2020.1.14.
I downloaded the GoogleService-Info.plist into my assets folder and set up a project in the Firebase console.
But as soon as I import the FirebaseAnalytics 7.0 package I'm getting this error:
Generation of the Firebase Android resource file google-services.xml from Assets/GoogleService-Info.plist failed.
If you have not included a valid Firebase Android resources in your app it will fail to initialize.
"python" "/Users/joerg/Projekte/UnityTest/FirebaseTest2012042/Assets/Firebase/Editor/generate_xml_from_google_services_json.py" -i "Assets/GoogleService-Info.plist" -l --plist
Could not find key in plist file: [DATABASE_URL]
How do I set the [DATABASE_URL] in GoogleService-Info.plist?
Thanks
Joerg
This was really frustrating. There is no mention on the original setup tutorial about this issue. I'm assuming more people are going to run in to this problem. So here is the solution:
Go to Firebase Console
Choose your project
Go to "Realtime Database"
Create Realtime Database
After database is created.
Go to "Project Settings"
Download google-services.json and GoogleService-Info.plist
Replace these files in you Unity project. (these files should be inside of the Assets folder, or if you've created a Data folder, then you can find them there.)
In the newly generated files there is a "firebase_url":. Which was missing before. This should now fix this particular error message.
Ok, I found the solution: I just had to setup a database in the Firebase Console and then the url is written to the plist file.
This wasn't mentioned in the Google tutorial.
Simple solution, just add those lines:
<key>DATABASE_URL</key>
<string>https://unexisting.fake.database.firebaseio.com</string>
p.s. I would not recommend enabling database service since it's paid. If for some reason, some plugin will attempt to use it in some way, you will be charged. The only reason I am not using those awesome paid services from Google is that they are only POST PAID without ability to set limit (except you wrote some complicated script yourself which will run in real time and will turn off services once you reach certain limit). There are lot of developers stories who woke up with 5-10k bills due to some error in script.

Unity android plugin for FCM

I'm trying to add Google FCM push notification function to Unity project. I'm surprised that there are no resources about Google FCM for Unity. There are only old Google GCM resources. This is my step-by-step progress below.
Make Android Studio project and register it to a FCM console project
Add google-service.json to '/app' and configure build.gradle (project and module)
Add MyFirebaseInstanceIDService, MyFirebaseMessagingService java classes and onTokenRefresh, sendRegistrationToServer, onMessageReceived, sendNotification methods according to sample example in FCM document
Add services for the classes to AndroidManifest.xml
After that, I tested the Android Studio project on mobile, and FCM console push notification works well. Then, I started to configure the Android Studio project for Unity.
Change 'application' to 'library' in build.gradle (module) and add deleteOldJar, exportJar for AndroidPlugin.jar
Add classes.jar of Unity to Android Studio library and module setting
Remove 'android:icon ...', 'android:theme ...' in AndroidManifest.xml
Export jar and add AndroidPlugin.jar, AndroidManifest.xml to 'Plugins/Android' in Unity
Then, I tested the Unity project on mobile. It is built without exception, but FCM console push notification didn't work. (I made test log for confirming that the Android Studio libray is well plugined for Unity, the log worked well)
Maybe, there are somethings to add to 'Plugins/Android' except AndroidManifest.xml and AndroidPlugin.jar like references below.
Google firebase analytics plugin for unity - StackOverflow
http://joxi.ru/Q2KeQD7C3zdYrj
But, I couldn't find my answer. Please let me know what I have to do or add.
Sorry for bad english and long explanation. Many thanks :)
I used Unity SDK in OneSignal.
It is very simple, easy, and cool SDK for push notification.
Reference link below.
https://onesignal.com/
This approach will not be feasible.
Jar files do not contain resources, and as such, the json file will be missing from the jar build. Alternatively, aar files, which would in theory contain the resources, are interpreted by Unity3D as pure plugin and ignores the resources or at least some, specially when using gradle. But Unity is getting better at it.
Try https://firebase.google.com/docs/unity/setup. It's new and I got the sample project to work already.
Just to add: the new Plugin of Firebase for Unity3D worked liked a charm. Use cases like pure system try notification don't need a single line of additional programming on the client side. Data Messages are very easily implemented as well.

Android client FirebaseApp initialization error

I had GCM implemented and I am trying to import GCM to FCM now. I dont want to use google-services.json because I want to use different google projects for different environments(Dev, Stag, Prod).
I tried to initialize the app via this code below
FirebaseOptions.Builder options=new FirebaseOptions.Builder();
options.setGcmSenderId("<<project id>>");
options.setApplicationId("<<Project name>>");
FirebaseApp firebaseApp = FirebaseApp.initializeApp(getApplicationContext(),options.build(),"MyTestFCM");
String refreshedToken= FirebaseInstanceId.getInstance(firebaseApp).getToken();
I keep getting exception on Firebase App initialization
Caused by: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. Available app names: MyTestFCM
If I remove the app name then i dont get a token back, then when I re-run the application I get a token. I have tried to execute the above piece of code from Mainactivity and Application class. In both places I get the same error.
So my question is how do I initialize Firebase application without using google-services.json
Thanks,
P
Firebase SDK requires to have a "default" project configured via google-services.json
Once you have that you can register FCM sdk with other sender-id using the FirebaseInstanceId.getInstance(context).getToken(...)
But please note that the most recent FCM features (auto-retry of the registration, topic subscriptions) only work with the default project.
So turns out that you need to use google-services.json for FCM, and to handle multiple build variants situation,
Generate respective google-services.json from the firebase console for the different build variants.
Download the google-services.json
In your project create folders for the variants, for example if you want release build, create a folder with name "release" and place the google-services.json in it.
When the app builds, depending upon the build variant it looks for google-services.json in the respective folder and picks up the project details from it.
More details can be found on this thread
google services issues 54
Thanks Arthur Thompson
have you checked to make sure to set your FIREBASE_URL to the right string? Also did you make sure to have the appropriate app setup config?
Last time this happened, I needed to set up my Android App Configs.
https://support.google.com/firebase/answer/7015592
Afterwards, you can follow this setup.
https://firebase.google.com/docs/cloud-messaging/android/client
Please do double check, you added
apply plugin: 'com.google.gms.google-services'
at the bottom of app's gradle file and then clean and rebuild the project

GCMRegistrar cannot be resolved

I'm trying to implement Push Notification. I have a problem with import com.google.android.gcm.GCMRegistrar it cannot be resolved.
I did install Google Play Services and add google-play-services_lib to my projects folder.
But the problem remains. I tried to find gcm.jar as I saw solutions that worked for others, but I don't have this .jar.
Is there something else that I'm missing?
First of all download Google Cloud Messaging for Android Library. For this goto Android SDK Manager->Extras->Google Cloud Messaging for Android Library check and install it.
See the below image:
Now, after downloading this libary you'll see gcm folder is available into path D:\.....\android-sdk\extras\google
Now You'll find gcm.jar into path D:\....\android-sdk\extras\google\gcm\samples\gcm-demo-client\libs.
Now, add this gcm.jar file into your project
GCMRegistrar GCM API is deprecated.It is recommended to refer updated documentation on Google developer Site
Our Google overlords have decried that gcm.jar is deprecated as of Summer 2013 so whatever example code you're working off that requires GCMRegistrar.java is a bit outdated. Of course, just adding gcm.jar works well as stated in the other answers.
If you want to follow Google's commands for whatever reason, CommonsWare has an updated GCM example project that basically just copies the needed classes from gcm.jar and renames them with a 'compat' suffix:
https://github.com/commonsguy/cw-omnibus/tree/master/Push/GCMClient2/src/com/commonsware/android/gcm/client

Add gcm.jar in Eclipse IDE (Google Cloud Messaging)

I have a problem as:
I didn't find where can I get this Jar file gcm.jar? also where Can I put it ?.
Note I used Android 4.1.
Start SDK Manager and scroll down to the section "Extras" and make sure you have installed Google Cloud Messaging for Android Library, if not, install the package.
The package will be installed in the directory "your-android-sdk\extras\google\gcm\"
Client code (for example to be used in Android app):
gcm\gcm-client\
Server code (where the Client connects to and registers it's regId):
gcm\gcm-server\
To add the gcm client-jar (gcm.jar) to your Android-project, copy it to the "libs"-folder in your Eclipse project and right click on the file and select Build Path --> Add to Build Path.
The GCM Helper libraries (gcm.jar) has been deprecated.
The documentation for the library (https://developer.android.com/google/gcm/helper.html)
now displays a messaging stating:
The information in this document has been superseded by GCM Server and GCM Client. Please use the GoogleCloudMessaging API instead of the GCM client helper library. The GCM server helper library is still valid.
Implementing a GCM server is documented here: https://developer.android.com/google/gcm/server.html
Implementing a GCM client is now documented here: developer.android.com/google/gcm/client.html (sorry, can't post as a link because I don't have enough rep).
As on today's date, SDK Manager now has the option to "Show obsolete packages" (Packages->Show obsolete packages). This allows you to install GCM through the SDK Manager itself.
Go to this link
https://dl-ssl.google.com/android/repository/gcm_r03.zip
when download completes extract the zip file, you will get three directories with names client side, server side and samples.
now open your SDK folder and create a folder named "extras/android" and paste all three folders here DONE!!
now whenever make a new project in project classpath using add external jar add gcm.jar.
refer
Just for the Recored: I followed the steps provided by chrkad but I found the .jar file in the DIST folder and NOT in the JAR folder. After I found that out I saw that Peter Gluck postet that before.
I hope that this could save some time to ppl having this issue! (took me 20 minutes)
Seems like this package is now obsolete. In order to see it in SDK Manager I had to check "Show obsolete packages" in the "Packages" menu
See details from answer
https://stackoverflow.com/a/23092848/4255980

Categories

Resources