Code ENOLOCAL Could not install from “android” as it does not contain a package.json file

Çağlar Can SARIKAYA
3 min readSep 29, 2020

--

Hi there! ,

I had an ionic application and I don't have an android phone for tests. What should I do?

I gave this title to make a good SEO and also if you searching this title, it means you got some, so I will explain what we need exactly to run ionic codes on the android studio emulator.

I created an emulator using the last android version, that was one of the faults. The first attempt I used to 30 API level. When I write ionic cordova platform add android I got some issues let review.

The first issue as I write on the title -Code ENOLOCAL Could not install from “android” as it does not contain a package.json file- I opened the project folder and I made an archive android folder to guarantee if some bad things happen and I deleted android folder and run ionic cordova platform add android

After this, I got this error “Source path does not exist: resources/android/icon/drawable-hdpi-icon.png” it means there is some problems with Cordova and I solve with adding`ionic integrations enable cordova --add

After this, I got this error “This error occurred while using native-run. You can try running this command with — no-native-run, which will revert to using Cordova.” and this problem from versions for solve npm i -g native-run@lastest`

After this, I got this error “ionic cordova run android [ERROR] Error while getting native targets for android: Error: Cannot find module ‘signal-exit’” this problem is about the android device, to solve

  1. cordova clean android (or IOS)
  2. rm -rf node_modules (just delete node_modules folder)
  3. npm install
  4. cordova build android (without ionic)

and cordova run android may solve the problems but mine didn’t

This time I got JAVA_HOME issue, and I downloaded the latest version of SDK and JRE and added environment variables. But I shouldn't do that. You have to read the issue carefully if you still with me on this step. Because mine was needed to JDK 1.8 and I downloaded this one and installed.

After this, I got this error “Android Studio project detected ANDROID_HOME=C:\Users\caglar\AppData\Local\Android\sdk JAVA_HOME=C:\Program Files\java\jdk1.8.0_261 studio 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”

There are 2 errors one of them is Gradle and the other one is java. I got Gradle on https://gradle.org/install

  1. I choose Installing manually
  2. Selected binary only
  3. Create a new directory C:\Gradle with File Explorer.
  4. Extract Gradle achieve to this folder
  5. Last, Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\your-gradle-version\bin. Click OK to save.

And then probably this problem will not solve because when you did some changes to system variables you have a reboot or log out.

After this, I got only one issue. There was problem about installing 2 times java. I found and deleted the wrong address both of the variables page(system and user)

and after one more log out. You have done it. It has to run with cordova run android except for one last error. It was looking everything ok until stuck on the emulator waiting. But it's not a big deal just you have to read the issue it was written 27 numbered API version of android which I used 30. Just delete the emulator and set up again with 27, give permission by using the device for plugin permissions and open settings change the USB mode to the developer, and done :)

at least it works ;)

edit.2

if you try with cordova emulate android it work for me. Also if you want to give target use this cordova emulate android --target=N5Oreo

--

--

Çağlar Can SARIKAYA
Çağlar Can SARIKAYA

No responses yet