How to integrate Firebase Analytics in ant-based project? - android

I've got a cocos2d-x project that uses Ant and for legacy reasons cannot be converted to Android Studio. How can I integrate Firebase Analytics to it?
Official docs offer only the way to use Android Studio, gradle, and the Play Services plugin for gradle.
This blogpost and this repo describe a way to include Firebase Analytics for Eclipse-based projects, which is close enough for me: I can include jar files and edit xml-s manually.
However, I've run into a couple of problems with this approach:
First, where do you put the values.xml file that's converted from google-services.json? Where is it used? I've copied those values into my res/values/strings.xml file, but I'm not sure if it's the correct way.
More important, after I've the build compiling and running on the device, it crashes with the following error in the logcat:
E/AndroidRuntime(18301): FATAL EXCEPTION: main
E/AndroidRuntime(18301): java.lang.NoClassDefFoundError: com.google.android.gms.R$string
E/AndroidRuntime(18301): at com.google.android.gms.common.internal.zzam.<init>(Unknown Source)
E/AndroidRuntime(18301): at com.google.firebase.FirebaseOptions.fromResource(Unknown Source)
E/AndroidRuntime(18301): at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
E/AndroidRuntime(18301): at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
E/AndroidRuntime(18301): at android.content.ContentProvider.attachInfo(ContentProvider.java:944)
E/AndroidRuntime(18301): at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
E/AndroidRuntime(18301): at android.app.ActivityThread.installProvider(ActivityThread.java:4237)
E/AndroidRuntime(18301): at android.app.ActivityThread.installContentProviders(ActivityThread.java:3992)
E/AndroidRuntime(18301): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3946)
E/AndroidRuntime(18301): at android.app.ActivityThread.access$1300(ActivityThread.java:123)
E/AndroidRuntime(18301): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
E/AndroidRuntime(18301): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(18301): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(18301): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime(18301): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(18301): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(18301): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(18301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(18301): at dalvik.system.NativeStart.main(Native Method)
Any ideas how to fix it?

Related

NoClassDefFoundError: com.google.firebase.FirebaseOptions (firebase and admob)

I am in troubled because:
java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1214)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1189)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4912)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4518)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4458)
at android.app.ActivityThread.access$1300(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5136)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
This generally happens when you are using google play-service dependency in your project.
Just downgrade the google play-service dependency to compile 'com.google.android.gms:play-services:8.3.0' and the problem may get solved.

android: The google maps 8.4.0 version is crashing for some devices

We're facing an issue with the maps is some phones. Here's the open issue in the google repo. None of the comments on the issue is helpful.
We are using 8.4.0 version and we have no clue how to fix or catch this crash.
This is hapening only in some devices example : LGE LG-P970 Android 4.0.4 API 15.
We're using the SupportMapFragment.
The stack trace is not giving any details:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at maps.dz.o.a(Unknown Source)
at maps.dg.e.a(Unknown Source)
at maps.dg.u.a(Unknown Source)
at maps.ei.ag.a(Unknown Source)
at maps.ei.bu.a(Unknown Source)
at maps.ei.n$1.a(Unknown Source)
at maps.ei.n.a(Unknown Source)
at com.google.android.gms.maps.internal.i$a.onTransact(:com.google.android.gms.alldynamite:107)
at android.os.Binder.transact(Binder.java:297)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment$zza.onCreateView(Unknown Source)
at com.google.android.gms.dynamic.zza$4.zzb(Unknown Source)
at com.google.android.gms.dynamic.zza.zza(Unknown Source)
at com.google.android.gms.dynamic.zza.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4516)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Did anybody face this issue? any fix (or work around) is welcome.
Thanks!
I observe this crash in activity which dynamically changes fragments when Android device connected to computer in USB debug mode. Without USB connection application works fine.
Stack trace is not very helpful:
java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$900(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5473)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at maps.dz.o.a(Unknown Source)
at maps.dg.e.a(Unknown Source)
at maps.dg.p.a(Unknown Source)
at maps.ei.ag.a(Unknown Source)
at maps.ei.bu.a(Unknown Source)
at maps.ei.n$1.a(Unknown Source)
at maps.ei.n.a(Unknown Source)
at com.google.android.gms.maps.internal.i$a.onTransact(:com.google.android.gms.alldynamite:107)
at android.os.Binder.transact(Binder.java:347)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment$zza.onCreateView(Unknown Source)
at com.google.android.gms.dynamic.zza$4.zzb(Unknown Source)
at com.google.android.gms.dynamic.zza.zza(Unknown Source)
at com.google.android.gms.dynamic.zza.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5244)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388) 
at android.app.ActivityThread.access$900(ActivityThread.java:148) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:5473) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:525) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622) 
at dalvik.system.NativeStart.main(Native Method) 
Device: Huawei G535-L11, Android 4.3
Workaround: disconnect device from USB before launching the app

Google Play Services NullPointerException

I know about java.lang.NullPointerException, but I got the following error from TestFairy the application that client already using: any one who face this problem please let me know how may I resolved this issue and why this issue generate,
java.lang.NullPointerException at
android.os.UserManager.getApplicationRestrictions(UserManager.java:614)
at com.google.android.gms.common.GooglePlayServicesUtil.zzah(Unknown
Source) at
com.google.android.gms.common.GooglePlayServicesUtil.zzj(Unknown
Source) at
com.google.android.gms.common.GoogleApiAvailability.zzj(Unknown
Source) at com.google.android.gms.internal.zzll.zza(Unknown Source)
at com.google.android.gms.internal.zzli.zzoe(Unknown Source) at
com.google.android.gms.internal.zzlf.onConnectionSuspended(Unknown
Source) at
com.google.android.gms.internal.zzli$2.onConnectionSuspended(Unknown
Source) at
com.google.android.gms.common.internal.zzj$zzb.handleMessage(Unknown
Source) at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:146) at
android.app.ActivityThread.main(ActivityThread.java:5756) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:515) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) at
dalvik.system.NativeStart.main(Native Method)

android.os.DeadObjectException Youtube Video with enabled ads

I am writing a sample program in which i am using Youtube API, and it works fine, but I noticed that application crashes every time I try to play a video with enabled ads.
Log:
FATAL EXCEPTION: main
java.lang.IllegalStateException: android.os.DeadObjectException
at com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer.a(SourceFile:516)
at com.google.android.apps.youtube.api.jar.a.a.a(SourceFile:485)
at com.google.android.youtube.player.internal.h.onTransact(SourceFile:413)
at android.os.Binder.transact(Binder.java:326)
at com.google.android.youtube.player.internal.d$a$a.a(Unknown Source)
at com.google.android.youtube.player.internal.s.a(Unknown Source)
at com.google.android.youtube.player.YouTubePlayerView.a(Unknown Source)
at com.google.android.youtube.player.YouTubePlayerView$1.a(Unknown Source)
at com.google.android.youtube.player.internal.r.g(Unknown Source)
at com.google.android.youtube.player.internal.r$c.a(Unknown Source)
at com.google.android.youtube.player.internal.r$b.a(Unknown Source)
at com.google.android.youtube.player.internal.r$a.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1036)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.os.DeadObjectException
at android.os.BinderProxy.transact(Native Method)
at com.google.android.apps.youtube.api.b.a.aq.a(SourceFile:706)
at com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer.a(SourceFile:513)
few Questions:
How can i resolve this issue ?
Is it possible to block the ad on Youtube Player API ?

Does the V2 Maps Library require the ACCESS_NETWORK_STATE permission?

I'm using the Android V2 Google Maps Library (Google Play Services) in my published app. I've been seeing sporadic exceptions show up in Google Play that seem to suggest the support map fragment occasionally tries to check the network state. However, the library documentation does not mention that this permission is required. I don't check the network state directly in my application, so I did not declare this permission. As a result a SecurityException is sometimes thrown when inflating the support map fragment:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.foo/com.foo.ui.TransactionDetailActivity}: android.view.InflateException: Binary XML file line #327: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #327: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.inflate(LayoutInflater.java:459)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(SourceFile:119)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SourceFile:262)
at com.foo.ui.TransactionDetailActivity.onCreate(SourceFile:129)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
... 11 more
Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10106 nor current process has android.permission.ACCESS_NETWORK_STATE.
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:623)
at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:425)
at maps.bm.e.e(Unknown Source)
at maps.bm.e.a(Unknown Source)
at maps.z.ag.a(Unknown Source)
at maps.z.ag.a(Unknown Source)
at maps.z.ag.a(Unknown Source)
at maps.z.bw.a(Unknown Source)
at maps.z.r.onCreateView(Unknown Source)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$Stub.onTransact(IMapFragmentDelegate.java:107)
at android.os.Binder.transact(Binder.java:310)
at com.google.android.gms.maps.a.l.a(Unknown Source)
at com.google.android.gms.maps.m.a(Unknown Source)
at com.google.android.gms.internal.ap.a(Unknown Source)
at com.google.android.gms.internal.al.a(Unknown Source)
at com.google.android.gms.internal.al.a(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:846)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1061)
at android.support.v4.app.FragmentManagerImpl.addFragment(SourceFile:1160)
at android.support.v4.app.FragmentActivity.onCreateView(SourceFile:272)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
... 28 more
I have declared the relevant permission in my manifest and will see if that fixes the problem. However, it's concerning that this would only happen on some devices and not others. For example, this has worked fine on our internal test devices and many others. Does anyone have any insight into this mysterious issue? Could it be caused by a proguard error?
Edit 1: This error occurred while using version 2.0.10 (541717-10) of the Google Play Services library.
With the latest release of the Google Play Services library the documentation has been updated to indicate this permission is required.
The release notes indicate why this permission is required:
Improved recovery from gaining network connectivity. This fix requires the ACCESS_NETWORK_STATE permission.
Yes. Any use of the getActiveNetworkInfo() method will require the network state access permission.
The following line in your Manifest should do the trick:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Categories

Resources