hansemannn / titanium-firebase-analytics

Use the Firebase Analytics SDK in Axway Titanium 🚀
Other
35 stars 18 forks source link

Not getting data on Android #10

Closed trkfabi closed 6 years ago

trkfabi commented 6 years ago

Hi,

I'm using analytics and core just to log some events. iOS works fine but I don't see any data going to Firebase under the Android project. Settings seem to be just fine, the google-services.json is under /app/assets/android/ and no errors are begin logged in the console. I'm using Ti SDK 6.3.0 and I don't use any other module that could conflict with this one.

I'd appreciate any clue of where to look at.

Thanks

hansemannn commented 6 years ago

I do not personally use the Android one, but maybe @miga or @appwerft can help?

mitulbhalia commented 6 years ago

Hello @trkfabi Did you find any solution for your issue? Also can you please tell me how to configure android module? I added google-services.json in /app/assets/android/ but when i tried run the demo, it shows me below error.

Uncaught TypeError: Alloy.Globals.FA.configure is not a function

I declare this module in alloy.js as below Alloy.Globals.FA = require('firebase.analytics'); Alloy.Globals.FA.configure(); Please let me know.

trkfabi commented 6 years ago

Hi Mitul,

No, I haven’t found a solution yet. I’m not receiving any data from the Android apps on the firebase console.

I have added these 2 lines to tiapp.xml:

firebase.analytics firebase.core

And this is the code in Alloy.js: Alloy.Globals.FirebaseCore = require('firebase.core'); Alloy.Globals.FirebaseAnalytics = require('firebase.analytics'); Alloy.Globals.FirebaseCore.configure();

and I call this method: Alloy.Globals.FirebaseAnalytics.log(eventName, parms);

it works on iOS.

and this is my app/assets folder:

Hope we can find a solution or workaround to this issue.

Fabian

On Jan 1, 2018, at 4:22 AM, Mitul Bhalia notifications@github.com wrote:

Hello @trkfabi https://github.com/trkfabi Did you find any solution for your issue? Also can you please tell me how to configure android module? I added google-services.json in /app/assets/android/ but when i tried run the demo, it shows me below error.

Uncaught TypeError: Alloy.Globals.FA.configure is not a function

I declare this module in alloy.js as below Alloy.Globals.FA = require('firebase.analytics'); Alloy.Globals.FA.configure(); Please let me know.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hansemannn/titanium-firebase-analytics/issues/10#issuecomment-354640245, or mute the thread https://github.com/notifications/unsubscribe-auth/ABffPdLpmMJ4wEtlm7FHhOmhW4u5KSasks5tGIeygaJpZM4RCpWE.

hansemannn commented 6 years ago

I noticed that you use an outdated version of the module that didn't play nice with playservices at that time. With 7.0.0+, the google play services are managed in a central place, the ti.playservices module. The updated module version (2.x) requires that module and firebase.core to be included.

Example:

<module>ti.playservices<module>
<module>firebase.core<module>
<module>firebase.analytics<module>

In addition, if the problem still occurs with titanium-firebase-analytics 2.0.0 (current stable), I've prepared a 2.0.1 version that attempts to pass the activity different than before. Let me know if that works out!

Preprelease: firebase.analytics-android-2.0.1.zip

mitulbhalia commented 6 years ago

Ok @trkfabi Let me know when you find solution.

@hansemannn My main concern is that i am not using latest version of mac os so i need to use ti sdk 7.0 then i have to first update my mac os then xcode version so is there any older which i can use for my iphone app?

trkfabi commented 6 years ago

Hi Hans,

thank you for the update. I don’t know if I am missing something…

I had to install node 8.x to use Ti sdk 7.x+.

I replaced tiapp.xml lines with this: image

it compiles without errors for both iOS and Android, but it crashes when the app runs with this error on iOS and Android: image

image

I pasted the modules in both folders, under the “modules” folder in the project and in /library/…

image

image

And this is Alloy.js (I have just added the setScreenNameAndClass method, no other modifications since last version) image

I don’t know what’s going on :(((

Fabian.

On Jan 1, 2018, at 2:27 PM, Hans Knöchel notifications@github.com wrote:

I noticed that you use an outdated version of the module that didn't play nice with playservices at that time. With 7.0.0+, the google play services are managed in a central place, the ti.playservices https://github.com/appcelerator-modules/ti.playservices/releases module. The updated module version (2.x) requires that module and firebase.core to be included.

Example:

ti.playservices firebase.core firebase.analytics In addition, if the problem still occurs with titanium-firebase-analytics 2.0.0 (current stable), I've prepared a 2.0.1 version that attempts to pass the activity different than before. Let me know if that works out! Preprelease: firebase.analytics-android-2.0.1.zip — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or mute the thread .
hansemannn commented 6 years ago

Sorry, I think your post is missing some screens / code.

trkfabi commented 6 years ago

Sorry. I have updated the post.

trkfabi commented 6 years ago

OMG, wait... I copied/pasted <module>firebase.analytics<module> from somewhere.... the closing tag is wrong!! (i'm crying). Sorry for wasting your time. I'll test this and report back if it works for Android.

hansemannn commented 6 years ago

I've just changed an activity reference to initialize the instance and now the app doesn't crash for me anymore. Unfortunately, I still receive the following logs on Android when logging with Analytics.log('test_event', {});.

It says:

[INFO]  FA: App measurement is starting up, version: 11020
[INFO]  FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
[ERROR] FA: GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.
[ERROR] FA: Scheduler not set. Not logging error/warn
[INFO]  FA: To enable faster debug mode event logging run:
[INFO]  FA:   adb shell setprop debug.firebase.analytics.app com.appc.firebasedemo
[ERROR] FA: AppMeasurementReceiver not registered/enabled
[ERROR] FA: AppMeasurementService not registered/enabled
[ERROR] FA: Uploading is not possible. App measurement disabled
[INFO]  FA: Tag Manager is not found and thus will not be used

Probably pasted the google-services.json incorrectly? I only personally tested the iOS version so far, so if we can get Android running together, we should be good!

trkfabi commented 6 years ago

I'm not an Android fan either. I got it working!!! by adding these services to the tiapp.xml under <application> tag: (replace mypackagename with your com.blabla.myapp)

<!-- this is to make FA work -->
<service android:name="com.google.android.gms.measurement.AppMeasurementService" android:enabled="true" android:exported="false"/>  

<receiver android:name="com.google.android.gms.measurement.AppMeasurementReceiver" android:enabled="true">
   <intent-filter>
      <action android:name="com.google.android.gms.measurement.UPLOAD" />
   </intent-filter>
</receiver>  

<service android:name="mypackagename.gcm.GcmIntentService" android:exported="false">
   <intent-filter>
      <action android:name="com.google.android.c2dm.intent.RECEIVE" />
   </intent-filter>
</service>

<service android:name="mypackagename.gcm.GcmIntentService" android:exported="false">
   <intent-filter>
      <action android:name="com.google.android.c2dm.intent.SEND" />
   </intent-filter>
</service>

<service android:name="mypackagename.gcm.GcmIDListenerService" android:exported="false">
   <intent-filter>
      <action android:name="com.google.android.gms.iid.InstanceID" />
   </intent-filter>
</service>

 <service android:name="mypackagename.gcm.RegistrationIntentService" android:exported="false"/>
<!-- this is to make FA work -->

and also had to add <string name="google_app_id">my firebase application id</string> to the string.xml file (still looking if there's a better place to set this prop, i.e: tiapp.xml like gsm.senderid) to get rid of this error:

[ERROR] FA: GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.
[ERROR] FA: Scheduler not set. Not logging error/warn

and DEBUG VIEW is also working: image

just run this command in a terminal to start debugging (genymotion emulator): ./adb shell setprop debug.firebase.analytics.app com.blabla.myapp

and to stop debugging: ./adb shell setprop debug.firebase.analytics.app .none.

trkfabi commented 6 years ago

Custom parameters are not working on Android. This sentence: Alloy.Globals.FirebaseAnalytics.log('logout', {username: "a4@a.com"});

logs this on Android: image

and this on iOS: image

hansemannn commented 6 years ago

Thanks @trkfabi, great progress! The custom events are only not working, because it right now checks for dedicated custom keys like ACHIEVEMENT_ID.

I think we can remove that check and just bridge all String keys to it. Let me see how other do that. I'll also update the readme today to reflect the installation steps.

hansemannn commented 6 years ago

Added an own paragraph for the installation here. Closing this issue, will likely do a PR to add custom events. Thanks again everyone for participating!

hansemannn commented 6 years ago

2.0.1 drafted, including an attempt to implement custom events: https://github.com/hansemannn/titanium-firebase-analytics/releases/tag/android-2.0.1

trkfabi commented 6 years ago

custom events are working fine with the latest 2.0.1. well done!

ghost commented 6 years ago

Excellent work! However, I had to add another service in the AndroidManifest section of the tiapp.xml file, this allowed the App Measurement Service to run:

<service android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementJobService" android:permission="android.permission.BIND_JOB_SERVICE"/>

Without this addition, I still received:

[ERROR] FA: AppMeasurementReceiver not registered/enabled
[ERROR] FA: AppMeasurementService not registered/enabled
hansemannn commented 6 years ago

Thanks @DGJMaxwell, added that note!

hansemannn commented 6 years ago

.. and an example app: https://github.com/hansemannn/titanium-firebase-demo

LilianAlvarez commented 6 years ago

I experimented the same issue reported by Fabian Martinez with firebase analytics. I can not figure it out how to setup firebase analytics.

I get the same error : GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.

I did add the 1:1XXXXXX:android:XXXXXXXX in platform/android/res/values

I added the google-services.json in assets/android

I added the require info in the tiapp.xml quoted below.

My Tiapp.xml :

ti.map : 4.0.0 (android) Latest ti.playservices latest firebase.core & firebase.analytics

trkfabi commented 6 years ago

I used to get this error, but it’s related to the google app id you added in res/values. It’s not finding it for some reason.

Can you share exactly how you added the tag and the name of the file under res/values folder?

El ene. 14, 2018, a la(s) 1:53 p. m., Lilian ALVAREZ notifications@github.com escribiĂł:

I experimented the same issue reported by Fabian Martinez with firebase analytics. I can not figure it out how to setup firebase analytics.

I get the same error : GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.

I did add the 1:1XXXXXX:android:XXXXXXXX in platform/android/res/values

I added the google-services.json in assets/android

I added the require info in the tiapp.xml My Tiapp.xml :

ti.map ti.map ti.playservices ti.cloud ti.cloudpush dk.napp.social firebase.core firebase.analytics facebook

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

LilianAlvarez commented 6 years ago

Here it is @trkfabi. In my strings.xml i added :

1:10XXXXXX3:android:XXXXXXXXXa

capture d ecran 2018-01-19 a 00 48 04

trkfabi commented 6 years ago

Try replacing the strings contents with:

1:10XXXXXX3:android:XXXXXXXXXa

El ene. 18, 2018, a la(s) 8:49 p. m., Lilian ALVAREZ notifications@github.com escribiĂł:

Here it is @trkfabi. In my strings.xml i added : 1:10XXXXXX3:android:XXXXXXXXXa

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

LilianAlvarez commented 6 years ago

I try and i still get the same error @trkfabi

[ERROR] FA: Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI

trkfabi commented 6 years ago

try adding it to:

app/i18n/en/string.xml
or app/i18n/es/string.xml

or the language folder you are using, as if it was just another language text id. (not the best but it may work)

On Jan 24, 2018, at 3:41 PM, Lilian ALVAREZ notifications@github.com wrote:

I try and i still get the same error @trkfabi https://github.com/trkfabi [ERROR] FA: Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI https://goo.gl/NAOOOI — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hansemannn/titanium-firebase-analytics/issues/10#issuecomment-360232555, or mute the thread https://github.com/notifications/unsubscribe-auth/ABffPfWm4U71tlY1ra7McBJlZXQRx5kZks5tN3lpgaJpZM4RCpWE.

LilianAlvarez commented 6 years ago

@trkfabi : thanks for the lead i got it work by using the international system.

Thanks a lot @trkfabi !