Vuetify don't render on cordova android - android

I've created a Vue project and add a cordova plugin, like this:
vue create app-test
vue add cordova
npm run cordova-serve-android
Everything works up to this point.
Then I've tried to do this:
vue add vuetify
When I run:
npm run cordova-serve-browser
Everything fine, but when I run
npm run cordova-serve-android
Just a blank screen was rendered
Examining the code with the debugger, there's no App.vue, nor HelloWorld.vue instantiated.
I've just find a lot of errors on console:
Failed to load resource: net::ERR_CONNECTION_REFUSED
https://localhost:8080/sockjs-node/info?t=1570409595173
Please suggest.

How It worked for me (without using vue cordova plugin)
Remove and install new version nodejs and cordova
Created a cordova project and added platform android (don't build or run android from the command prompt.. it will create lot of errors)
Then open the created android project (\platforms\android) in android studio (use the latest version of android studio),on open it will ask for gradle upgrade, then "Ok" to update the build gradle and wait for the update finish.
then run the project from android studio,
if the cordova hellworld project is working, then replace the content of 'platforms\android\app\src\main\assets\www\' with the content in 'dist' folder created by using the vuejs build command.
Then run the project from the android again, Now you can view your app
(optional) if you are sending non https requests from the app, then android:usesCleartextTraffic="true" in the AndroidManifest.xml file
Note : You have to build the vuetify project every time to generate 'dist' folder and need replace the files in www folder

Related

Run / Build Apk is not updated with the latest changes

I have a problem in my vuejs + cordova project, when there is an edit file for example (login.vue) the changes only appear when running the 'npm run serve' command but when running the command 'cordova run browser / android' the login.vue file is not updated. I've tried clear cache 'npm clear cache' and 'cordova clean / cordova prepare' the results are still the same.
Command Before run/build cordova :
npm run serve
npm run build
cd cordova_app
cordova run/build android or browser
it is because the latest changes you made to files need to be brought to the platform folder (E.g. $projectroot/platform/android/www).
For this you have two options:
you can edit the file here directly
$projectroot/platform/$platform_name/www, but as a result, if you delete the platform, then that change will get lost.
Or you can make also make the changes in $projectroot/www/ but you will need to run few commands: cordova platform remove android and cordova platform add android if it is for Android. Please note that this will also overwrite any special configuration you have made in your IDE (xCode for iOS or Android Studio for Android) because it regenerates from your code, a new workspace for your app to be compiled, including your latest code, all in the platform folder.
Good luck!

phonegap - navigator.connection.type not defined

I am trying to check for an established network connection through the phonegap/cordova API, but alas, it is not working.
I added the plugin as explained on the cordova documentation, and phonegap local plugin list gives [phonegap] org.apache.cordova.network-information.
However, simply calling
document.addEventListener("deviceready", function () {
alert(Object.keys(navigator.connection));
}, false);
results on my phone (Android 4.0.4) always returning 0 and running on an emulator with Android 4.4.2 logs into LogCat that navigator.connection is undefined. In fact, on both machines alert(Object.keys(navigator)); never shows the connection key.
Any solution?
Phonegap with Cordova 3.3.0
When you install the plugin it copies files to www/plugins and updates android.json
then when you build the project, the build copies the java to platforms/android/src/... and the js files to platforms\android\assets\www\plugins (and does any customisation defined in plugin.xml)
At multiple occasions I saw android.json not correctly updated and javascript files not copied. Removing and re-installing plugins solved the problem for me.
If you did not perform manual customisations to the platforms/android folder, I think the easiest way to clean your project would be to empty the /plugins folder and the platforms folder and then re-install all the plugins you need.
I had the same issue and found I had to run "cordova build" and then the status was returned correctly.
BEWARE
When I run cordova build, it appears to take everything in my ~/app/www directory and overried everything in app/platforms/android/assets/www/
My "install process" is as follows:
cordova create app com.app "App"
cd app
cordova platform add android
cordova plugin add org.apache.cordova.network-information
cordova plugin add org.apache.cordova.camera
cordova plugin add org.apache.cordova.geolocation
cordova build
I can then do code changes in app/www and when happy, 'deploy' it using 'cordova build' (which seems to always copy the files to app/platforms/android/assets/www/.
If I add another plugin using: (for example)
cordova plugin add org.apache.cordova.file
then I need to run
cordova build
to have it work.
I hope this helps
(I am using cordova 3.3.1-0.1.2 )

Upgraded to Phonegap3, project does not load needed plugins correctly

So I've tried posting some of these issues on the Phonegap forum but have not heard from anyone regarding my issues...
I recently upgraded from PG 2.9 to 3.3 and am having trouble adjusting my project to the change... it should be as easy as installing phonegap 3.3 and creating a new project and dragging my /www to the root of the project and calling the cordova CLI commands to build and update my project-- both of which say that they complete successfully.
But it's not that easy! Instead, building and updating my project deletes the cordova2.9.jar and does not create a 3.3.0 jar... so I build it myself which goes fine. I stick it in my /libs folder and my app loads on my phone finally... The problem now is that running in PG 3 requires a change in how API calls are handled-- they are all plugins which you have to install before using them... so I installed all of the needed plugins...
The problem now is this message in logcat within Eclipse:
Unable to open asset URL: file:///android_asset/www/cordova/lib/cordova_plugins.js
so I find this cordova_plugins.js file in the root of my assets/www/ directory (Why is it here?! Shouldn't this be automated by cordova build & update to the correct location?!) So I try to copy the file to /www/cordova/lib/ where the error reports it is trying to find it.
When I do this, I get all of these errors:
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/DirectoryEntry.js
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/DirectoryReader.js
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/File.js
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/Entry.js
...etc (basically every plug-in that I had installed in the project.)
I am clearly missing something here... relocating these javascript files to the correct directory manually should not be what I need to do...
I should mention that this original error occurred when I was running the application in PG2.9 but the only plugins that I needed to use were included by default so I could still use the needed API functionalities.
Any ideas here?
You must need to create and deploy any phonegap project/application using Phonegap Command Line Interface
To Create any project write following command on command line:
$ phonegap create <path> <package_name> <project_name>
i.e.
$ phonegap create hello com.example.hello HelloWorld
To add any platform to your project:
cd <path_to_project>
$ phonegap build <platform>
i.e.
cd hello
$ phonegap build ios
$ phonegap build android
To add any plugin feature to your project:
cd <path_to_project>
$ phonegap local plugin add <path_to_plugin>
i.e.
cd hello
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git

phonegap/ Cordova error: [RangeError: Maximum call stack size exceeded]

I am trying to create a phonegap / cordova app using the 3.1.0 version.
Created my app with the command:
cordova create hello com.example.hello HelloWorld
And after running this command:
cordova platform add android
to add android platform, i am getting:
[RangeError: Maximum call stack size exceeded]
Any idea what could be the issue?, previously i created another app, but same error was occurring when adding camera plugin.
I faced the same issue, but I was actually issuing the command in wrong directory, so firstly I changed the directory to Hello then issued the command.
So, I have directory structure as,
---Cordova
---Hello
and I was actually issuing the command by being at Cordova folder. After that I changed the folder to Hello then executed this cordova platform add android and it worked.
Please check once
be sure you are located in the created directory (Hello, I guess), the same level with .cordova
cd Hello
For anyone coming to this question after July 2013 (when Cordova 3.0.0 was released), there is another reason for this problem.
If you created a Cordova project on a computer with Cordova 3.x and you are trying to work with it on a computer that still has the old 2.x version, you will get this error because of how the project structure changed between the versions.
Upgrading Cordova to the newest version using npm install -g cordova will fix the problem.

How to Build and run the cordova project with eclipse and run project for android

I have created the project with cordova CLI but i do not know where i need to change and how to run the cordova android project with eclipse for each platform. Thanks for helping
Before run the android project inside your Cordova Project you should know these things.
If you are making any changes in the Cordova Project then first you need to prepare the cordova. use the command cordova prepare
Then it changed in your config.xml (for android) automatic as you added or any changes you made. Do not make any change in your android project which exist inside your Cordova project. You can only make change inside the www folder of your Cordova project. And after made changed you need to make cordova prepare every time.
After prepare the cordova you can run the android project on device or emulator. For this you make sure you have made the path of android sdk for platforms-tools and tools in your environment system. If you not configure this path and add this two path in system environment .
Now run the android project on device use command cordova run android and run on emulator use this command cordova emulate android.
And if want to run on eclipse then you should import this android project of your workspace in eclipse. But if you again made changes in your cordova project then need to delete and again import the android project this switching happened every time so better to run through CLI.
I hope you got all things
Sunil's answer is good. I would like to add logging using Android Debug Bridge(adb).You may want to run:
adb logcat on a seperate shell window for logs after running cordova run android you need when you run into errors.This will produce huge logs, so I would recommend using:
adb logcat|grep Cordova

Categories

Resources