hansemannn / titanium-firebase-core

Use the Firebase Core SDK in the Titanium SDK 🚀
Other
31 stars 23 forks source link

Errors running firebase.core v2 on Android: "Failed to resolve target intent service" #10

Closed yahya-uddin closed 6 years ago

yahya-uddin commented 6 years ago

I am using Titanium 7.0.0 GA and Fire Base Core/ Analytics v2 for Android.

I have the following simple code in alloy.js:

var FirebaseCore = require("firebase.core");
FirebaseCore.configure({
    applicationID: "1:0123456789012:android:XXXXXXXXXXXXXXXX" // Assuming this is the App ID
});

However, I get the following errors on the console:

[ERROR] FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforceme
nt
[ERROR] FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
hansemannn commented 6 years ago

Please use the module correctly, see this link for reference).

yahya-uddin commented 6 years ago

Thanks for this. However, I didn't see that documented on any of the README files for the project or the official FireBase docs (correct me if I'm wrong).

Nonetheless I edited the tiapp.xml file to the following as suggested in the accepted answer of the StackOverflow link you provided:

...
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <application>
                    <service android:name="com.yahyauddin.example.gcm.GcmIntentService"
                           android:exported="false">
                        <intent-filter>
                            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                        </intent-filter>
                    </service>

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

            <service android:name="com.yahyauddin.example.gcm.RegistrationIntentService"
                               android:exported="false"/>
                     </application>
        </manifest>
    </android>
...

However, I get the following error:

[ERROR] TiApplication: (main) [13,1271] Sending event: exception on thread: main msg:java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file
 "/data/app/com.yahyauddin.example-2/base.apk"],nativeLibraryDirectories=[/data/app/com.yahyauddin.example-2/lib/arm64, /data/app/com.yahyauddin.example-2/base.apk!/lib
/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libfirebase.core.so"; Titanium 7.0.0,2017/12/05 13:30,undefined
[ERROR] TiApplication: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.yahyauddin.example-2/base.apk"],nativeLibraryD
irectories=[/data/app/com.yahyauddin.example-2/lib/arm64, /data/app/com.yahyauddin.example-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "lib
firebase.core.so"
[ERROR] TiApplication:  at java.lang.Runtime.loadLibrary0(Runtime.java:972)
[ERROR] TiApplication:  at java.lang.System.loadLibrary(System.java:1567)
[ERROR] TiApplication:  at org.appcelerator.kroll.runtime.v8.V8Runtime.loadExternalModules(V8Runtime.java:151)
[ERROR] TiApplication:  at org.appcelerator.kroll.runtime.v8.V8Runtime.initRuntime(V8Runtime.java:118)
[ERROR] TiApplication:  at org.appcelerator.kroll.KrollRuntime.doInit(KrollRuntime.java:205)
[ERROR] TiApplication:  at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:114)
[ERROR] TiApplication:  at org.appcelerator.kroll.KrollRuntime.init(KrollRuntime.java:136)
[ERROR] TiApplication:  at com.yahyauddin.example.ExampleApplication.onCreate(ExampleApplication.java:49)
[ERROR] TiApplication:  at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1032)
[ERROR] TiApplication:  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5876)
[ERROR] TiApplication:  at android.app.ActivityThread.-wrap3(ActivityThread.java)
[ERROR] TiApplication:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699)
[ERROR] TiApplication:  at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] TiApplication:  at android.os.Looper.loop(Looper.java:154)
[ERROR] TiApplication:  at android.app.ActivityThread.main(ActivityThread.java:6682)
[ERROR] TiApplication:  at java.lang.reflect.Method.invoke(Native Method)
[ERROR] TiApplication:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
[ERROR] TiApplication:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

In addition, the snippets of code in the link your provided doesn't seem to appear in any of the official docs, which indicates to me they are out of date (after all the answer was provided on Mar 2016). It also relates to GCM which has been deprecated by FireBase.

However, the official FireBase docs did mention some changes to the manifest file: https://firebase.google.com/docs/cloud-messaging/android/client?authuser=0#manifest

But this is for Cloud Messenging, which is a feature you don't yet support for Android: https://github.com/hansemannn/titanium-firebase-cloud-messaging

(And I only need FireBase for analytics for the time being)

Nonetheless I decided to change my tiapp.xml code to the following:

    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <application>
                     <service
                            android:name=".MyFirebaseInstanceIDService">
                            <intent-filter>
                                 <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
                             </intent-filter>
                       </service>
                   </application>
       </manifest>
    </android>

The above code looks more appropriate and seems to better relate to the error message I had in the original question. To recap, the original error message I had was:

[ERROR] FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforceme
nt
[ERROR] FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.

The above code actually specifies FirebaseInstanceId intent service, so it looks like I'm heading on the right track.

However, this then gives the error message:

[ERROR] TiApplication: (main) [42,42] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to instantiate service uk.co.thedealerapp.thedeale
r.MyFirebaseInstanceIDService: java.lang.ClassNotFoundException: Didn't find class "uk.co.thedealerapp.thedealer.MyFirebaseInstanceIDService" on path: DexPathList[[zip 
file "/data/app/uk.co.thedealerapp.thedealer-2/base.apk"],nativeLibraryDirectories=[/data/app/uk.co.thedealerapp.thedealer-2/lib/arm64, /data/app/uk.co.thedealerapp.the
dealer-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]; Titanium 7.0.0,2017/12/05 13:30,undefined
[ERROR] TiApplication: java.lang.RuntimeException: Unable to instantiate service uk.co.thedealerapp.thedealer.MyFirebaseInstanceIDService: java.lang.ClassNotFoundExcept
ion: Didn't find class "uk.co.thedealerapp.thedealer.MyFirebaseInstanceIDService" on path: DexPathList[[zip file "/data/app/uk.co.thedealerapp.thedealer-2/base.apk"],na
tiveLibraryDirectories=[/data/app/uk.co.thedealerapp.thedealer-2/lib/arm64, /data/app/uk.co.thedealerapp.thedealer-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib
64]]
[ERROR] TiApplication:  at android.app.ActivityThread.handleCreateService(ActivityThread.java:3449)
[ERROR] TiApplication:  at android.app.ActivityThread.-wrap6(ActivityThread.java)
[ERROR] TiApplication:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1721)
[ERROR] TiApplication:  at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] TiApplication:  at android.os.Looper.loop(Looper.java:154)
[ERROR] TiApplication:  at android.app.ActivityThread.main(ActivityThread.java:6682)
[ERROR] TiApplication:  at java.lang.reflect.Method.invoke(Native Method)
[ERROR] TiApplication:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
[ERROR] TiApplication:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
[ERROR] TiApplication: Caused by: java.lang.ClassNotFoundException: Didn't find class "uk.co.thedealerapp.thedealer.MyFirebaseInstanceIDService" on path: DexPathList[[z
ip file "/data/app/uk.co.thedealerapp.thedealer-2/base.apk"],nativeLibraryDirectories=[/data/app/uk.co.thedealerapp.thedealer-2/lib/arm64, /data/app/uk.co.thedealerapp.
thedealer-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
[ERROR] TiApplication:  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
[ERROR] TiApplication:  at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
[ERROR] TiApplication:  at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
[ERROR] TiApplication:  at android.app.ActivityThread.handleCreateService(ActivityThread.java:3446)
[ERROR] TiApplication:  ... 8 more

Please help! I am going through as many docs I can get my hands on, and I'm really not sure how to resolve this issue.

yahya-uddin commented 6 years ago

Any update on this?

yahya-uddin commented 6 years ago

Any update on this? Seems like this has been prematurely closed?

hansemannn commented 6 years ago

It is working fine for others, see this discussion. Please do not spam this closed thread.