In this post I will show how you can add banner ads to your Ionic apps. I will be doing this on a new app but you can do it to your existing app as well. I have also written a post on adding banner ads to Ionic 2 apps, so if you are looking for Ionic 2 apps You can check that post out as well.
We will first start by creating a new Ionic project by issuing the following command in the command prompt1ionic start MyNewApp Tabs
Now we will need to add the platform to out app. So will do the following command
As we will be using the AdMob Pro plugin we will need to download it in our project. We will do that by the following command
you can read more about the plugin in the Admob pro plugin documentation
Now we will need to add the following code to the $ionicPlatform.ready() in the app.js file
So the finished app.js file looks like this:app.js
NOTE: The app.js file will be different for each template namely tabs,bank,sideMenu, make sure you add the code to the $ionicPlatform.ready() function and no to any function inside it.
The error you have received is from NPM (since the Cordova CLI is installed via NPM). This is a tricky issue where using NPM with
sudo, and then not using
sudowill result in weird permission issues.
sudo chown -R $USER /usr/local/
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':CordovaLib:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/arulmanickam/adt-bundle-linux-x86-20131030/sdk/build-tools/23.0.2/aapt'' finished with non-zero exit value 127
For me it was that I forgot to install the 32bit dependencies:
sudo apt-get install -y lib32gcc1 libc6-i386 lib32z1 lib32stdc++6
sudo apt-get install -y lib32ncurses5 lib32gomp1 lib32z1-dev lib32bz2-dev
i have this error when i am trying to build
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
You have permission errors. My guess is that you tried to run the script as root rather than sudo. When running the script you have to run it as your user account using sudo.
change owner permission all files & folder to your current login user .
- Your android sdk
- Your ionic or cordova project files
dont run as admin or run using sudo