Phonegap 3.4.0 fails to build new projects and update old projects - node.js

I recently updated phonegap, node, and npm. I have an existing project I previously built with Phonegap version 3.3.0. I then attempted to update my existing project using phonegap platform update ios and received an error stating that the '/platforms' directory does not exist.
I don't think it makes any difference, but I also tried to use the cordova command instead of the phonegap command, but I just get the same error as above. I even created a completely new project with phonegap create Test and I am able to get a project built successfully, but when I try to run/build I get a similar error: Error: /platforms does not exist. Please specify an existing parent folder. [error] /Users/mftcmbp1/.cordova/lib/ios/cordova/3.4.0/bin/create: Command failed with exit code 1 Even stranger, I am able to successfully create a project with the cordova command, build ios and android platforms, and emulate the project, yet I can't do this with the phonegap command like I could before I updated.Any help or suggestions of why this would be occurring will be helpful.
Thanks!

Not sure if there is a bug with Phonegap 3.4.0, but I fixed my issue by uninstalling the latest Phonegap version and installing Phonegap version 3.3.0-0.19.4.

1- you need to 'cd' to your project and add platform first before build
cd Test
2- then add platform
iOS
phonegap platform add ios
android
phonegap platform add android
3- then you can build your project
iOS
phonegap build ios
android
phonegap build android

I ran into this over the weekend, have you tried:
$ mkdir project_directory/platforms
As I remember it, that solved the issue as a hotfix.
The error occured after a project was cloned from github without the platforms directory.

I ran into the same issue, and it looks like an error in the update script, and specifically this file:
node_modules/phonegap/node_modules/cordova/src/util.js
The quick fix is, in the function isRootDir, to change "config.xml" to ".cordova", i.e.:
- if (fs.existsSync(path.join(dir, 'config.xml'))) {
+ if (fs.existsSync(path.join(dir, '.cordova'))) {
The old version identified the base project directory via the existence of the .cordova directory. The new version is incorrectly looking for a directory that contains these three items:
www/
config.xml
platforms/
config.xml should not be in the base directory, it's under www/, which is why it fails.
The script does have fail-safe, which is to look for www/config.xml. However, the way it does this is to continue traversing the tree towards root, and if at any time it finds another www/config.xml, will assume this is a better candidate for the project directory.
In your situation, I'm guessing you have a /www/config.xml off of your root directory, and PhoneGap is erroneously thinking that is your project directory.

Related

Android studio is giving the following error when I am trying to build a ionic project "Gradle sync failed: Sync failed: reason unknown"

I am trying to build a ionic project in Android studio on Ubuntu 20.04 . I am using the command ionic capacitor build then android studio opens up as expected then it shows this error Gradle sync failed: Sync failed: reason unknown. I am unable find a solution for this particular gradle sync error. I have reinstalled Ubuntu and other things but still the problem persists.
In my case, a fresh install of Android Studio resulted in Android 31 being the only SDK available but the project was targeting Android 30. I went to Tools > SDK Manager and made sure the appropriate version of Android SDK was installed and available. After restarting, and allowing the gradle sync to complete I was able to build/run the app on a virtual device, etc.
Here is what I found
This is the screenshot thanks for helping.
Capacitor lets you manage your own Android project. Like any IDE-backed project, sometimes things get so out of sync that the only solution is to rebuild the project.
To do this, follow these steps:
Copy any source code you created (such as Java files in app/android/src, manifest files, or resource files) into a safe location outside of app/android.
Next, make sure you are running an updated version of the Capacitor CLI:
npm install #capacitor/cli#latest
Remove the android directory:
rm -rf android/
Re-create the Android app from Capacitor:
npx cap add android
Copy your saved source files back into the project.
Check the error log. You should find something like "Module: 'mobile' platform 'android-30' not found" or something similar. Click Tools > SDK Manager and download the appropriate Android SDK Platform package.
on top right you will see option to view log file upon clicking there you will redirect to file manager and open idea file there
example :
open idea file and scroll down you will see actual issue.
In my case android sdk 31 was not installed.
I installed android sdk 31 from File>Settings>Apprearance and behaviour>system settings>android sdk and install required android sdk and rebuild the project.
accord to my observation in most cases you get this error because you have not required sdk installed in your system.

android studio error - Could not determine the dependencies of task ':app:installDebug'

While running the React Native Android app, then building the project the following error is shown:
Could not determine the dependencies of task ':app:installDebug'.
Go to android folder in your project and then type
gradlew clean for Windows and
./gradlew clean for Mac and Linux. I use this method every time I encounter the same problem, and also when changing the package.json (add / remove library)
Please remove build folder in /android/app and run build command again.
It worked for me.

Flutter create command was unsuccessful

I'm creating a new flutter project in Android studio for the first time. I give the project a name and choose Flutter sdk. I then clicked finish and then noting happened. Android studio says that
"Flutter create command was unsuccessful"
When I navigate to command directory using file explorer, I new folder is created with the project name I've given but it is empty.
Please help.
I don't think you installed flutter correctly. First and foremost, make sure you run flutter doctor from your terminal.
If it doesn't work then you didn't install flutter properly.
If it works, try creating your project via terminal by typing flutter create projectname
I hade the same issue in ubuntu
first, check flutter doctor and solve the error if there was
then check the git installation
in my case, I didn't install git
On Windows at least you need to add <flutter_dir>\bin to your path, and then restart Android Studio. It is not clear to me why Android Studio needs to know the location of the Flutter SDK if it doesn't then use that information but... :shrug:
Git also needs to be in the PATH too (as C:\Program Files\Git\cmd); I have always used git-bash just fine without that but now it seems to be a requirement that isn't clearly surfaced when upgrading.
In My case set the flutter sdk path first while create the app and then create the app

VS 2015 TACO - build broke on Xcode 8 / iOS 10

Here are the issues I encountered and fixed:
Code signing: downloaded the xcode8.js hook and added the following to build.json, per http://www.dpogue.ca/articles/cordova-xcode8.html:
"ios": {
"debug": {
"developmentTeam": "VZ4B5XSP9U"
},
"release": {
"developmentTeam": "VZ4B5XSP9U",
"codeSignIdentity": "iPhone Developer"
}
}
On my Mac, deleted the ~/.taco_home/node_modules/taco-remote-lib/2.2.1 and .../2.2.0 folders, per https://github.com/Microsoft/remotebuild/issues/5.
On my Mac, tried uninstalling and reinstalling remotebuild, and different versions of node and npm (0.12.9 and 4.6, and respective npm versions).
In Visual Studio, tried changing the targeted Cordova version: 6.3.1, 6.2, 6.1.1, and back to 5.4.1.
No matter what I do though, the build gets stuck either on extracted - Extracted app contents from uploaded build request, or building - Updating platform forever.
Earlier, when I tried opening the Xcode project in Xcode on the Mac, it successfully built and deployed the app to the device. I was then facing issues using WebRTC (using cordova-plugin-iosrtc) and it was giving me privacy violation exceptions. I tried adding the cordova-custom-config plugin and appropriate Cocoa keys (NSCameraUsageDescription and NSMicrophoneUsageDescription) per App crashes with __CRASHING_DUE_TO_PRIVACY_VIOLATION__ when trying to access contacts, and then it stopped working altogether.
Can anyone please advise what are the latest versions of all of the components I should be using to make it work again? Some sources advise to use Node 0.12.9 on the Mac, others 0.12.7; most people claim that with Cordova >= 5.3.3, any Node version should suffice, however using Node 4.6 didn't work either.
Thanks in advance for any help!
Update: After performing the brew update etc. as suggested by Jordan, the remote deploy works, but the build sets "Main interface" setting under project's General tab to "NSMainNibFile~ipad", which causes the app to crash on launch, until I open the project in Xcode and clear that field, then an incremental build creates a functioning app.
This is a known issue with Apache Cordova 6.3.1 and for the Visual Studio tools we've been working on a fix for this. To work around the issue for now, you'll need to perform the following steps:
Add a developmentTeam property to the ios build settings in your project's build.json file (an example is shown below).
Set the build.json file's codeSignIdentity property to the static value iPhone Developer.
Setup a before_compile hook in your project to copy the developmentTeam property into the project's platforms/ios/cordova/build.xcconfig file.
The project's build.json file should look something like the following:
{
"ios": {
"debug": {
"developmentTeam": "DEVELOPMENT_TEAM_NAME"
},
"release": {
"developmentTeam": "DEVELOPMENT_TEAM_NAME",
"codeSignIdentity": "iPhone Developer"
}
}
}
To simplify the process, Darryl Pogue published a sample hook that makes the required changes to the project's build.xconfig file based on the build.json example shown above. To use this hook, copy the sample xcode8.js file to your project's hooks folder, and then modify the project's config.xml to execute it before the compilation step using the following code:
<platform name="ios">
<hook type="before_compile" src="hooks/xcode8.js" />
</platform>
Creating a Distribution Build
At this point, the Cordova build process works, and you can run, test and debug your app. Unfortunately, the app isn't being signed with the correct development certificate needed for distribution. In order to sign them with a distribution certificate, you'll need to create an archive of the app by following the instructions found in: Uploading Your App to iTunes Connect.
iOS 10
Developers building Cordova applications for iOS 10 may encounter the following errors:
Http 404: Error mounting developer disk image
Http 500: No devices found to debug. Please ensure that a device is connected and awake and retry.
This is caused by the Mac development environment needing an update to several modules. To fix the issue, on Mac OS, open a terminal window and issue the following command:
brew update && brew upgrade libimobiledevice --HEAD && brew upgrade ios-webkit-debug-proxy ideviceinstaller

cordova hybrid app build fail with vs2013 up2 (chinese traditional)

I build cordova project with vs2013 up2 for windows phone platform and receive some error as follow , but build for ios & android is ok .
(1)Non-whitespace before first tag.
I found the js file "C:\Users\xxx\AppData\Roaming\npm\node_modules\vs-mda\node_modules\cordova\node_modules\plugman\src\util\xml-helpers.js" in line 124 command
var contents = fs.readFileSync(filename, 'utf-8').replace("\ufeff", "");
...is failing in chinese traditional environment, when building for windows phone platform the WMAppManifest.xml file has BOM code , so will be error as 嚙踝蕭??xml version="1.0" encoding="utf-8"?>, it should be <?xml version="1.0" encoding="utf-8"?>
have any idea can fix it ?
Thanks.
The issue you are seeing (issues.apache.org/jira/browse/CB-5477) was fixed in Cordova 3.5
(I'm a new poster and haven't earned the reputation points to include more than 2 links in my response, so I'm saving those for the ones that matter below).
If you update to the latest CTP 2.0 for Multi-Device Hybrid Apps, you will pick up the fix.
Unfortunately, there is an other Cordova issue that still exists in version 3.5 which also impacts WP8 in localized environments (https://issues.apache.org/jira/browse/CB-6932).
It has been fixed in Cordova version 3.6 which hasn't yet been released, but here's how you can pick up the fix.
After installing the new MDD tools, create an MDD project and build for WP8. (It will fail under Chinese as it did before.)
Now go into c:\Users\<username>\cordova\lib\wp\cordova\3.5.0\wp8\bin
Replace the existing create.js with the version from here
(click "Raw" to view just the file contents)
https://github.com/MSOpenTech/cordova-wp8/blob/ac097f2801d4defe5e4d445e10b7102001631a54/wp8/bin/create.js
Create a new project and build again for wp8. It should work now and future projects should work as well.
For me, it worked by removing android and adding again.
remove:
ionic platform rm android
add:
ionic platform add android
You can execute these commands at your project directory.

Resources