Cordova Error Please Install Android target 19 - android

My Cordova has suddenly stopped working.
It was working well when I was last working on it - around 2 months ago.
Now when I want to resume working on my project, it gives me the error:
> cordova platforms add android
npm http GET https://registry.npmjs.org/cordova-android/3.7.1
npm http 200 https://registry.npmjs.org/cordova-android/3.7.1
npm http GET https://registry.npmjs.org/cordova-android/-/cordova-android-3.7.1.tgz
npm http 200 https://registry.npmjs.org/cordova-android/-/cordova-android-3.7.1.tgz
Platform android already added.
> cordova run android
Running command: C:\Work\Eclipse\Workspace\Android\CordovaTmp\HelloWorld\platforms\android\cordova\run.bat
"C:\Work\Eclipse\Workspace\Android\CordovaTmp\HelloWorld\platforms\android\cordova\run"
ERROR: Error: Please install Android target "android-19".
Hint: Run "android" from your command-line to open the SDK manager.
ERROR running one or more of the platforms: Error: C:\Work\Eclipse\Workspace\Android\CordovaTmp\HelloWorld\platforms\android\cordova\run.bat: Command failed with exit code 2
You may not have the required environment or OS to run this project
> cordova -version
4.3.0
I have checked out these posts, but thats of no help: link 1, link 2 and link 3.
Also, I am unable to run 'android' on the cygwin shell even though I have added tools and platform-tools to my PATH variable in 'My Computer'
I am running Windows 8.1, cygwin and here is what my SDK Manager looks like:
My platforms/android/AndroidManifest.xml looks like:
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.foo.helloworld" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="CordovaApp" android:theme="#android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
</manifest>

The cordova run android command needed to be run from windows powershell and not cygwin.

Related

Unable to apply changes on device: emulator-5554. Error is: Command ./gradlew failed with exit code 1

The app i'm working on works in ios, but wont for android.
It has worked previously before updating the nativescript version to 3.4.3 from 3.4.1 and Mac OS to High Sierra.
I then had to update the Android Studio version.
The following is the output from tns debug android.
Searching for devices...
Preparing project...
Gradle build...
+ applying user-defined configuration from /Mobile/NativeScript-Projects/Genkan/app/App_Resources/Android/app.gradle
+ adding nativescript runtime package dependency: nativescript-optimized
+ adding aar plugin dependency: /Mobile/NativeScript-Projects/Genkan/node_modules/nativescript-imagepicker/platforms/android/nativescript_imagepicker.aar
+ adding aar plugin dependency: /Mobile/NativeScript-Projects/Genkan/node_modules/nativescript-ui-listview/platforms/android/TNSListView-release.aar
+ adding aar plugin dependency: /Mobile/NativeScript-Projects/Genkan/node_modules/nativescript-ui-sidedrawer/platforms/android/TNSSideDrawer-release.aar
+ adding aar plugin dependency: /Mobile/NativeScript-Projects/Genkan/node_modules/nativescript-ui-core/platforms/android/TNSCore-release.aar
+ adding aar plugin dependency: /Mobile/NativeScript-Projects/Genkan/node_modules/tns-core-modules-widgets/platforms/android/widgets-release.aar
FAILURE: Build failed with an exception.
* Where:
Build file '/Mobile/NativeScript-Projects/Genkan/platforms/android/app/build.gradle' line: 64
* What went wrong:
A problem occurred configuring project ':app'.
> Could not get unknown property 'outputFile' for task ':app:packageDebug' of type com.android.build.gradle.tasks.PackageApplication.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
Unable to apply changes on device: emulator-5554. Error is: Command ./gradlew failed with exit code 1.
the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="__PACKAGE__"
android:versionCode="2"
android:versionName="2.1">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="__APILEVEL__"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="com.tns.NativeScriptActivity"
android:label="#string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#style/LaunchScreenTheme"
android:windowSoftInputMode="adjustPan">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="#style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
This usually happens because of the incompatible java JDK version.
Please check your current java version using this command:
java --version
If there is java installed already then remove that version first, after that install LTS version of java jdk from https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
From Docs: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#variant_api
However, more complicated tasks that involve accessing outputFile
objects no longer work. That's because variant-specific tasks are no
longer created during the configuration stage. This results in the
plugin not knowing all of its outputs up front, but it also means
faster configuration times.
Use outputFileName instead of outputFile in your Gradle configuration.

Add specific android version

I'm trying to add a specific android platform.
Now all answers to these same questions look approximately the same:
Add
<preference name="android-targetSdkVersion" value="XX" /> to your config.xml
So, I tried:
Adding that line to my config.xml where XX = 23
cordova platform remove android --save
ionic cordova platform add android --save
My output shows me:
Using cordova-fetch for cordova-android#~6.2.2
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: com.ionicframework.someapp
Name: MyApp
Activity: MainActivity
Android target: android-25
This looks like it's using android-25.
My myapp/platforms/android/AppManifest.xml looks like this:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="com.ionicframework.someapp" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="#mipmap/icon" android:label="#string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="#android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/provider_paths" />
</provider>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
But my platforms/android/project.properties just shows target=android-25
So. How can I configure my android version to use android-23, eventually manually if there's no straight answer.
(I had this issue before and I believe I resolved it back then by reverting to a 5.X.X build of cordova. New requirements make that kind of impossible this time)
I'm not sure if this is exactly what you're looking for, but this might help. If you are trying to only use a certain API level / android version, you can use the command on cli:
cordova platform add android#[cordova android version]
ie: cordova platform add android#4.1.1
You can check out the documentation on which versions of cordova android support which API level.
Note:
Please note that the versions listed here are for Cordova's Android package, cordova-android, and not for the Cordova CLI. To determine what version of Cordova's Android package is installed in your Cordova project, run the command cordova platform ls in the directory that holds your project.
Struggle with the same problem. Is there a final solution for this problem?
This seems to be ignored in the config.xml:
<preference name="android-minSdkVersion" value="16"/>
<preference name="android-targetSdkVersion" value="23"/>
"cordova platforms add android" always install android version 6.2.2

Cordova/Phonegap Android target: not installed [Android Studio Installed]

Still facing this issue. I searched all over google could not found a solutions.
Mac OSX Sierra
Android Studio 2.3
Cordova/ Phonegap (Latest Version)
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
Gradle: installed
Error: Some of the requirements check failed
.bash_profile
================================
# Setting JAVA_HOME Path
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home"
# Setting ANDROID_HOME Path
ANDROID_HOME=“/Users/{localpath}/Library/Android/sdk”
# Setting GRADLE_HOME Path
GRADLE_HOME=“/Users/{localpath}/Library/Android/gradle/gradle-3.4”
export PATH=“${GRADLE_HOME}/bin:${PATH}”
export PATH="${ANDROID_HOME}/tools:$PATH"
export PATH="${ANDROID_HOME}/platform-tools:$PATH"
Andriod Manifest
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.company.myAPP" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="#mipmap/icon" android:label="#string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="#android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="25" />
</manifest>
Android Studio Installed SDK
Facing exactly the same error, I encountered this answer on forum.ionicframework.com:
As easy as that.
I had the problem on Mac, so I did download the SDK tools373, copy-paste it in /Users/username/Library/Android/sdk, and it worked instantly.
But I absolutly don't know what causes the issue.
And I don't know what causes the issue either, but it helped me and everything works as expected.
Facing with same error.
Maybe this info will be helpful.
In the latest Android SDK Tools (v25.3.1), the android command no longer operates as expected and instead exits with a non-zero status code and provides a message telling folks to use the sdkmanager and avdmanager commands.
try to execute android in terminal if it will return something like this:
The android command is no longer available.For manual SDK and AVD management, please use Android Studio.For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
then you need to downgrade your SDK to v25.2.5 or less. Instruction can be found here
I downgraded Android SDK
FROM
latest release 10.0(q) to API level 29
TO
9.0(pie) API level 28
by the user guide here
then added this in a .bash_profile
export ANDROID_HOME=${HOME}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
everything works fine
I hope that it can help someone

cordova Error: Please install Android target: "android-22" (When I already have 23)

Cordova gives me this error, when I was making my first hello world app.
I typed :
cordova build android
And I got the follwing output:
[Error: Please install Android target: "android-22".
Hint: Open the SDK manager by running: /home/nicki/Android/Sdk/tools/android
You will require:
1. "SDK Platform" for android-22
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)]
ERROR building one of the platforms: Error: /home/nicki/code/cordova/hello/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/nicki/code/cordova/hello/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
I am using Ubuntu 14.04.
Android Manifest file in my app:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.example.hello" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application android:hardwareAccelerated="true" android:icon="#drawable/icon" android:label="#string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="#android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
</manifest>
I also modified <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" /> to
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
and it still gave same error of android-22 (even though it was 19 in the file).
And besides that I got 23 which is even better than 22, as you can see in my screenshot below:
this can be the issue with Cordova version you are using. Each version of cordova will support only a set of android version. Please read this for more information: https://cordova.apache.org/announcements/2015/07/21/cordova-android-4.1.0.html
Just edit the files listed below as
# Project target.
target=android-23
myApp/platforms/android/project.properties
myApp/platforms/android/CordovaLib/project.properties
From the screenshot i have understand that, you have installed Android SDK Platform tool and Android SDK Build tool in version 23. So you have to change the Project target as mentioned above on those files.
It worked for me. Thanks
I'm on Windows 7 x64.
For me the problem was that default java.exe was ran from Oracle's JDK 8u40 (on PATH), while my JAVA_HOME pointed to IBM (WebSphere) JDK with WAS 8.5
After I ran
set JAVA_HOME=c:\devtools\jdk_8u40
in my shell for it to point to Oracle's JDK directory, it started finally working!
This works for me, my specific approach is: remove the reference to the oracle directory from the environment variable of path and reduce the JDK version to 1.8.0u65

net::ERR_FILE_NOT_FOUND file:///android_asset/www/index.html was not found

I have a cordova app (that i'm building for Android) that I have signed using the keytools on the command line and installed this onto my Android device.
Whenever I open the app on my phone I get the following error:
Application Error
net::ERR_FILE_NOT_FOUND (file:///android_asset/www/index.html)
My phone has an internet connection so there is an active mobile internet connection - can anyone help in debugging the problem?
I have come across a number of fixes that relate to moving remote assets however I cannot see in my app where I have any links to a remote URL.
Is there a way I can do a 'stack-trace' to allow me to pin-point the exact point this Application Error is being thrown within my app?
Any tips at all would be appreciated
-- update --
Here is the adb log that is generated when in the emulator
For anyone else that this may help I used the following to output the emulator log to a file:- (the double >> is needed to append data to the file)
adb -e logcat >> emulator.log
https://gist.github.com/anonymous/e53abb7eb089950ac4e5
-- update --
My AndroidManifest.xml file looks like the following:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.myapp" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="#drawable/icon" android:label="#string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="#android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
</manifest>
-- update --
Within my platforms 'android' folder is a 'assets' folder - this has the following structure:
www/
_where-is-www.txt
www/css
www/img
www/js
www/res
www/app.html
www/cordova.js
www/cordova_plugins.js
www/index.php
There doesn't appear to be an index.html - even though the cordova setup states an index.html file... I cannot understand why it would be doing this.
NOTE :
I am creating a cordova app, adding a Android platform, then copying my existing www folder from another directory of the existing app (that has been developed and released to the Play store so works ok) - then finally doing the build. Not sure why index.html should be showing... any ideas??
you should run cordova build android before cordova run android or make it simple by running cordova build android && cordova run android --device
PS: don't forget sudo if you work on mac
I had to run the ionic commands to fix this error:
ionic cordova platform add android
ionic cordova run android
https://forum.ionicframework.com/t/ionic-err-file-not-found-file-android-asset-www-index-html/91629/2

Categories

Resources