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

Failed to install 'cordova-plugin-screen-orientation': Error: Expected plugin to have ID "es6-promise-plugin" but got "cordova-plugin-screen-orientation".on cordova prepare android #55

Closed
2 of 3 tasks
flipace opened this issue Jul 3, 2019 · 16 comments

Comments

@flipace
Copy link

flipace commented Jul 3, 2019

Bug Report

Problem

Since 3.0.2 cordova prepare android leads to this error (at least for us):

Installing "cordova-plugin-screen-orientation" for android
Failed to install 'cordova-plugin-screen-orientation': Error: Expected plugin to have ID "es6-promise-plugin" but got "cordova-plugin-screen-orientation".
    at checkID (/home/circleci/.config/yarn/global/node_modules/cordova-lib/src/plugman/fetch.js:203:15)
    at /home/circleci/.config/yarn/global/node_modules/cordova-lib/src/plugman/fetch.js:187:9
    at _fulfilled (/home/circleci/.config/yarn/global/node_modules/q/q.js:854:54)
    at /home/circleci/.config/yarn/global/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/home/circleci/.config/yarn/global/node_modules/q/q.js:816:13)
    at /home/circleci/.config/yarn/global/node_modules/q/q.js:624:44
    at runSingle (/home/circleci/.config/yarn/global/node_modules/q/q.js:137:13)
    at flush (/home/circleci/.config/yarn/global/node_modules/q/q.js:125:13)
    at process._tickCallback (internal/process/next_tick.js:61:11)
Failed to restore plugin "cordova-plugin-screen-orientation" from config.xml. You might need to try adding it again. Error: Error: Expected plugin to have ID "es6-promise-plugin" but got "cordova-plugin-screen-orientation".

Setting the version to 3.0.1 fixes the problem for us.

What is expected to happen?

cordova prepare android / plugin installation works without errors.

What does actually happen?

The error above.

Command or Code

cordova prepare android

Environment, Platform, Device

Android, built on CircleCI

Version information

cordova-android@7.1.1
cordova-plugin-screen-orientation@^3.0.1

Checklist

  • I searched for existing GitHub issues
  • I included all the necessary information above
  • I updated all Cordova tooling to most recent version -> we did not yet upgrade to cordova-android@8.0.0
@flipace flipace changed the title 3.0.2 causes error on prepare 3.0.2 causes error on cordova prepare android Jul 3, 2019
@janpio
Copy link
Member

janpio commented Jul 3, 2019

Investigating.

@janpio janpio self-assigned this Jul 3, 2019
@janpio
Copy link
Member

janpio commented Jul 3, 2019

Can not reproduce:

E:\Projects\throwaway
λ cordova create cordovaScreenOrientation302
Creating a new cordova project.

E:\Projects\throwaway
λ cd cordovaScreenOrientation302\

E:\Projects\throwaway\cordovaScreenOrientation302  (helloworld@1.0.0)
λ cordova platform add android
Using cordova-fetch for cordova-android@^8.0.0
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: io.cordova.hellocordova
        Name: HelloCordova
        Activity: MainActivity
        Android target: android-28
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@8.0.0
Plugin 'cordova-plugin-whitelist' found in config.xml... Migrating it to package.json
Discovered saved plugin "cordova-plugin-whitelist". Adding it to the project
Installing "cordova-plugin-whitelist" for android
Adding cordova-plugin-whitelist to package.json
E:\Projects\throwaway\cordovaScreenOrientation302  (helloworld@1.0.0)
λ cordova plugin add cordova-plugin-screen-orientation
Installing "cordova-plugin-screen-orientation" for android
Installing "es6-promise-plugin" for android
Adding cordova-plugin-screen-orientation to package.json

E:\Projects\throwaway\cordovaScreenOrientation302  (helloworld@1.0.0)
λ cordova prepare android

E:\Projects\throwaway\cordovaScreenOrientation302  (helloworld@1.0.0)                                                                    
λ cordova build android                                                                                                                  
Checking Java JDK and Android SDK versions                                                                                               
ANDROID_SDK_ROOT=undefined (recommended setting)                                                                                         
ANDROID_HOME=C:\Users\Jan\AppData\Local\Android\sdk (DEPRECATED)                                                                         
Starting a Gradle Daemon (subsequent builds will be faster)                                                                              
                                                                                                                                         
BUILD SUCCESSFUL in 1m 12s                                                                                                               
1 actionable task: 1 executed                                                                                                            
Subproject Path: CordovaLib                                                                                                              
Subproject Path: app                                                                                                                     
Starting a Gradle Daemon (subsequent builds will be faster)                                                                              
> Task :app:preBuild UP-TO-DATE                                                                                                          
> Task :CordovaLib:preBuild UP-TO-DATE                                                                                                   
> Task :CordovaLib:preDebugBuild UP-TO-DATE                                                                                              
> Task :CordovaLib:checkDebugManifest                                                                                                    
> Task :CordovaLib:processDebugManifest                                                                                                  
> Task :app:preDebugBuild                                                                                                                
> Task :CordovaLib:compileDebugAidl NO-SOURCE                                                                                            
> Task :app:compileDebugAidl NO-SOURCE                                                                                                   
> Task :CordovaLib:packageDebugRenderscript NO-SOURCE                                                                                    
> Task :app:compileDebugRenderscript                                                                                                     
> Task :app:checkDebugManifest                                                                                                           
> Task :app:generateDebugBuildConfig                                                                                                     
> Task :app:prepareLintJar                                                                                                               
> Task :app:generateDebugSources                                                                                                         
> Task :CordovaLib:compileDebugRenderscript                                                                                              
> Task :CordovaLib:generateDebugBuildConfig                                                                                              
> Task :CordovaLib:generateDebugResValues                                                                                                
> Task :CordovaLib:generateDebugResources                                                                                                
> Task :CordovaLib:packageDebugResources                                                                                                 
> Task :CordovaLib:generateDebugRFile                                                                                                    
> Task :CordovaLib:prepareLintJar                                                                                                        
> Task :CordovaLib:generateDebugSources                                                                                                  
> Task :CordovaLib:javaPreCompileDebug                                                                                                   
                                                                                                                                         
Note: E:\Projects\throwaway\cordovaScreenOrientation302\platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemCookieManager.ja
 or overrides a deprecated API.                                                                                                          
Note: Recompile with -Xlint:deprecation for details.                                                                                     
> Task :CordovaLib:compileDebugJavaWithJavac                                                                                             
                                                                                                                                         
> Task :CordovaLib:processDebugJavaRes NO-SOURCE                                                                                         
> Task :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug                                                       
> Task :app:javaPreCompileDebug                                                                                                          
> Task :app:mainApkListPersistenceDebug                                                                                                  
> Task :app:generateDebugResValues                                                                                                       
> Task :app:generateDebugResources                                                                                                       
> Task :app:mergeDebugResources                                                                                                          
> Task :app:createDebugCompatibleScreenManifests                                                                                         
> Task :app:processDebugManifest                                                                                                         
> Task :app:processDebugResources                                                                                                        
> Task :app:compileDebugJavaWithJavac                                                                                                    
> Task :app:compileDebugNdk NO-SOURCE                                                                                                    
> Task :app:compileDebugSources                                                                                                          
> Task :app:mergeDebugShaders                                                                                                            
> Task :app:compileDebugShaders                                                                                                          
> Task :app:generateDebugAssets                                                                                                          
> Task :CordovaLib:mergeDebugShaders                                                                                                     
> Task :CordovaLib:compileDebugShaders                                                                                                   
> Task :CordovaLib:generateDebugAssets                                                                                                   
> Task :CordovaLib:packageDebugAssets                                                                                                    
> Task :app:mergeDebugAssets                                                                                                             
> Task :app:validateSigningDebug                                                                                                         
> Task :app:signingConfigWriterDebug                                                                                                     
> Task :app:transformClassesWithDexBuilderForDebug                                                                                       
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug                                                                         
> Task :app:transformDexArchiveWithDexMergerForDebug                                                                                     
> Task :app:mergeDebugJniLibFolders                                                                                                      
> Task :CordovaLib:compileDebugNdk NO-SOURCE                                                                                             
> Task :CordovaLib:mergeDebugJniLibFolders                                                                                               
> Task :CordovaLib:transformNativeLibsWithMergeJniLibsForDebug                                                                           
> Task :CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug                                                                    
> Task :app:transformNativeLibsWithMergeJniLibsForDebug                                                                                  
> Task :app:processDebugJavaRes NO-SOURCE                                                                                                
> Task :app:transformResourcesWithMergeJavaResForDebug                                                                                   
> Task :app:packageDebug                                                                                                                 
> Task :app:assembleDebug                                                                                                                
> Task :app:cdvBuildDebug                                                                                                                
                                                                                                                                         
BUILD SUCCESSFUL in 2m 48s                                                                                                               
42 actionable tasks: 42 executed                                                                                                         
Built the following apk(s):                                                                                                              
        E:\Projects\throwaway\cordovaScreenOrientation302\platforms\android\app\build\outputs\apk\debug\app-debug.apk                    

Can you help me understand what I am doing differently?
Can you reproduce the problem in a new, clean Cordova project?


es6-promise-plugin was added quite some time ago in version 2.0.2 of this plugin: https://github.com/apache/cordova-plugin-screen-orientation/pull/15/files, #15, https://github.com/apache/cordova-plugin-screen-orientation/blob/fea37d15ca8188e3777e87cabcdaa1784a8e7cc3/RELEASENOTES.md#202-nov-06-2017

The changes of 3.0.2 do not contain anything related to this plugin: 3.0.1...3.0.2 To be honest there are not real code changes at all except 1 tiny bugfix, the rest is CI configuration.

@janpio
Copy link
Member

janpio commented Jul 3, 2019

Same for Android 7.1.1 by the way:

E:\Projects\throwaway\cordovaScreenOrientation302  (helloworld@1.0.0)
λ cordova platform add android@7.1.1
Using cordova-fetch for cordova-android@7.1.1
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: io.cordova.hellocordova
        Name: HelloCordova
        Activity: MainActivity
        Android target: android-27
Android project created with cordova-android@7.1.1
Android Studio project detected
Android Studio project detected
Installing "cordova-plugin-screen-orientation" for android
Plugin dependency "es6-promise-plugin@4.2.2" already fetched, using that version.
Installing "es6-promise-plugin" for android
Installing "cordova-plugin-whitelist" for android
Dependent plugin "es6-promise-plugin" already installed on android.

E:\Projects\throwaway\cordovaScreenOrientation302  (helloworld@1.0.0)
λ cordova prepare android
Android Studio project detected

E:\Projects\throwaway\cordovaScreenOrientation302  (helloworld@1.0.0)
λ cordova plugin rm cordova-plugin-screen-orientation
Uninstalling 1 dependent plugins.
Uninstalling es6-promise-plugin from android
Android Studio project detected
Uninstalling cordova-plugin-screen-orientation from android
Removing "cordova-plugin-screen-orientation"
Removing cordova-plugin-screen-orientation from package.json

E:\Projects\throwaway\cordovaScreenOrientation302  (helloworld@1.0.0)
λ cordova plugin add cordova-plugin-screen-orientation
Installing "cordova-plugin-screen-orientation" for android
Plugin dependency "es6-promise-plugin@4.2.2" already fetched, using that version.
Installing "es6-promise-plugin" for android
Android Studio project detected
Adding cordova-plugin-screen-orientation to package.json

@flipace
Copy link
Author

flipace commented Jul 3, 2019

@janpio thanks for investigating. i will try to find out what causes the different behavior in our setup. it appears to work for me with a clean project as well but not with our larger config with multiple plugins.

since there have not been any changes related to es6-promise-plugin i guess that this may have more to do with some cordova-lib stuff? I checked the part in plugman/fetch.js where the error is thrown and added a console.log:

Discovered plugin "cordova-plugin-screen-orientation" in config.xml. Adding it to the project
Installing "cordova-plugin-screen-orientation" for android
{
  parsedSpec: PluginSpec {
    scope: null,
    id: 'es6-promise-plugin',
    version: null,
    package: 'es6-promise-plugin'
  },
  pinfo: PluginInfo {
    getPreferences: [Function: getPreferences],
    getAssets: [Function: getAssets],
    getDependencies: [Function: getDependencies],
    getConfigFiles: [Function: getConfigFiles],
    getEditConfigs: [Function: getEditConfigs],
    getInfo: [Function: getInfo],
    getSourceFiles: [Function: getSourceFiles],
    getHeaderFiles: [Function: getHeaderFiles],
    getResourceFiles: [Function: getResourceFiles],
    getLibFiles: [Function: getLibFiles],
    getHookScripts: [Function: getHookScripts],
    getJsModules: [Function: getJsModules],
    getEngines: [Function],
    getPlatforms: [Function],
    getPlatformsArray: [Function],
    getFrameworks: [Function],
    getFilesAndFrameworks: [Function: getFilesAndFrameworks],
    filepath: '/d/project/node_modules/cordova-plugin-screen-orientation/plugin.xml',
    dir: '/d/project/node_modules/cordova-plugin-screen-orientation',
    _et: ElementTree { _root: [Element] },
    id: 'cordova-plugin-screen-orientation',
    version: '3.0.2',
    name: 'Screen Orientation',
    description: 'Cordova Screen Orientation plugin',
    license: 'Apache 2.0',
    repo: undefined,
    issue: undefined,
    keywords: undefined,
    info: undefined,
    getKeywordsAndPlatforms: [Function]
  }
}
Failed to install 'cordova-plugin-screen-orientation': Error: Expected plugin to have ID "es6-promise-plugin" but got "cordova-plugin-screen-orientation".
    at checkID (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:215:15)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:199:9
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:787:54)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:816:30
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:749:13)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:557:44
    at flush (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:108:17)
    at processTicksAndRejections (internal/process/task_queues.js:82:9)
Failed to restore plugin "cordova-plugin-screen-orientation" from config.xml. You might need to try adding it again. Error: Error: Expected plugin to have ID "es6-promise-plugin" but got "cordova-plugin-screen-orientation".

(using cordova@8.0.0 here)

feel free to close the issue though, since it's apparently not related to this plugins update

@janpio
Copy link
Member

janpio commented Jul 3, 2019

Did you try the new project with CLI 8.0.0? That's the one variable I didn't try as I missed that in your post.

This plugin here is probably special in that it has a plugin as a dependency - not many of the core plugins have that.

@flipace
Copy link
Author

flipace commented Jul 3, 2019

@janpio yes, i tried it with cli 8.0.0 on the new project (worked).

on the project where it breaks i tried with 8.0.0 and 8.1.2 - couldn't yet check 9+ since there's a hook which breaks due to requireCordovaModule('q') failing on the newer version.

@Stephane84
Copy link

Stephane84 commented Jul 3, 2019

I had a similar issue today, but not with same version.
cordova-android@6.4.0
cordova-plugin-screen-orientation 3.0.1 (not 3.0.2)
cordova CLI 8.0.0

i obtain the same stack for 'cordova prepare android' during plugin research :

Installing "cordova-plugin-screen-orientation" for android
Failed to install 'cordova-plugin-screen-orientation': Error: Expected plugin to have ID "es6-promise-plugin" but got "cordova-plugin-screen-orientation".
    at checkID (C:\Dev\tools\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\fetch.js:215:15)
    at C:\Dev\tools\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\fetch.js:199:9
    at _fulfilled (C:\Dev\tools\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (C:\Dev\tools\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)
    at Promise.promise.promiseDispatch (C:\Dev\tools\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:749:13)
    at C:\Dev\tools\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:557:44
    at flush (C:\Dev\tools\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:108:17)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
Failed to restore plugin "cordova-plugin-screen-orientation" from config.xml. You might need to try adding it again. Error: Error: Expected plugin to have ID "es6-promise-plugin" but got "cordova-plugin-screen-orientation".

changing to cordova-plugin-screen-orientation 3.0.2 solve the problem.
Strange...

@janpio
Copy link
Member

janpio commented Jul 3, 2019

Thanks @Stephane84, that is really strange. But at least we know it is not caused by the new version. What CLI version are you using?

@janpio janpio changed the title 3.0.2 causes error on cordova prepare android Failed to install 'cordova-plugin-screen-orientation': Error: Expected plugin to have ID "es6-promise-plugin" but got "cordova-plugin-screen-orientation".on cordova prepare android Jul 3, 2019
@janpio
Copy link
Member

janpio commented Jul 3, 2019

(I renamed the issue to reflect the problem better - this way we can keep it open and investigate further.)

@Stephane84
Copy link

Stephane84 commented Jul 3, 2019

Thanks @Stephane84, that is really strange. But at least we know it is not caused by the new version. What CLI version are you using?

cordova CLI 8.0.0

node 6.9.5
npm 5.6.0
ionic CLI 3.20.0

@Stephane84
Copy link

Another try today, updating cordova-android from 6.4.0 to 8.0.0
cordova-plugin-screen-orientation 3.0.1 work now (it doesn't with 6.4.0)

I notice that this fix : #25 make my application turning on the other direction (left right inversed) than before (between 3.0.1 and 3.0.2)

@janpio
Copy link
Member

janpio commented Jul 4, 2019

I notice that this fix : #25 make my application turning on the other direction (left right inversed) than before (between 3.0.1 and 3.0.2)

Could you please create a new issue for this? The PR was considered a bugfix, maybe this was not correct. But let's discuss this in a new issue.

@shesek
Copy link

shesek commented Jul 6, 2019

I'm experiencing the same error. Can be seen here: https://travis-ci.org/shesek/spark-wallet/builds/555012772

These are the configuration files: config.xml, package.json

@Stephane84
Copy link

Stephane84 commented Jul 17, 2019

it seems that cordova only take the version specified in config.xml for the plugins, and not in package.json (nor package-lock.json)

For my app, i found that version of cordova-plugin-screen-orientation was not the same beetween node_modules folder (npm) and plugins folder (cordova).

Maybe there is a bug in this situation (i don't understand why).

if you fixe the version everywhere (without ^ or ~) it seems to work again.

Could you test it ? in package.json package-lock.json and config.json for 3.0.1 or 3.0.2

I don't remember all the tests i've done, but maybe, the order of the insctructions are importent during the build

  • npm run build
  • ionic3 cordova platform add android@8.0.0
  • cordova build android --release

maybe in the past i had different order like :

  • ionic3 cordova platform add android@8.0.0
  • npm run build
  • cordova build android --release

and this doesn't work

If it helps someone...

@jcesarmobile
Copy link
Member

This is a cordova-cli issue, not plugin issue. Since all comments are using an old version if the CLI it might be fixed.
But if it's not, report it on cordova-cli repo

@Sampath-Lokuge
Copy link

This works for me: npm i es6-promise-plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants