1

I have recently converted my only cordova project to use Ionic and Capacitor. Publishing to the app store I find my app is too big (in the aab format), because I have too many images. I understand I need to create an asset pack. All I can find about the details of a creating an asset pack is https://developer.android.com/guide/playcore/asset-delivery/integrate-native (anyone have any better information?).

After following those steps, in VS Code I ...

 > ionic build
 > ionic capacitor build

Then in Android studio I do.

Menu | Build | Make Project 

I get the following error:

Build file 'C:\code\myco-match\android\build.gradle' line: 27

A problem occurred evaluating root project 'android'.
> Could not find method android() for arguments [build_19eh0vogqj489iczcfbatfj08$_run_closure2@69641835] on root project 'android' of type org.gradle.api.Project.

Line 27 is

android {
    assetPacks = [":species-images"]
}

Did I leave out a step in the build?

Am I missing something in my gradle configuration? I am not that familiar with gradle).

Did I forget something in my initial app conversion? It was my 1st cordova project converted to my 1st ionic and capacitor project.

Any ideas?

Paul Hill
  • 91
  • 1
  • 7
  • I got an error with a dash in the asset pack name as mentioned here https://stackoverflow.com/questions/44531814/android-studio-xml-error/44533155 don't use dashes in the pack name! – Paul Hill Nov 05 '21 at 21:56

1 Answers1

0

The problem is that in the reference in my first link above I mis-read step 2.

https://developer.android.com/guide/playcore/asset-delivery/integrate-native

Reading the following stack overflow issue

Gradle sync failed: Could not find method android() for arguments on root project on android studio

Gabriele Mariotti said the poster "using the wrong build.gradle file. You can't define the android block in the top-level file."

Reviewing the instructions step 4 says "In the project’s app build.gradle file" I had incorrectly changed the top-level build.gradle file. Step 7 lists build.gradle as if you change it, but that list item ought to be /app/build.gradle.

Now I can build and package using android studio.

Paul Hill
  • 91
  • 1
  • 7