Cordova - cordova platform add android access denied - android

I recently have setup my dev environment to work with Phonegap/Cordova and I am getting a weird success when I add the android platform
I run the command cordova platform add android, it goes through doing its thing and right before it tells me Project successfully created it has Access is denied.
Any ideas? is this an issue?
full cli log including commands:
http://pastebin.com/RBcSgyAJ

Looks quite similar to the issue stated here. Most likely an Antivirus problem, try to disable it temporarily and execute the cordova platform add android command again.
Also, I noticed that your drive volume is J:, is this a network drive? That could also lead to problems.

Related

Connection to the server was unsuccessful

I can't run Android APK of my ionic apps on my tablets (Android version 4.4), I get the connection unsuccessful error. I have no idea why, it happens even if I start a ionic project from scratch and run the apk without modifying anything in the project. Weird thing is..I can run it on my Xperia celphone and also if I emulate a Nexus 9 tablet with android studio the Apk also works. How can I fix this? maybe build the apk with older android api? is there a way of doing this, or isn't this related?
Already tried setting loadUrlTimeoutValue to a high number, makes no difference.
Aaaaaaaaaaaaaaaaaaaaaaaaah finally got it FFS, had to add cordova crosswalk plugin to make it work. Followed this > https://github.com/codyteng/ionic2-android-crosswalk
ionic plugin add cordova-plugin-crosswalk-webview
ionic platform add android
ionic run android

Ionic build succeeds but does not create .apk file

I was always able to build from this project, this just started happening this morning. When I run ionic build android everything runs smoothly and the build succeeds, but the date modified on the android-debug.apk file stays the same, and I don't see my changes when I run it on a device.
Could it have something to do with messed up permissions and somehow it doesn't have permission to write the apk? I'm running Ubuntu-server 14.04.4.
I know it's been answered before but I'm adding this to let you guys know what I've tried and how it's not working anyways...
I've also faced same issue and tried several things like
Renaming APK file, expecting it will create new one.
Deleting build folder, expecting as usual will create new one.
opening project in Android studio, expecting it will create new one when I use it to launch the APK to device.
I've tried calling ionic prepare platform before calling ionic build.
The ionic build is a proxy for cordova build command.
But in this issue all of above approaches were failed.
The reason I can see behind this is because of no proper response/function of added platform to your project, as when you build it's cordova platform android's responsibility to prepare build on your command. Which is not working.
Lot of people suggests that You need to us ionic/cordova restore, this will restore your state.
Another way is you can use Android Studio's build APK option which helps you not to disturb your plugins by restore or reset commands.
Hope this helps you save your time from trying all these approaches.
Could it that you are looking at a wrong place?
When build command is successfully finished you should see smth like below in console
Built the following apk(s):
<PATH_TO_YOUR_SOURCES>/platforms/android/build/outputs/apk/android-debug.apk
Are you checking this this location?
Okay so the problem isn't with Ionic, it's just that the changed files aren't showing up in the ftp for some reason. So now I will try and figure that out.
As suggested by #mobileevangelist , ionic cordova restore can be done using command
ionic cordova prepare
It fixed my problem.
Try to
Open Android Studio
Choose Import project
Select YourProjectDirectory/platforms/android folder
Choose Build -> Build APK

Getting a white screen with my installed app in Android emulator (however works in browser)

I am having issues getting a legacy mobile app to run in an emulator - it all seems to run in the browser without any issues but when I run the cordova emulate command the app attempts to install but I always get a white screen (nothing else) & the app isn't visible to use.
I am running Cordova CLI v5.0.0 although the app was made about a year ago so was developed in an older version of Cordova.
Can anyone suggest the best ways to debug this app to find the cause of the problem & why the problem only persists when I run the emulate command but seems fine in the browser?
-- update --
I have installed the Samsung drivers to allow me to connect my OnePlusOne device to adb, and I am know using the Android Studio program to collate errors etc..
In Android studio I can see the logs (see gist below):
https://gist.github.com/gkimpson/fbde0f5a7d1017daae17
Its quite long so added it externally - any ideas why I am having problems with my app?
-- update --
This line seems to be the problem
D/SystemWebChromeClient﹕ file:///android_asset/www/js/app/modules/stickers/stickers.js: Line 357 : Uncaught TypeError: window.requestFileSystem is not a function
The code in stickers.js is below for that section..
if (window.isDevice) {
window.requestFileSystem(window.PERSISTENT, 512, onInitFs, errorHandler);
} else {
callback(fc);
}
Ok here is what I had to do when I migrated from cordova 3.6 to cordova 5.
But first, I suggest you a little reading :
Cordova Android 4 release notes
Plugins switch to npm
The white list plugin documentation And in addition the CSP documentation
To sum-up, the security has changed in cordova, if you don't add the white list plugin your app will have no network access, and the plugins are now installed via npm instead of via git.
So what I did (a little bit hardcore maybe):
delete completly the platforms/android folder
delete the plugins folder (maybe before cordova plugins list if you don't have the list somewhere)
reinstall the plugins with the new name (most of external plugins haven't changed name, but all cordova plugins have) for example cordova-plugin-camera replaces org.apache.cordova.camera
add the white list plugin and configure it (or if you're not concerned about security, install the white list-legacy plugin which should work as previous versions)
add the android platform
and you can run cordova plugin save and cordova platform saveto have all your plugins and platforms saved in config.xml

phonegap/android: changes to index.html not being regarded when building the app

I'm making my first steps in phonegap. I've been able to set up a project, install a plugin and build the app on my phone without errors. However, now, when I try to change the layout of my www/index.html in the project's root platforms/android/assets/www/index.html stays untouched whenever I (re)build the app.
I'm basically working in eclipse, only for html and javascript I use sublime. I've searched now for a couple of hours for a solution. The most promising approach was this thread: Changes to HTML files not showing on built phonegap 3.0 app ... but even that didn't work.
What can I have done wrong? There's no error, no warning (none resulting from the build process) and I don't know how I could debug the issue. I'm currently using phonegap/cordova 4.2.0
Any clue? Thanks
I still don't know the reason for my problem. However, installing the app via cordova CLI rather than eclipse seems to have solved the problem:
$ cordova prepare android
$ cordova run android

Installing phonegap app to android emulator using windows CLI

I'm trying to install my Phonegap application onto an Android AVD/Emulator. I have launched the AVD and it's registering as 5554:Nexus_S.
When using the Phonegap commands at the Windows prompt I am typing:
phonegap build android
phonegap install android
The output I get says it successfully installed the app onto the device, but it never shows up. This is the output of the install command:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] trying to install app onto device
cp: dest file already exists: C:\Users\username\app\platforms\android\assets\www\phonegap.js
[phonegap] successfully installed onto device
I've tried variations of targeting the device using options with no luck:
--device=5554
--target=5554
Any ideas?
I figured it out. You have to specify the --emulator= in the call, so the command looks like:
phonegap install --emulator=emulator-5554 android
You can find the name/id of your running emulators by running the list-started-emulators.bat under the /platforms/android/cordova/lib/ folder in your project.
Another quick note is that sometimes even when you have started the emulator phonegap will not recognize it... so you have to start it from phonegap bat file so that the right process number is registered. to do this.
Use the following command,
1. List-emulator-images.bat : This will display available emulator images you have
2. start-emulator : This will start the emulator which will register with phonegap.
Also make sure you are running all of this from and ADMIN Enabled command prompt.
Okay, I've solved my problem. This solution may not be applied to all, but I was suffering from the same problem as I've mentioned in the comments of the question.
What did I do wrong?
I made some changes in one of the plugins.
I was working on my app and added the Vibration plugin. I made some changes in the plugin, both in the generic version [your_project_root\plugins\org.apache.cordova.vibration\src\android\Vibration.java] and also in the platform specific version [your_project_root\platforms\android\src\org\apache\cordova\vibration\Vibration.java].
But when I reverted the changes back, everything went fine.
I say it again, this solution may not be generic but can be useful for at least my type of problem.
And this gives rise to another question, can't we make changes in the Plugins?I think it is totally fine to make changes in them. Maybe I had done something wrong.

Categories

Resources