No Java files found that extend CordovaActivity - android

I'm attempting to build a cordova app to release to android devices but receiving the following error message:
"Error: No Java files found that extend CordovaActivity"
It appears that the source of the error is that build folder that is to contain the source files is not being built. That is, the files that are to be created in the folder "src" isn't generated during the build and so the following warning is returned during each build:
ls: no such file or directory: ...\platforms\android\src\io\cordova\myappedc27c*.java
That is, the directory path "..\io\cordova\myappedc27c" is not being created.
Currently running Visual Studio 2017 version 15.7 on Windows 7 Pro.
Any help is appreciated.

ionic cordova platform rm android then ionic cordova platform add android#latest command solved the problem for my Ionic 3 application.

This happened to me after renaming the default Cordova config and package names. I fixed it by doing the following:
cordova platform remove android
cordova platform add android
Substitute android for each platform you'll be using.

I am developing an Ionic (5) app and saw this randomly pop up as well. Removing just the android platform under platforms wasn't good enough. I removed the entire platforms directory and while I was at it, also removed out-tsc, plugins and www.

Related

Cordova Web App

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.

Cordova Android build error "Cannot read property 'length' of undefined"

I have an older cordova project that I am updating. As a part of this process, I removed the android platform and readded it.
Now when I try to build the project I get the following error:
C:\App>cordova build android --verbose
No scripts found for hook "before_build".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform android
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at C:\App\platforms\android\res\xml\config.xml
Merging project's config.xml into platform-specific android config.xml
Found "merges/android" folder. Copying its contents into the android project.
Merging and updating files from [www, platforms\android\platform_www, merges\android] to platforms\android\assets\www
Wrote out android application name "App" to C:\App\platforms\android\res\values\strings.xml
android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.20): 10020
Wrote out Android package name "com.nge.app" to C:\App\platforms\android\src\com\nge\bca\MainActivity.java
Updating icons at platforms\android\res
Updating splash screens at platforms\android\res
This app does not have additional resource files defined
Prepared android project successfully
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
ANDROID_HOME=C:\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_40
Error: Cannot read property 'length' of undefined
This did work before I removed the platform so I am guessing it is a bug or a config file that changed.
There is a similar issue here: https://pt.stackoverflow.com/questions/219442/cordova-build-android-error-cannot-read-property-length-of-undefined
I found another solution by downgrading Android to version 6.1.2, since the suggestions here (and many other suggestions on various forums, like reinstalling plugins, etc.) didn't work for me:
cordova platform update android#6.1.2 --save
If that doesn't work at first hand, try the following:
First remove android platform:
cordova platform remove android
Add Android version 6.1.2:
cordova platform add android#6.1.2
Build Android:
cordova build android
Here are some additional steps I took prior to above (on Mac), just to make sure:
Download the latest JDK and install.
Add JAVA_HOME this way:
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
Restart shell (CMD+Q and open again)
Make sure echo $JAVA_HOME equals to Android Studio -> File -> Project Structure -> JDK Location
For me, this is the following path and version:
/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
Update Android Studio and all of the SDK packages
Update npm
npm update -g
Note: On OS X 10.11 El Capitan or greater, run:
sudo npm update -g --unsafe-perm=true
Update Cordova
npm update -g cordova
If all of this didn't work for you and you are left with no other choice, I suggest you try downgrading Cordova to version 6.4.0:
npm update -g cordova#6.4.0
You can downgrade cordova cli using
npm install -g cordova#6.4.0
and build the project with give command
ionic cordova build android
no need to add platform, it'll automatically add.
If it ask to update cordova cli, then choose no
Resolved an error by following:
Hi all,
Resolved problem to run cordova run android via command prompt for cordova project attached problem screenshot.
To resolve this problem removed all environment variables under Advanced System settings.
Uninstalled java and installed again, downloaded old sdk tools to avoid prompt for eclipse now.
Under user variable added
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_131
Under System variable
ANDROD_HOME = C:\cordova\android-sdk
Path = C:\Program Files\Android\Android Studio2\gradle\gradle-3.2\bin\;%JAVA_HOME%\bin to avoid error:
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
Problem resolved now 😊
The problem was that my gradle version was 2.1 where Cordova wanted 3.2. Updating Android Studio (It was at 2.1) and making sure the environment variables are upto date was the main trick to get it to work again.

spawn EACCESS Error while running / building Android Platform on Ionic 3

As many users, i had this error when doing
ionic cordova run android -android
or
cordova build android --verbose
the output :
No scripts found for hook "before_build".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform android
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at /Users/davidanquetin/GIT/MEDIATOOLS/DOMME/domme-app/platforms/android/res/xml/config.xml
Merging project's config.xml into platform-specific android config.xml
Merging and updating files from [www, platforms/android/platform_www] to platforms/android/assets/www
Wrote out android application name "Domme" to /Users/davidanquetin/GIT/MEDIATOOLS/DOMME/domme-app/platforms/android/res/values/strings.xml
Wrote out Android package name "com.pasquet.domme.all" to /Users/davidanquetin/GIT/MEDIATOOLS/DOMME/domme-app/platforms/android/src/com/pasquet/domme/all/MainActivity.java
Updating icons at platforms/android/res
Updating splash screens at platforms/android/res
This app does not have additional resource files defined
Prepared android project successfully
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
Running command: /usr/libexec/java_home
Command finished with error code 0: /usr/libexec/java_home
ANDROID_HOME=/Users/davidanquetin/Documents/_UTILITAIRES/TECHNIQUE/android-sdk-macosx/
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
Running command: "/Applications/Android Studio 3.0 Preview.app/Contents/gradle/gradle-4.0-milestone-1/bin/gradle" -p /Users/davidanquetin/GIT/MEDIATOOLS/DOMME/domme-app/platforms/android wrapper -b /Users/davidanquetin/GIT/MEDIATOOLS/DOMME/domme-app/platforms/android/wrapper.gradle
Error: spawn EACCES
i tried many manipulations founded on the web (chmod etc...) but nothing is working..
when i try
chmod +x /Applications/Android Studio 3.0 Preview.app/Contents/gradle/gradle-4.0-milestone-1/bin/gradle
i have :
chmod + /Applications/Android\ Studio\ 3.0\ Preview.app/Contents/gradle/gradle-4.0-milestone-1/bin/gradle
and always the same error after building...
thanks for ideas !
UPDATE / RESOLVED
The way i resolved the problem :
delete Android Studio app
redownload and reinstall it
update java
creating a new ionic project, then update it with my previous assets / code files.
reinstall platforms with a clean installation
and...it works !
I think it is manly Android Studio removing and reinstallation which resolves the problem.
If it could help !
UPDATE / RESOLVED
The way i resolved the problem :
delete Android Studio app
redownload and reinstall it
update java
creating a new ionic project, then update it with my previous assets
/ code files.
reinstall platforms with a clean installation
and...it works ! I think it is manly Android Studio removing and reinstallation which resolves the problem.
If it could help !

command cordova platform add android not recognized internal or external command?

I did all Pre-requests steps for creating phonegap android apps. I installed all things like a
Installing Apache ANT
Installing Eclipse
Adding Android ADT Plugin
Installing NodeJS
Installing Cordova
Setting up Environment Variable
but when I was fire the command like cordova platform add android then I got following screen
before this command all commands worked properly. please anybody tell me how to solve this problem..
Thanks in advance
As seen here, it seems cordova cli does not work correctly if you have spaces in the folder where you put your project.
Most people (including me) using windows 7 or 8 don't have the issue because "c:\Documents and Settings" has been replaced by "c:\Users".
Which version of cordova are you using? (I don't seem to be able to reproduce the issue with cordova 3.4.1)
I see two solutions for you (plus upgrading to latest cordova if you have a older version) :
1)Use folder's short name:
cd c:\Docume~1\Administrator\DesignTechCadAcadamy
cordova platform add android
or 2)Try to create a folder at the root of your disk and work in this folder instead of in your user's folder.
For example try
md c:\CordovaProjects
pushd c:\CordovaProjects
cordova create test
cd test
cordova platform add android

phonegap/ Cordova error: [RangeError: Maximum call stack size exceeded]

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.

Categories

Resources