adjust / android_sdk

This is the Android SDK of
http://www.adjust.com
Other
593 stars 299 forks source link

Android SDK Webbridge, not all javascript files seem to be loaded correctly #607

Open revolucion opened 4 months ago

revolucion commented 4 months ago

Hi,

I have been trying to set up a web bridge connection to an Android app. I managed to get it working on iOS, so my setup in the web-app part seems to be working correctly.

Using Adjust Android SDK & web bridge version 4.38.5.

The build.gradle file has these 2 dependencies added:

    implementation 'com.adjust.sdk:adjust-android:4.38.5'
    implementation 'com.adjust.sdk:adjust-android-webbridge:4.38.5'

In my activity, I have the following lines, after setting up the webView:

        // Register adjust bridge
        AdjustBridge.registerAndGetInstance(getApplication(), webView);

So far, so good. Then on the web-app side, I have:

  const adjustAppToken = ********;
  const environment = AdjustConfig?.EnvironmentProduction;
  const adjustConfig = new AdjustConfig(adjustAppToken, environment);
  adjustConfig?.setLogLevel(AdjustConfig.LogLevelVerbose);

  // Track app did launch
  if (platform === 'ios') {
    Adjust.appDidLaunch(adjustConfig); // iOS
  }

  if (platform === 'android') {
    Adjust.onCreate(adjustConfig); // Android
  }

However, when I now check and debug my webview_bridge.js file (on the web-app side, where I handle the connection), both Adjust and AdjustConfig are undefined when checking them in the Chrome devtools console. Only AdjustBridge returns an object with methods. So it can't create a config, and it can't execute Adjust.onCreate.

I have checked the debugger, and it does have AdjustBridge, and I can call AdjustBridge.onCreate, but creating the config still doesn't work, as AdjustConfig is an undefined object. So in short, Adjust never initialises properly.

Since Android SDK 4.33.0, the requires javascript files are supposedly embedded in the JAR itself, so I suppose I don't need to add them to the HTML document either right? Also, since it does seem to recognise AdjustBridge as an object with methods, it would seem the setup is done correctly.

What am I missing? Or are there still bugs with the embedded javascript files?

Thanks. Wes