hansemannn / titanium-firebase-analytics

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

Android Run Failed Due to Preconditions #22

Closed jwogan5 closed 6 years ago

jwogan5 commented 6 years ago

Update: I was trying to use firebase analytics 2.1.0 which gave all of the precondition errors below. I switched the code to use firebase analytics 2.0.1 and everything worked as it should. So the latest release of the module is what is throwing all of the precondition errors.

I am trying to use the Firebase Analytics module with Android. With the same setup I am able to use the Firebase Cloud Messaging module for Android but when I try to include the analytics the app loads but hangs on startup with the error at the bottom. I have read through every other issue on both the core and analytics modules and my setup seems to be what everyone else has got to work. Any help with this issue would be greatly appreciated.

I am using : Alloy File :

   var moment = require('alloy/moment');
   var FirebaseCore = require('firebase.core');
   var fca = require('firebase.analytics')
  var fcm = require('firebase.cloudmessaging');
  FirebaseCore.configure({file: 'google-services.json'});

Ti.App ( Commented Out All Other Modules)
-------------------------------------------
 <module platform="android" version="11.0.40">ti.playservices</module>
 <module version="2.2.0">firebase.core</module>
 <module version="2.0.1">firebase.analytics</module>
 <module version="1.0.2">firebase.cloudmessaging</module>

  Ti.APP SDK
 -------------
  <sdk-version>7.1.1.GA</sdk-version>

Ti.App Android Manifest
  -----------------------
 <service android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementService"/>
            <service android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementJobService" android:permission="android.permission.BIND_JOB_SERVICE"/>
            <service android:exported="false" android:name="com.commercial.imt2.gcm.RegistrationIntentService"/>
            <receiver android:enabled="true" android:name="com.google.android.gms.measurement.AppMeasurementReceiver">
                <intent-filter>
                    <action android:name="com.google.android.gms.measurement.UPLOAD"/>
                </intent-filter>
            </receiver>
            <service android:exported="false" android:name="com.commercial.imt2.gcm.GcmIntentService">
                <intent-filter>
                    <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                </intent-filter>
            </service>
            <service android:exported="false" android:name="com.commercial.imt2.gcm.GcmIntentService">
                <intent-filter>
                    <action android:name="com.google.android.c2dm.intent.SEND"/>
                </intent-filter>
            </service>
            <service android:exported="false" android:name="com.commercial.imt2.gcm.GcmIDListenerService">
                <intent-filter>
                    <action android:name="com.google.android.gms.iid.InstanceID"/>
                </intent-filter>
            </service>
            <service android:name="com.commercial.imt2.services.MyGcmListenerService" android:exported="false" >
              <intent-filter>
                  <action android:name="com.google.android.c2dm.intent.RECEIVE" />
              </intent-filter>
            </service>

    Strings.xml File Under Platform/Android/res/values
    --------------------------------------------------
   <?xml version="1.0" encoding="UTF-8"?>
1:475698257911:android:e672692e655ea311

Error:

W/System.err: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/Preconditions; [WARN] W/System.err: at com.google.android.gms.internal.measurement.zzgl.zzg(Unknown Source) [WARN] W/System.err: at com.google.firebase.analytics.FirebaseAnalytics.getInstance(Unknown Source) [WARN] W/System.err: at firebase.analytics.TitaniumFirebaseAnalyticsModule.analyticsInstance(TitaniumFirebaseAnalyticsModule.java:40) [WARN] W/System.err: at firebase.analytics.TitaniumFirebaseAnalyticsModule.setScreenNameAndScreenClass(TitaniumFirebaseAnalyticsModule.java:74) [WARN] W/System.err: at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) [WARN] W/System.err: at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:187) [WARN] W/System.err: at org.appcelerator.kroll.KrollRuntime.runModule(KrollRuntime.java:247) [WARN] W/System.err: at org.appcelerator.titanium.TiLaunchActivity.loadActivityScript(TiLaunchActivity.java:134) [WARN] W/System.err: at org.appcelerator.titanium.TiLaunchActivity.windowCreated(TiLaunchActivity.java:189) [WARN] W/System.err: at org.appcelerator.titanium.TiRootActivity.windowCreated(TiRootActivity.java:171) [WARN] W/System.err: at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:666) [WARN] W/System.err: at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:175) [WARN] W/System.err: at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:160) [WARN] W/System.err: at android.app.Activity.performCreate(Activity.java:6955) [WARN] W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) [WARN] W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927) [WARN] W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) [WARN] W/System.err: at android.app.ActivityThread.-wrap14(ActivityThread.java) [WARN] W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) [WARN] W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102) [WARN] W/System.err: at android.os.Looper.loop(Looper.java:154) [WARN] W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6776) [WARN] W/System.err: at java.lang.reflect.Method.invoke(Native Method) [WARN] W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) [WARN] W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) [WARN] W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.Preconditions" on path: DexPathList[[zip file "/data/app/com.comme rcial.imt2-1/base.apk"],nativeLibraryDirectories=[/data/app/com.commercial.imt2-1/lib/arm64, /data/app/com.commercial.imt2-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]] [WARN] W/System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) [WARN] W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:380) [WARN] W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:312) [WARN] W/System.err: ... 25 more [INFO] [LiveView] Error Evaluating app.js @ Line: undefined [ERROR] Failed resolution of: Lcom/google/android/gms/common/internal/Preconditions; [ERROR] File: app.js [ERROR] Line: undefined [ERROR] SourceId: undefined [ERROR] Backtrace: [ERROR] undefined

ERROR] FirebaseApp: Firebase API initialization failure. [ERROR] FirebaseApp: java.lang.reflect.InvocationTargetException [ERROR] FirebaseApp: at java.lang.reflect.Method.invoke(Native Method) [ERROR] FirebaseApp: at com.google.firebase.FirebaseApp.zza(Unknown Source) [ERROR] FirebaseApp: at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) [ERROR] FirebaseApp: at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) [ERROR] FirebaseApp: at firebase.core.TitaniumFirebaseCoreModule.configure(TitaniumFirebaseCoreModule.java:116)

[ERROR] FirebaseApp: at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) [ERROR] FirebaseApp: at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:187) [ERROR] FirebaseApp: at org.appcelerator.kroll.KrollRuntime.runModule(KrollRuntime.java:247) [ERROR] FirebaseApp: at org.appcelerator.titanium.TiLaunchActivity.loadActivityScript(TiLaunchActivity.java:134) [ERROR] FirebaseApp: at org.appcelerator.titanium.TiLaunchActivity.windowCreated(TiLaunchActivity.java:189) [ERROR] FirebaseApp: at org.appcelerator.titanium.TiRootActivity.windowCreated(TiRootActivity.java:171) [ERROR] FirebaseApp: at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:666) [ERROR] FirebaseApp: at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:175) [ERROR] FirebaseApp: at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:160) [ERROR] FirebaseApp: at android.app.Activity.performCreate(Activity.java:6955) [ERROR] FirebaseApp: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) [ERROR] FirebaseApp: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927) [ERROR] FirebaseApp: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) [ERROR] FirebaseApp: at android.app.ActivityThread.-wrap14(ActivityThread.java) [ERROR] FirebaseApp: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) [ERROR] FirebaseApp: at android.os.Handler.dispatchMessage(Handler.java:102) [ERROR] FirebaseApp: at android.os.Looper.loop(Looper.java:154) [ERROR] FirebaseApp: at android.app.ActivityThread.main(ActivityThread.java:6776) [ERROR] FirebaseApp: at java.lang.reflect.Method.invoke(Native Method) [ERROR] FirebaseApp: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) [ERROR] FirebaseApp: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) [ERROR] FirebaseApp: Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/Preconditions; [ERROR] FirebaseApp: at com.google.android.gms.internal.measurement.zzgl.zzg(Unknown Source) [ERROR] FirebaseApp: at com.google.android.gms.measurement.AppMeasurement.getInstance(Unknown Source) [ERROR] FirebaseApp: ... 26 more [ERROR] FirebaseApp: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.Preconditions" on path: DexPathList[[zip file "/data/app/com.commer cial.imt2-2/base.apk"],nativeLibraryDirectories=[/data/app/com.commercial.imt2-2/lib/arm64, /data/app/com.commercial.imt2-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]] [ERROR] FirebaseApp: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) [ERROR] FirebaseApp: at java.lang.ClassLoader.loadClass(ClassLoader.java:380) [ERROR] FirebaseApp: at java.lang.ClassLoader.loadClass(ClassLoader.java:312) [ERROR] FirebaseApp: ... 28 more

Astrovic commented 6 years ago

Have you find a solution?

jwogan5 commented 6 years ago

No, I just had to stick with 2.0.1 of the module.

Astrovic commented 6 years ago

If you haven't the necessity to use the resetAnalyticsData() method, I create a PR https://github.com/hansemannn/titanium-firebase-analytics/pull/24/files in witch you can use the FirebaseAnalytics.enabled property and it is compatible with the last firebase.core module. In my github fork you can download a pre-release: https://github.com/Astrovic/titanium-firebase-analytics/releases/tag/android-2.1.1

jwogan5 commented 6 years ago

Thank you for the build.

hansemannn commented 6 years ago

PR merged, thanks again @Astrovic !