Running into all kinds of issues setting up a new mobile app project. I was able to add the Android platform but when I try and run the app in emulator I get the following.
Run your project for android …
Copying web assets from www to android/app/src/main/assets/public in 13.64ms
Creating capacitor.config.json in android/app/src/main/assets in 866.68μs
[info] Found 1 Cordova plugin for android:
cordova-plugin-whitelist@1.3.5
[info] Inlining sourcemaps
copy android in 39.83ms
Updating Android plugins in 2.11ms
[info] Found 1 Cordova plugin for android:
cordova-plugin-whitelist@1.3.5
update android in 40.85ms
Running Gradle build - failed!
[error]
> Configure project :app
WARNING: Using flatDir should be avoided because it doesn’t support any meta-data formats.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':capacitor-android'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
> Namespace not specified. Please specify a namespace in the module's build.gradle file like so:
android {
namespace 'com.example.namespace'
}
If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the
namespace value in the build.gradle file using the AGP Upgrade Assistant; please refer to
https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
* 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 753ms
Error running your project for android!
Still can’t add iOS Platform but will do a new thread for that.
I don’t know if this is relevant but I notice in the output I pasted in my initial post says it has found cordova plugins or something. I have clearly set the app ad Capacitor in the settings.
Check your package.json file. Each Capacitor item should be on the same version. There is a bug somewhere that changes the version of “@capacitor/core” to 4.6.0 whenever you load a project, install a plugin, or switch from frontend to backend.
Your “@capacitor/android”: should be the same version as “@capacitor/core”,
Key in the new version, then run npm install in your terminal, then run npx cap sync
Another thing you can do (in addition) is tap the open in Android Studio button. Then just let the Gradle sync, maybe run the update. Should mostly happen automatically.
Then you should be able to launch the Android Emulator from Wappler.
Another thing to look out for, that I have been making a stink about is that the bundler that auto installs with Capacitor has been deprecated. So if you plan on using any Capacitor plugins on your mobile app, you will need a new bundler like Webpack.
I found this very useful, just keep your package.json file open and watch for and correct capacitor/core version reverts as they happen.
Why aren’t you using Capacitor for mobile app building in Wappler? Cordova is getting old and deprecated as it doesn’t support the latest Android versions well.
Trying to rebuild the App from scratch using Capacitor but it is still broken. Only with capacitor both iOS and Android are broken. Can’t even start a new app from scratch.
Brand New Fresh Capaicitor App …
Android:
✖ Running Gradle build - failed!
[error] Starting a Gradle Daemon (subsequent builds will be faster)
> Configure project :app
WARNING: Using flatDir should be avoided because it doesn't support any meta-data formats.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':capacitor-android'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
> Namespace not specified. Please specify a namespace in the module's build.gradle file like so:
android {
namespace 'com.example.namespace'
}
If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the
namespace value in the build.gradle file using the AGP Upgrade Assistant; please refer to
https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
* 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 7s
Error running your project for android!
This is not exactly true. Cordova is not deprecated, and is currently receiving updates.
It works fine with Android Studio Giraffe (built Aug 16, 2023). You just have to stay on Gradle 7. You can still target sdk 33 (the current requirement).
As somebody with an active Cordova project, it’s not very comforting to hear that while Cordova is available in Wappler, the advice is the use something else when things aren’t working. Just like Wappler cannot respond to every request for development, I cannot respond to every request to change platforms.
Yeah, it’s really hard to explain to my employer that I can no longer work on an app that was built two years ago without any problems. Then try and explain that I can not even build a new one from scratch because my software is broken. Doesn’t make me look good at all.
Adding to what these guys are saying. Mobile app functionality is a huge advertised selling point for Wappler which is pretty expensive as far as software goes. So it is discouraging when mobile stuff is not supported, thinly documented, or flat out doesn’t work. Even more discouraging when requests for help, clarification, guidance etc are ignored.
Ive made several posts similar to Brad’s that Wappler has ignored, in addition to other posts asking for guidance on mobile app issues that have never received a reply.
Wappler is advertised to us as a full app builder solution, but in reality it is just a website builder.
Per default Wappler creates a Capacitor 4 mobile app. The latest Android Studio (Giraffe) however runs on much newer tech and requires the latest Capacitor 5
You can easily upgrade your Wappler project to Capacitor 5 by opening a terminal within Wappler and running:
npm i -D @capacitor/cli@latest
and then:
npx cap migrate
answer the questions and you project will be migrated.
As explained in:
To also update the Wappler settings with the new Android Studio path, just open the Wappler Global Settings / Mobile and enter the JDK path there as: