I am trying to use AdMob in my app.
I am using this : https://github.com/appfeel/admob-google-cordova
Following this tutorial : https://github.com/appfeel/admob-google-demo
I have downloaded the zip. Run it on device and got the following error message :
cordova-admob plugin not ready. Are you in desktop browser ? It won't
work...
I investigated and found out the plugin isn't even installed. So I tried installing it via the CLI like so :
cordova plugin add cordova-admob
And I get the following messages :
cordova-admob: Warning, could not copy necessary files for angular
browser platform.
cordova-admob: Please ensure 'www/lib/angular-admob/angular-admob.js'
exists (you can copy it from 'plugins/cordova-admob/angular-admob.js')
I tried copying it from there and created a folder at the location www/lib/angular-admob, as it wasn't there but I get build errors.
Anyone come across this ? I've been at this for weeks, on and off, trying to get the adMob to work for PhoneGap/Cordova but I keep getting different errors. I have tried this plugin :
https://github.com/floatinghotpot/cordova-admob-pro
That one worked great on the android emulator, but not when I, both, served it to my device via the phonegap desktop app and served it from CLI to my device.
Here's the error I am getting now :
When creating the project from scratch and following these steps :
cordova create AdMobTest || cordova platform add android || cordova
plugin add cordova-admob || creating empty lib folder inside my
project www folder || cordova plugin remove cordova-admob || cordova
plugin add cordova-admob || cordova prepare android || cordova compile
android || cordova run android --device –
I'm now getting this error :
Just create a EMPTY folder with the name lib inside your project www folder:
Clean your project by removing the current version of the plugin with the cordova cli. Remeber to use the cli inside your project root folder:
Add the plugin with the cordova cli:
Have a nice day!
EDIT : Your error occur inside processDebugResources so it´s nothing about the plugin. To avoid this problem change your target Android SDK to an prior version.
Here is one answered question which adress this problem: Execution failed app:processDebugResources Android Studio
Related
I'm trying to make an apk of the web app I made in babylonjs.
From my understanding you can use Cordova to convert a web app into an apk.
I was able to install Cordova and make its hello world apk download to my phone and open and run it just fine.
However my problem occurs when I put all of my web app files into the www folder in my Cordova project folder. After I do that Cordova gives me this error
Error: ENOENT: no such file or directory, stat '/Users/dylan/practiceApk/www/node_modules/.bin/nopt'
when I try to build the android version.
Here is some information about my setup I believe is relevant.
OS: Mac
cordova -v: 7.1.0
Cordova requirements:
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-26,android-24
Gradle: installed /Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle
cordova info also gives this error(similar error I believe to the one above):
Error retrieving Android platform information:
Android SDK is not set up properly. Make sure that the Android SDK 'tools' and 'platform-tools' directories are in the PATH variable.
Error: android: Command failed with exit code ENOENT
But I tried a lot of different things to fix this. Most of them involved making the android tools in the path (er something..?) I also downgraded from the most recent version of Cordova and android. I believe the problem is in my web app node_modules/.bin/nopt
But I don't know why its is a problem.
Also im not sure how this affects it, but I'm not hosting the website anywhere I just assumed I can used Cordova to create the web app as an apk that could be used offline, all resource are in the project folder though.
Any ideas on how to fix this? I only started using Cordova today so I don't know much about it.
Thanks for your time!
Update: I tried building an iOS version and I get the same error. I believe this is an issue with my npm setup...
It seems that when I was copying over my project to the newly made Cordova project folder I also copied the node_modules folder and didn't actually initialize npm. After initializing it and then updating it would build the app.
I m new to cordova/ionic.
I have a cordova project which i want to run either on android device or emulator.
When i run the command : ionic cordova run android.
I get the following error :
Detected locally installed Ionic CLI, but it's too old--using global
CLI.
cordova platform add android --save Using cordova-fetch for cordova-android#7.0.0 Error: Failed to fetch platform
cordova-android#7.0.0 Probably this is either a connection problem, or
platform spec is incorrect. Check your connection and platform
name/version/URL. Error: cmd: Command failed with exit code 1 Error
output:
in the code platform android already exists, but when i check its version it i s, android~6.3.0.
I have tried a number of things to resolve it which includes, reinstalling cordova, android.
Can anyone have a solution for it.
The code was written around a year back and now i have all the latest versions installed in my system
Problem is android platform was not added properly. Therefore you have to add respective Android Platform into your Project.
Before adding run :
cordova platform remove android
After run :
cordova platform add android#6.0.0
if you develop on windows enviroment You can check the version of Android provided by Cordova under :
C:/Users/%USER%/.cordova/lib/npm-cache/cordova-android
You may also want to try adding --nofetch to the command, which will use the pre-7.x behavior. See Cordova 7 fails to add android platform
You can try it by firstly updating your android sdk manager with all the latest updates and also update its gradle. Then try to firstly remove the android platform using command
CORDOVA PLATFORM REM ANDROID
and then add android platform using command
CORDOVA PLATFORM ADD ANDROID.
The following is what I did to setup Ionic in Chrome App for Mobile:
Created a Chrome App for Mobile project - cca create projectname
Created an Ionic project ionic start projectname_ionic
Deleted all of the files from the Chrome App www folder except the manifest files and background.js - find projectname/www/* -not -name 'manifest*' | grep -v 'background.js' | xargs rm -rf
Copied the content of the Ionic project www folder to the Chrome App www folder - cp -r projectname_ionic/www/* projectname/www/
Commented out <script src="cordova.js"></script> at projectname/www/index.html since cca automatically inject it already
When trying to run the project I get the following error from app.js line 14 -
Uncaught TypeError: Cannot read property 'Keyboard' of undefined
When typing at the console of Chrome dev tools (remote debugging) window.cordova I do get an existing object, so the problem is that window.cordova.plugins is undefined.
btw the app itself does load up at the mobile and I can switch tabs, but at the Friends tab when I click on a name I do see that it got clicked but nothing happen beside that.
I also tried the following:
projectname_ionic/plugins had 3 plugins which projectname/plugins missed so I added them using cca plugin add ... to projectname/
Run ionic platform add android at projectname_ionic/ before copying the files
Tried few older versions of Ionic (desperate I know :))
And some other tries which I forgot already...
Anyone got an idea what should I do?
Thanks in advance!
I started getting the same error after removing plugins directory (I had a hook that was adding the plugins as part of the add platform). There are 3 plugins that ionic adds for a new project. I did not have keyboard and console ones as part of my hook.
Check that you have following cordova plugins:
cordova plugin add ionic-plugin-keyboard
cordova plugin add org.apache.cordova.console
cordova plugin add org.apache.cordova.device
Once I added missing plugins to the ones added by hook the error was gone.
Also, if node_modules was removed, npm install will be needed.
When I tried to add the plugin on Mac OSX the plugin had a different name. You have to run this command in the project directory.
cordova plugin add ionic-plugin-keyboard
You can see the lib here: keyboard plugin
It sounds like you're not running this as an actual build -- are you using CADT? Even if you're testing with CADT on a device you will still NOT get window.cordova.plugins. Once you build the project with cca build and then install the apk on a device then the window.cordova.plugins will be defined.
Hatzlacha
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 )
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.