Comments (1)
I create new project and add android platform. When I run 'sudo cordova build android' it build FAILED
TL;DR; Shouldn't use sudo. If you npm installed
or cordova plugin/platform add
with sudo
, then running without sudo
may be difficult. In which case you may want to delete your node_modules/
, plugins/
, and platforms/
so you can reinstall without sudo
. This makes all the files owned by your own user, not by the root
user.
When you run with sudo
(aka root) you may be running under a different environment. For example it looks like your Android SDK and JDK is installed for a local single user, v002024
, not the root
user.
While echo $ANDROID_HOME
and sudo echo $ANDROID_HOME
will produce a printout as expected. Running:
sudo su
echo $ANDROID_HOME
does not produce what you'd expect. Cordova launches several sub-processes including calling on gradle, java, and other binaries, so it's about the equivalent of doing the above. It won't have the environment variables that you set as expected. The root user account needs to be configured appropriately for this to work, HOWEVER, it's also not secure to be running under the root. You're running a lot of software that I'm sure you haven't vetted yourself, or it can change easily without you knowing. Using root for develpoment tools makes you very susceptible to supply chain attacks so it's advisable to install locally without the sudo
/root privileges.
If you've installed NodeJS through the official NodeJS channel, the NPM shipped is configured to install global packages in a directory where root is required to access. Which might be why you're using sudo
to begin with. If this is the case, have a read at fixing-npm-permissions.md, which allows you to reconfigure to a directory that your local user has read/write access to. This will avoid the sudo
requirement when installing global packages. After changing the install prefix, you will have to reinstall your global packages.
If you want to quickly confirm if this the issue without messing with your environment, try doing this:
cd ~/
cordova create testapp
cd testapp
cordova platform add android
cordova build android
The build should be successful, no sudo
was use.
from cordova-android.
Related Issues (20)
- Could not resolve com.android.tools.build:gradle:7.4.2 after update to cordova-android@12 HOT 2
- No matching variant of com.android.tools.build:gradle:7.4.2 was found HOT 1
- Mixed translations for native date picker on Android HOT 5
- Missing privateHelpers.extractStringFromManifest method. HOT 1
- Android 14 support ? HOT 1
- Incoming Call FullScreen Intent On A Cordova Activity HOT 1
- `ErrorURL` preference is not working HOT 2
- Will Cordova Android 13 support Kotlin 1.9.x ? HOT 2
- Failed to register a ServiceWorker with Cordova 10 HOT 6
- Target date for support to API34 HOT 2
- DevTools cannot display source map properly HOT 2
- cordova-android12.0.1 onRequestPermissionsResult never used HOT 1
- Cordova app on Android crashes after choosing file with native HTML file input, only on Android 13 HOT 3
- Update docs in regards to using adaptive icons with background colors HOT 3
- Splash screen icon not show at first launch HOT 1
- Execution failed for task ':app:mergeReleaseResources'. HOT 2
- Panoramic images HOT 1
- backgroundMode plugin quirks HOT 2
- Cordova undefined when AndroidInsecureFileModeEnabled set to false HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-android.