How to run an ionic v1 app on Android? - android

I just received an ionic v1 app that I have to make some changes,but after a fresh installation of ionic, I'm unable to run it. Every time that I run ionic run android in the ionic CLI, I receive this error:
WARN: ionic.project has been renamed to ionic.config.json, please
rename it. Using this version of Cordova with older version of
cordova-android is deprecated. Upgrade to cordova-android#5.0.0 or
newer.
Error: Your android platform does not have Api.js
For the moment I can not migrate to Ionic 2.
What can I do to run/build it?

Fist of all, when you install Ionic this way
npm install -g cordova ionic
You are getting the last CLI that works with Ionic 2, Angular 2 and a different project structure. If you want to run and build an Ionic v1 project you need the tools that works with your version.
To install a specific version you need to add # symbol after the name package and the version that you want for example:
npm install -g ionic#1.7.14
npm install -g cordova#6.0.0
Also you have to keep in mind that Android has been improving their tools too, and this version of cordova doesn't work properly with the latest Android tools chain. This question can help you to download and setup the android tools for this version of cordova.
After that you will be able to run ionic run android

Related

Gradle version to use with Android/Cordova CLI

I currently use Cordova CLI on Windows to build hybrid Android apps. I am in the process of moving my development mover to a headless Ubuntu server. Getting java, NVM, Node, Android SDK and Cordova CLI installed on Ubuntu has not been a problem. Having done so and created the customary Cordova hello world project,
cordova create hello com.example.hello HelloWorld
I proceeded to add the Android platform
cordova plaform add android
and then attempted to build
cordova build android
at which point I was told
Error: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
Installing Gradle by following the instructions given here - I am NOT installing Android Studio and am working on a headless Ubuntu machine so automatic Gradle installation is not an option - is not a problem. However, it is not clear to me which version of Gradle I should install.
I do not want to break my current Cordova project so I am trying to replicate the current Windows/Cordova CLI setup as closely as I can
Node 8.9.2
Java 8
Gradle ???
Dipping inside the gradle-wrapper.properties file in my existing project I find
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
I have noted that when I compile the project at present there are some ominous warnings about features to be removed from future versions of Gradle that are shown. I could experiment with using gradle-2.10 but it is not entirely clearr to me that it would indeed be the right version. Hopefully, someone here will be able to point me in the right direction.
First, clean up the project
cordova clean android
Then, force the cordova to use the distribution url with the version you want, in this case: gradle-6.3
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=https\\://services.gradle.org/distributions/gradle-6.3-all.zip
Then, build your application.
cordova build android --release

Ionic + Angular - Platform Add Android Error - Error: Failed to fetch platform cordova-android#0.0.8

Okay, so you run this. And it continues to fail.
cordova platform add android --save
And the output is this.
Error: Failed to fetch platform cordova-android#0.0.8
After trying to reinstall cordova, node, and other packages, I have had no luck. I am running this with the ionic blank starter package with ionic Cli 3.
For some reason with the latest version of everything, ionic, angular, the cli, etc, the platform was trying to add
cordova-android#0.0.8
To fix this, just go to this link and get the latest version, and run this...
sudo ionic cordova platform add android#6.4.0
I had the same issue and followed this link
https://github.com/apache/cordova-android/releases
There, I found that the latest version is 7.1.1
I tried this ionic cordova platform add android#7.1.1 but got the same error
From a forum I follow, I got this link https://www.npmjs.com/package/cordova-android
Then I tried this ionic cordova platform add android#7.1.0 and it ran as I expected
remove old android
ionic cordova platform rm android
add latest android
ionic cordova platform add android#latest

Can't add Android platform and build ionic project anymore?

So I wanted to start a new ionic project by writing:
ionic start Ionic1 blank
After that I moved to that new directory and wanted to add android platform:
ionic platform add android
I then got this error:
Error: Failed to fetch platform android
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: EACCES: permission denied, open '/home/think/.cordova/lib/npm_cache/cordova-android/4.1.1/package/.npmignore'
I don't know why this happens. I tried these:
1) change the permision with
chmod 744 /home/think/.cordova/lib/npm_cache/cordova-android/4.1.1/package/.npmignore
2) uninstalled and installed nodejs, cordova, ionic, etc.
3) Executed with sudo ionic platform add android (but "sudo" is not necessary i think since I added android platform before in other projects without having to write "sudo" )
Still it's somehow not possible to add a platform.
I'm on ubuntu 14.04 LTS. I have android SDK manager installed.
I can build and run my other ionic projects that I created earlier. But since yesterday I can't build new projects anymore. It happened when I iupdated to ionic 1.7.13. I tried to downgrade ionic to an earlier version but that wouldn't solve the issue either.
Maybe this is a cache problem of cordova. Delete the cache and try to add the platform again:
rm -rf ~/.cordova
I have no idea what went wrong. i just installed cordova and ionic again and now it's working. For those who encountered the same problem: The commands I executed:
sudo npm install -g cordova
sudo npm install -g ionic
After that add, build, and run the project just as usual.
Try adding it with cordova instead of ionic.
cordova platform add android

Can't build app with Ionic

I am no longer able to build my app and generate an apk anymore because an error shows up. Here is what happens when I try to build the app in the command prompt: Command Prompt
Can somebody please help me with this? Oh and this is what happens if I type ionic info in the command prompt:
Your environment has been set up for using Node.js 0.12.4 (x64) and npm.
C:\Users\Singh>ionic info
Your system information:
Cordova CLI: 5.1.1
Ionic CLI Version: 1.6.1
Ionic App Lib Version: 0.3.3
OS: Windows 7 SP1
Node Version: v0.12.4
C:\Users\Singh>
Try to remove the platform, and then add it again, and then build your application.
So, if you have android as targeted platform execute these commands:
ionic platform remove android
ionic platform add android
ionic build android
My son had a very similar problem, and we never did figure out what caused it. He ended up creating a brand new blank ionic project, and then just copying the www folder from the old project. It worked, and he was able to get things building again. If you try it, you'll also have to re-add your plugins, copy package.json and bower.json, and then rerun bower install and npm install. It's not pleasant, but it might be worth a shot if you're desperate.

Cordova build android

When I want to try ionic weather app (https://github.com/driftyco/ionic-weather/) I've got problems when I wanted to build android to my phone-gap application using cordova. I receive this message in terminal when I execute the command cordova build android
Error: An error occurred while listing Android targets
I work on ubuntu 13.10
I was able to successfully build the project with the following steps:
npm install -g cordova ionic
git clone https://github.com/driftyco/ionic-weather/
cd ionic-weather
cordova platform add android
cordova build android
You may be missing the required android sdk tools, or they may not have been added to your system path.
Refer to this question
cordova ubuntu: An error occurred while listing Android targets
And follow this guide to ensure your environment was setup correctly.

Categories

Resources