Unable to run Android Emulator on new project

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 …
:heavy_check_mark: Copying web assets from www to android/app/src/main/assets/public in 13.64ms
:heavy_check_mark: 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
:heavy_check_mark: copy android in 39.83ms
:heavy_check_mark: Updating Android plugins in 2.11ms
[info] Found 1 Cordova plugin for android:
cordova-plugin-whitelist@1.3.5
:heavy_check_mark: update android in 40.85ms
:heavy_multiplication_x: 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.

One of the errors has to do with not having a namespace … I checked the Gradle file and it is indeed there.

Seems indeed there’s some issue with the Gradle 8.x version. We are going to check this.

1 Like

I just upgraded my Cordova apps and found Gradle 8 is definitely not supported by Cordova Android 12, so don’t bother checking there.

Not sure about capacitor.

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.

@brad

I have had and solved this same problem.

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.

Hope this helps!

1 Like

@brad

Here is a video of me getting it to work. Uses API 33 (not like in the Wappler docs). Hope this helps :slight_smile:

3 Likes

Thanks Cameron. I will explore a bit further. I appreciate your time.

1 Like

mine is currently like this, is that correct? that Android API 34 I can’t change it, my android studio is in the flamingo version.

I’ve been using 33. To change you may want to reinstall.

The most important part is the capacitor/core versions in the package.json

Is there a timeline on making app building possible with Wappler again? Do I need to find an alternative?

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.

So just try using Capacitor instead.

Because App was built a couple years ago.

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!

iOS:

Exsisting Cordova App:

Android:


* Where:
Settings file '/Users/bradlawryk/Documents/Kopar/Apps/2023 Client Gateway App/platforms/android/settings.gradle'

* What went wrong:
Could not compile settings file '/Users/bradlawryk/Documents/Kopar/Apps/2023 Client Gateway App/platforms/android/settings.gradle'.

iOS: Still works fine.

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. :slight_smile:

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:

/Applications/Android Studio.app/Contents/jbr/Contents/Home

Then also restart Wappler after that.

You should be able to run the mobile app in both iOS and Android Emulators and also open in for futher publishing in Android Studio or Xcode

Here a few screenshots of a quick new wappler mobile app running in both ios and android emulators:

Still getting Gradle errors on new app …

✖ Upgrading gradle wrapper files - failed!
[error] gradle wrapper files were not updated
✔ Writing breaking changes. in 148.69μs