question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CLI 8.0.1-dev (cordova-lib@9.0.0-dev) can't install local platforms (iOS, Android)

See original GitHub issue

Currently fighting my way through https://github.com/apache/cordova-mobile-spec and using https://github.com/apache/cordova-coho to get everything locally - which means I am working with master of everything.

C:\Projects\throwaway\mobilespecAndroid  (helloworld@1.0.0)
λ cordova -v
8.0.1-dev (cordova-lib@9.0.0-dev)

Now I am having problems with installing the Android platform from a local folder (../cordova-android is the master checkout of cordova-android):

C:\Projects\throwaway\mobilespecAndroid  (helloworld@1.0.0)
λ cordova platform add ../cordova-android --verbose
Warning: using prerelease version 8.0.1-dev (cordova-lib@9.0.0-dev)
No scripts found for hook "before_platform_add".
fetch: Installing C:\Projects\throwaway\cordova-android to C:\Projects\throwaway\mobilespecAndroid
Running command: npm install C:\Projects\throwaway\cordova-android --production --save
Command finished with error code 0: npm install,C:\Projects\throwaway\cordova-android,--production,--save
Removing "cordova-" prefix from cordova-android
Warning: using prerelease platform android@8.0.0-dev.
Use 'cordova platform add android@latest' to add the latest published version instead.
Adding android project...
PlatformApi successfully found for platform android
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: io.cordova.hellocordova
        Name: HelloCordova
        Activity: MainActivity
        Android target: android-27
Copying android template project to platforms\android
Cannot find module 'cordova-common'
Error: Cannot find module 'cordova-common'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (C:\Projects\throwaway\mobilespecAndroid\platforms\android\cordova\lib\builders\builders.js:20:22)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

The same works from GitHub directly:

C:\Projects\throwaway\mobilespecAndroid  (helloworld@1.0.0)                                                                                                                                                     
λ cordova platform add https://github.com/apache/cordova-android --verbose                                                                                                                                      
Warning: using prerelease version 8.0.1-dev (cordova-lib@9.0.0-dev)                                                                                                                                             
No scripts found for hook "before_platform_add".                                                                                                                                                                
Using cordova-fetch for https://github.com/apache/cordova-android                                                                                                                                               
fetch: Installing https://github.com/apache/cordova-android to C:\Projects\throwaway\mobilespecAndroid                                                                                                          
Running command: npm install https://github.com/apache/cordova-android --production --save                                                                                                                      
Command finished with error code 0: npm install,https://github.com/apache/cordova-android,--production,--save                                                                                                   
Removing "cordova-" prefix from cordova-android                                                                                                                                                                 
Warning: using prerelease platform android@8.0.0-dev.                                                                                                                                                           
Use 'cordova platform add android@latest' to add the latest published version instead.                                                                                                                          
Adding android project...                                                                                                                                                                                       
PlatformApi successfully found for platform android                                                                                                                                                             
Creating Cordova project for the Android platform:                                                                                                                                                              
        Path: platforms\android                                                                                                                                                                                 
        Package: io.cordova.hellocordova                                                                                                                                                                        
        Name: HelloCordova                                                                                                                                                                                      
        Activity: MainActivity                                                                                                                                                                                  
        Android target: android-27                                                                                                                                                                              
Copying android template project to platforms\android                                                                                                                                                           
Subproject Path: CordovaLib                                                                                                                                                                                     
Subproject Path: app                                                                                                                                                                                            
Android project created with cordova-android@8.0.0-dev                                                                                                                                                          
Checking for any plugins added to the project that have not been installed in android platform                                                                                                                  
No differences found between plugins added to project and installed in android platform. Continuing...                                                                                                          
PlatformApi successfully found for platform android                                                                                                                                                             
Generating platform-specific config.xml from defaults for android at C:\Projects\throwaway\mobilespecAndroid\platforms\android\app\src\main\res\xml\config.xml                                                  
Merging project's config.xml into platform-specific android config.xml                                                                                                                                          
[Gradle Properties] Preparing Configuration                                                                                                                                                                     
[Gradle Properties] File missing, creating file with Cordova defaults.                                                                                                                                          
[Gradle Properties] Appended missing default: org.gradle.daemon=true                                                                                                                                            
[Gradle Properties] Appended missing default: org.gradle.jvmargs=-Xmx2048m                                                                                                                                      
[Gradle Properties] Appended missing default: android.useDeprecatedNdk=true                                                                                                                                     
[Gradle Properties] Updating and Saving File                                                                                                                                                                    
Merging and updating files from [www, platforms\android\platform_www] to platforms\android\app\src\main\assets\www                                                                                              
  mkdir platforms\android\app\src\main\assets\www\cordova-js-src                                                                                                                                                
  mkdir platforms\android\app\src\main\assets\www\cordova-js-src\android                                                                                                                                        
  copy  platforms\android\platform_www\cordova-js-src\android\nativeapiprovider.js platforms\android\app\src\main\assets\www\cordova-js-src\android\nativeapiprovider.js (new file)                             
  copy  platforms\android\platform_www\cordova-js-src\android\promptbasednativeapi.js platforms\android\app\src\main\assets\www\cordova-js-src\android\promptbasednativeapi.js (new file)                       
  copy  platforms\android\platform_www\cordova-js-src\exec.js platforms\android\app\src\main\assets\www\cordova-js-src\exec.js (new file)                                                                       
  copy  platforms\android\platform_www\cordova-js-src\platform.js platforms\android\app\src\main\assets\www\cordova-js-src\platform.js (new file)                                                               
  mkdir platforms\android\app\src\main\assets\www\cordova-js-src\plugin                                                                                                                                         
  mkdir platforms\android\app\src\main\assets\www\cordova-js-src\plugin\android                                                                                                                                 
  copy  platforms\android\platform_www\cordova-js-src\plugin\android\app.js platforms\android\app\src\main\assets\www\cordova-js-src\plugin\android\app.js (new file)                                           
  copy  platforms\android\platform_www\cordova.js platforms\android\app\src\main\assets\www\cordova.js (updated file)                                                                                           
  delete platforms\android\app\src\main\assets\www\img\cordova.png (no source)                                                                                                                                  
  copy  www\index.html platforms\android\app\src\main\assets\www\index.html (updated file)                                                                                                                      
  copy  www\js\index.js platforms\android\app\src\main\assets\www\js\index.js (updated file)                                                                                                                    
Wrote out android application name "HelloCordova" to C:\Projects\throwaway\mobilespecAndroid\platforms\android\app\src\main\res\values\strings.xml                                                              
android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.0): 10000                                                                                                    
Wrote out Android package name "io.cordova.hellocordova" to C:\Projects\throwaway\mobilespecAndroid\platforms\android\app\src\main\java\io\cordova\hellocordova\MainActivity.java                               
This app does not have launcher icons defined                                                                                                                                                                   
This app does not have splash screens defined                                                                                                                                                                   
This app does not have additional resource files defined                                                                                                                                                        
Prepared android project successfully                                                                                                                                                                           
No scripts found for hook "before_prepare".                                                                                                                                                                     
Checking config.xml and package.json for saved platforms that haven't been added to the project                                                                                                                 
Checking config.xml for saved plugins that haven't been added to the project                                                                                                                                    
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project                                                                                                                            
No scripts found for hook "before_plugin_add".                                                                                                                                                                  
Calling plugman.fetch on plugin "cordova-plugin-whitelist@1"                                                                                                                                                    
fetch: Installing cordova-plugin-whitelist@"1" to C:\Projects\throwaway\mobilespecAndroid                                                                                                                       
Running command: npm install cordova-plugin-whitelist@"1" --save                                                                                                                                                
Command finished with error code 1: npm install,cordova-plugin-whitelist@"1",--save                                                                                                                             
Failed to restore plugin "cordova-plugin-whitelist" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin cordova-plugin-whitelist@1 via registry.                              
Probably this is either a connection problem, or plugin spec is incorrect.                                                                                                                                      
Check your connection and plugin name/version/URL.                                                                                                                                                              
Error: npm: Command failed with exit code 1 Error output:                                                                                                                                                       
npm ERR! code EINVALIDTAGNAME                                                                                                                                                                                   
npm ERR! Invalid tag name ""1"": Tags may not have any characters that encodeURIComponent encodes.                                                                                                              
                                                                                                                                                                                                                
npm ERR! A complete log of this run can be found in:                                                                                                                                                            
npm ERR!     C:\Users\Jan\AppData\Roaming\npm-cache\_logs\2018-11-24T00_58_41_165Z-debug.log                                                                                                                    
Checking for any plugins added to the project that have not been installed in android platform                                                                                                                  
No differences found between plugins added to project and installed in android platform. Continuing...                                                                                                          
Generating platform-specific config.xml from defaults for android at C:\Projects\throwaway\mobilespecAndroid\platforms\android\app\src\main\res\xml\config.xml                                                  
Merging project's config.xml into platform-specific android config.xml                                                                                                                                          
[Gradle Properties] Preparing Configuration                                                                                                                                                                     
[Gradle Properties] Updating and Saving File                                                                                                                                                                    
Merging and updating files from [www, platforms\android\platform_www] to platforms\android\app\src\main\assets\www                                                                                              
  copy  platforms\android\platform_www\cordova-js-src\android\nativeapiprovider.js platforms\android\app\src\main\assets\www\cordova-js-src\android\nativeapiprovider.js (updated file)                         
  copy  platforms\android\platform_www\cordova-js-src\android\promptbasednativeapi.js platforms\android\app\src\main\assets\www\cordova-js-src\android\promptbasednativeapi.js (updated file)                   
  copy  platforms\android\platform_www\cordova-js-src\exec.js platforms\android\app\src\main\assets\www\cordova-js-src\exec.js (updated file)                                                                   
  copy  platforms\android\platform_www\cordova-js-src\platform.js platforms\android\app\src\main\assets\www\cordova-js-src\platform.js (updated file)                                                           
  copy  platforms\android\platform_www\cordova-js-src\plugin\android\app.js platforms\android\app\src\main\assets\www\cordova-js-src\plugin\android\app.js (updated file)                                       
  copy  platforms\android\platform_www\cordova.js platforms\android\app\src\main\assets\www\cordova.js (updated file)                                                                                           
  copy  www\index.html platforms\android\app\src\main\assets\www\index.html (updated file)                                                                                                                      
  copy  www\js\index.js platforms\android\app\src\main\assets\www\js\index.js (updated file)                                                                                                                    
Wrote out android application name "HelloCordova" to C:\Projects\throwaway\mobilespecAndroid\platforms\android\app\src\main\res\values\strings.xml                                                              
android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.0): 10000                                                                                                    
Wrote out Android package name "io.cordova.hellocordova" to C:\Projects\throwaway\mobilespecAndroid\platforms\android\app\src\main\java\io\cordova\hellocordova\MainActivity.java                               
This app does not have launcher icons defined                                                                                                                                                                   
This app does not have splash screens defined                                                                                                                                                                   
This app does not have additional resource files defined                                                                                                                                                        
Prepared android project successfully                                                                                                                                                                           
No scripts found for hook "after_prepare".                                                                                                                                                                      
Saving android@https://github.com/apache/cordova-android into platforms.json                                                                                                                                    
--save flag or autosave detected                                                                                                                                                                                
Saving android@https://github.com/apache/cordova-android into config.xml file ...                                                                                                                               
adding android to cordova.platforms array in package.json                                                                                                                                                       
No scripts found for hook "after_platform_add".                                                                                                                                                                                                                                                                                                                                                                              

So somehow installing from a local folder is broken.

My npm:

λ npm -v
6.4.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
dpoguecommented, Dec 3, 2018

@janpio Regarding the node_modules folder, see https://github.com/apache/cordova/issues/32

0reactions
raphinessecommented, Apr 11, 2019

I just ran the following commands on my machine successfully (extracted from your reproduction listing @janpio):

git clone http://github.com/apache/cordova-cli && cd cordova-cli
npm i
npm link
cd ..

git clone http://github.com/apache/cordova-android && cd cordova-android
npm i
cd ..

cordova create test1 && cd test1

cordova platform add ../cordova-android

Works for me, YMMV. Closing for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Platform Guide - Apache Cordova
This guide will help set up your development environment for building Cordova apps for Android devices and optionally use Android-specific command-line tools ...
Read more >
"Failed to install the following Android SDK packages as some ...
According to Android SDK docs you can use the following command depending on the sdkmanager location: Docs on --licenses option seems to be...
Read more >
Install Android Studio - Android Developers
Set up and install Android Studio on Windows, macOS, or Linux.
Read more >
Ionic Cordova Build for Android and iOS Platform Builds
The Cordova CLI requires a separator for platform-specific arguments for Android builds, so an additional separator is required for the Ionic CLI, but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found