Cli: Incorrect package generated by cli.js

Created on 11 Sep 2019  Â·  6Comments  Â·  Source: react-native-community/cli

Environment

info Fetching system and libraries information...
System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
    Memory: 95.32 MB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.8.0 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
    Android SDK:
      API Levels: 26, 28, 29
      Build Tools: 28.0.2, 28.0.3, 29.0.2
      System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.5 => 0.60.5 
  npmGlobalPackages:
    create-react-native-app: 1.0.0
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7

Description

When I run: node ./node_modules/react-native/cli.js config I get the following output, see attached output (zipped json). See the incorrect snippet:

"android":{
   "sourceDir":"/Users/patricegagnon/_projects/my_test_spotify/node_modules/rn-spotify-sdk/android",
   "folder":"/Users/patricegagnon/_projects/my_test_spotify/node_modules/rn-spotify-sdk",
71 "packageImportPath":"import com.spotify.sdk.android.authentication.RNSpotifyPackage;",
   "packageInstance":"new RNSpotifyPackage()"
}

reactNativeConfigOutput.json.zip

At line 71, the package should be com.lufinkey.react.spotify.RNSpotifyPackage
instead of: com.spotify.sdk.android.authentication.RNSpotifyPackage

as described HERE. This incorrect package used land in MainApplication.java where we could change it. Now it lands in the generated PackageList.java which I can't overwrite.

To reproduce:

Either:

git clone https://github.com/patrice4github/test_spotify.git
npm install
react-native run-android

This is an empty application created with:

react-native init test_spotify
npm install react-native-events --save
npm install rn-spotify-sdk --save
Configured as described on the react-native-spotify readme

The error is this:

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/pg/_projects/my_test_spotify/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:19: error: cannot find symbol
import com.spotify.sdk.android.authentication.RNSpotifyPackage;
                                             ^
  symbol:   class RNSpotifyPackage
  location: package com.spotify.sdk.android.authentication
/Users/pg/_projects/my_test_spotify/android/app/src/main/java/com/my_test_spotify/PackageList.java:44: error: getApplication() has protected access in ReactNativeHost
    return this.reactNativeHost.getApplication();
                               ^
/Users/pg/_projects/my_test_spotify/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:54: error: cannot find symbol
      new RNSpotifyPackage()

Expected Results:

I'm not sure where this com.spotify.sdk.android,authentication package comes from. Neither, I don't know what cli.js runs. I'll gladly submit a PR if anyone can direct me in the direction where to look.

Thanks.

bug report

Most helpful comment

You can use it as:

// react-native.config.js
module.exports = {
  dependencies: {
    'your-package': {
      platforms: {
        android: { 
          packageImportPath: "correct import here;"
        }
      },
    },
  },
};

All 6 comments

You can use it as:

// react-native.config.js
module.exports = {
  dependencies: {
    'your-package': {
      platforms: {
        android: { 
          packageImportPath: "correct import here;"
        }
      },
    },
  },
};

Thanks for the workaround!
I'll wait a bit so someone directs me to final way to fix this.

Thanks!

-Patrice

On Wed, Sep 11, 2019 at 2:37 PM Michał Pierzchała notifications@github.com
wrote:

You can use it as:

// react-native.config.jsmodule.exports = {
dependencies: {
'your-package': {
platforms: {
android: {
packageImportPath: "correct import here;"
}
},
},
},
};

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/react-native-community/cli/issues/714?email_source=notifications&email_token=AANFW7VEUVAWKWOGP26SFK3QJE3F5A5CNFSM4IVXNRG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6PPENQ#issuecomment-530510390,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AANFW7SHA6XY4BRBP2GLLTTQJE3F5ANCNFSM4IVXNRGQ
.

I would look here: https://github.com/react-native-community/cli/blob/master/packages/platform-android/src/config/index.ts#L134

The packageName has the wrong value. We get it from AndroidManifest.xml here.

Looks like AndroidManifest.xml in the library has the correct value, so there must ve something off.

I would look into these places.

I am going to close this issue as it turned out to be issue with the Spotify package. I have sent a PR with a fix.

Cool, Thanks.

Was this page helpful?
0 / 5 - 0 ratings