Could not invoke MixpanelReactNative.initialize
- Created a new react native project
- Added mixpanel library
- Added implementation "com.mixpanel.android:mixpanel-android:6.+"
- run the app with const mixpanel = new Mixpanel('project_token xxx'); mixpanel.init(); No static method getInstance(Landroid/content/Context;Ljava/lang/String;ZLorg/json/JSONObject;)Lcom/mixpanel/android/mpmetrics/MixpanelAPI; in class Lcom/mixpanel/android/mpmetrics/MixpanelAPI; or its super classes (declaration of 'com.mixpanel.android.mpmetrics.MixpanelAPI' appears in /data/app/~~2gP3FIgWwr0b60IHKNSN6w==/com.mixpanel-xZD8RMkKrKsq9xvdUl7FKw==/base.apk) at com.mixpanel.reactnative.MixpanelReactNativeModule.initialize(MixpanelReactNativeModule.java:39)
@medi-eng I'm not able to reproduce this error. However, please note that there is no need for step 3: Added implementation "com.mixpanel.android:mixpanel-android:6.+"
Per the official install instructions linked below, you only need to run npm install mixpanel-react-native from your app's root directory and pod install from your app's ios directory. You do not need to manually add anything to your gradle dependencies (or your Podfile).
https://github.com/mixpanel/mixpanel-react-native#1-install-mixpanel
Let me know if that doesn't clear things up.
The mixpanel-android dependency is already specified here: https://github.com/mixpanel/mixpanel-react-native/blob/master/android/build.gradle#L37
Because of some other libraries we need to use Mixpanel Native android libraries as well. Any idea how we can do that too?
package com.medbikri;
import android.content.Context; import android.util.Log;
import org.json.JSONObject;
import java.util.HashMap;
import io.hansel.ujmtracker.HanselInternalEventsListener;
import com.mixpanel.android.mpmetrics.MixpanelAPI;
public class MbHanselInternalEventTracker implements HanselInternalEventsListener { private Context mContext; public MbHanselInternalEventTracker(Context context){ mContext = context; } @Override public void onEvent(String eventName, HashMap dataFromHansel) { Log.i("HanselEventName",eventName); Log.i("HanselDataFromHansel",dataFromHansel.toString()); JSONObject jsonProperties = new JSONObject(dataFromHansel); MixpanelAPI mixpanel = MixpanelAPI.getInstance(mContext, mContext.getString(R.string.MIXPANEL_TOKEN)); mixpanel.track(eventName, jsonProperties); } }
On Thu, 14 Jul 2022 at 04:20, Jared McFarland @.***> wrote:
The mixpanel-android dependency is already specified here: https://github.com/mixpanel/mixpanel-react-native/blob/master/android/build.gradle#L37
— Reply to this email directly, view it on GitHub https://github.com/mixpanel/mixpanel-react-native/issues/151#issuecomment-1183758058, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASB535B5BF4BTJCHRH2HT53VT5B3LANCNFSM52VOXWSA . You are receiving this because you were mentioned.Message ID: @.***>
hi @medi-eng , sorry for the late response. Your way of integration is not supported by our SDK. However, we have just released a beta version, v3.0.0-beta.1. This version allows you to enable JavaScript mode when initializing Mixpanel, which should work with your case. For more details and installation guidelines, please refer to the release notes at Mixpanel React Native v3.0.0-beta.1. I'm consolidating all the similar issues, please use https://github.com/mixpanel/mixpanel-react-native/issues/82 or open a new one for any feedback or issues in 3.0.0-beta versions 🙏