hyperlab / TiMixpanel

Mixpanel integration for Titanium Mobile
22 stars 12 forks source link

Surveys and In-App Notifications on Android #13

Closed timanrebel closed 9 years ago

timanrebel commented 9 years ago

For Peerby I have been trying to get in-app notifications and surveys to work on both iOS and Android. In both I was unsuccessful, but luckily @inakiabt had more success with iOS.

With Android, I came a long way. I integrated the source of the Mixpanel SDK, including the assets, fixed the Ant build to prepare the source for use in the module and everything should work now, but it doesn't. It crashes on a support lib. I really could use some help to get this to work, so I can create the PR and get it to work on Android as well

My code is on: https://github.com/timanrebel/TiMixpanel/tree/feature/android-surveys/android

The error that I get is:

Error inflating class android.support.v7.internal.widget.ActionBarView, which is weird, because v7 is included in Titanium. Adding the support lib to the Mixpanel module causes another error, saying the lib is duplicate.

The full tracelog is:

[ERROR] TiApplication: (main) [47,21392] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{nl.rebelic.TestApp/com.mixpanel.android.surveys.SurveyActivity}: android.view.InflateException: Binary XML file line #35: Error inflating class android.support.v7.internal.widget.ActionBarView; Titanium 3.4.0,2014/09/25 16:42,b54c467
[ERROR] TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{nl.rebelic.TestApp/com.mixpanel.android.surveys.SurveyActivity}: android.view.InflateException: Binary XML file line #35: Error inflating class android.support.v7.internal.widget.ActionBarView
[ERROR] TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
[ERROR] TiApplication: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
[ERROR] TiApplication: at android.app.ActivityThread.access$800(ActivityThread.java:135)
[ERROR] TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
[ERROR] TiApplication: at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] TiApplication: at android.os.Looper.loop(Looper.java:136)
[ERROR] TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5017)
[ERROR] TiApplication: at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] TiApplication: at java.lang.reflect.Method.invoke(Method.java:515)
[ERROR] TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
[ERROR] TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
[ERROR] TiApplication: at dalvik.system.NativeStart.main(Native Method)
[ERROR] TiApplication: Caused by: android.view.InflateException: Binary XML file line #35: Error inflating class android.support.v7.internal.widget.ActionBarView
[ERROR] TiApplication: at android.view.LayoutInflater.createView(LayoutInflater.java:620)
[ERROR] TiApplication: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
[ERROR] TiApplication: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
[ERROR] TiApplication: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
[ERROR] TiApplication: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
[ERROR] TiApplication: at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
[ERROR] TiApplication: at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
[ERROR] TiApplication: at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
[ERROR] TiApplication: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
[ERROR] TiApplication: at android.app.Activity.setContentView(Activity.java:1929)
[ERROR] TiApplication: at com.mixpanel.android.surveys.SurveyActivity.onCreateSurvey(SurveyActivity.java:229)
[ERROR] TiApplication: at com.mixpanel.android.surveys.SurveyActivity.onCreate(SurveyActivity.java:79)
[ERROR] TiApplication: at android.app.Activity.performCreate(Activity.java:5231)
[ERROR] TiApplication: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
[ERROR] TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
[ERROR] TiApplication: ... 11 more
[ERROR] TiApplication: Caused by: java.lang.reflect.InvocationTargetException
[ERROR] TiApplication: at java.lang.reflect.Constructor.constructNative(Native Method)
[ERROR] TiApplication: at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[ERROR] TiApplication: at android.view.LayoutInflater.createView(LayoutInflater.java:594)
[ERROR] TiApplication: ... 25 more
[ERROR] TiApplication: Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.v7.internal.widget.ActionBarView$HomeView
[ERROR] TiApplication: at android.view.LayoutInflater.createView(LayoutInflater.java:620)
[ERROR] TiApplication: at android.view.Layout
[ERROR] TiApplication: at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
[ERROR] TiApplication: at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
[ERROR] TiApplication: at android.support.v7.internal.widget.ActionBarView.<init>(ActionBarView.java:218)
[ERROR] TiApplication: ... 28 more
[ERROR] TiApplication: Caused by: java.lang.reflect.InvocationTargetException
[ERROR] TiApplication: at java.lang.reflect.Constructor.constructNative(Native Method)
[ERROR] TiApplication: at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[ERROR] TiApplication: at android.view.LayoutInflater.createView(LayoutInflater.java:594)
[ERROR] TiApplication: ... 32 more
[ERROR] TiApplication: Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010010 a=-1}
[ERROR] TiApplication: at android.content.res.Resources.loadDrawable(Resources.java:2068)
[ERROR] TiApplication: at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
[ERROR] TiApplication: at android.view.View.<init>(View.java:3554)
[ERROR] TiApplication: at android.view.ViewGroup.<init>(ViewGroup.java:470)
[ERROR] TiApplication: at android.wid
jonatansberg commented 9 years ago

This is caused by a conflict between the bundled R class in Mixpanel and the one generated by Titanium. It's exactly the same kind of issue that I had with the Titanium Mapbox SDK.

Try removing the included R.java and add the following to the module manifest:

respackage: com.mixpanel.android
timanrebel commented 9 years ago

Ah, that was what you meant in the email. Thanks! Trying that right now

timanrebel commented 9 years ago

Eureka!

screenshot 2014-12-01 20 58 17

timanrebel commented 9 years ago

Will clean up, do some more tests and create a PR asap!

jonatansberg commented 9 years ago

Awesome! :D

timanrebel commented 9 years ago

I just found out I implemented time tracking for iOS as well, but my commits are all mixed into each other. Will redo the changes and create 2 PR's tomorrow!

deckameron commented 6 years ago

@timanrebel @mrlundis

I am having this issue with a module I am trying to create. Could you please help with this? I am new to it so I did not understand what you meant on this comment below. How exactly do I remove the R class? Where on the manifest do insert the line you suggested?

This is caused by a conflict between the bundled R class in Mixpanel and the one generated by Titanium. It's exactly the same kind of issue that I had with the Titanium Mapbox SDK.

Try removing the included R.java and add the following to the module manifest: respackage: com.mixpanel.android

Thank you!