Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Recursive search for package json file reads the latest version from npm cache instead of actual package json file from project #139

Closed
charlisi opened this issue Aug 23, 2024 · 3 comments
Labels
Support Please open a support ticket

Comments

@charlisi
Copy link

Report

Plugin Version

Any version

On what Platform are you having the issue?

Android
ℹ Please replace these two lines with the SDK version.
e.g. ios and android

What did you do?

I install the latest 6.15.0 on one branch, then check out an older branch using 6.13.1. From this point on the sdk returns 404 when initializing as is pointing to the latest backend on 6.15.0. It returns 404 because the app_id passed doesn't match as we use different app ids in debug.

ℹ Please replace these two lines with what you did.
pnpm install

What did you expect to happen?

I'd expect the plugin to read its own package json file, rather than crawl the npm cache.

ℹ Please replace these two lines with what you expected to happen.
Reading its own package.json

What happened instead?

Read the wrong package.json

Please provide any other relevant information.

@charlisi
Copy link
Author

A potential solution was proposed here in previous issue with monorepos:
#108

@pazlavi pazlavi added the Support Please open a support ticket label Aug 23, 2024
Copy link

👋 Hi @charlisi and Thank you for reaching out to us.
In order for us to provide optimal support, please submit a ticket to our support team at [email protected].
When submitting the ticket, please specify:

  • ✅ your AppsFlyer sign-up (account) email
  • ✅ app ID
  • ✅ production steps
  • ✅ logs
  • ✅ code snippets
  • ✅ and any additional relevant information.

@Dani-Koza-AF
Copy link
Collaborator

Hey @charlisi
Quick note on the branch switching issue: The lock file (package-lock.json or yarn.lock) overrides package.json for dependency versions to ensure consistent installs. This might cause inconsistencies when you switch to an older branch because the lock file will still reference newer versions.

When you checkout the older branch, the package manager checks the lock file and sees that it specifies the version "^6.15.0" for the "appsflyer-capacitor-plugin" plugin. This means that npm or Yarn will attempt to install version 6.15.0, even if the version specified in the package.json file is "^6.13.1". This is because the caret symbol (^) allows for compatible version updates within the same major version.

For the older branch to install the correct plugin versions:

  1. Remove the lock file from your directory.
  2. Run npm install or yarn install to regenerate the lock file based on the current package.json.
  3. Switch to the older branch.

As lock files are usually under version control, coordinate with your team on any changes.

Your monorepo project structure might contribute to the issue. I've made enhancements to the getPackageJsonPath() method and our Gradle script for better support. If issues persist, set the APPSFLYER_PACKAGE_JSON_PATH in variables.gradle as per our docs on GitHub for v6.15.2 which will be released in the following day.

If such Gradle issues continue, we might reconsider this feature to avoid future conflicts at the expense of update efficiency.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support Please open a support ticket
Projects
None yet
Development

No branches or pull requests

3 participants