Ionic Cordova Confused With The New Bundle Building For Android

Viewed 159

I am tearing my hair out with the changes to how you submit an app to google. You now have to submit a bundle which i am trying to generate with ./gradlew bundle but i just keep getting confusing errors below:

* What went wrong:

A problem occurred evaluating project ':app'.

No installed build tools found. Install the Android build tools version 19.1.0 or higher.

  • 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. ==============================================================================

2: Task failed with an exception.

  • What went wrong: A problem occurred configuring project ':app'.

compileSdkVersion is not specified. Please add it to build.gradle

The first issue is confusing because i have build tools installed, the path output is this:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:~/Library/Android/sdk/tools:~/Library/Android/sdk/platform-tools

Which is the correct location of the sdk.

The second error i don't follow at all, in my config.xml i have this:

I then ionic cordova build android --prod --release before the gradlew command is run. I also looked in the build.gradle file and found the following:

allprojects {
apply from: 'repositories.gradle'
repositories repos

//This replaces project.properties w.r.t. build settings
project.ext {
defaultCompileSdkVersion=29
  defaultBuildToolsVersion="29.0.2" //String
  defaultMinSdkVersion=22 //Integer - Minimum requirement is Android 5.1
  defaultTargetSdkVersion=29 //Integer - We ALWAYS target the latest by default
  defaultCompileSdkVersion=29 //Integer - We ALWAYS compile with the latest by default
}

}

So it's telling it to use compile sdk version 29 by default for all projects. If i add the following and then run gradlew:

android{
    compileSdkVersion=29
}

I get the following issue when running gradlew:

 Could not find method android() for arguments [build_86qvliu728ivbijvz823o6ru1$_run_closure2@2ba919e2] on root project 'android' of type org.gradle.api.Project.

I'm at a total loss!

1 Answers

Android SDK build tools are in the Android/sdk/build-tools.

So what I suggest first, please check if you've added ANDROID_SDK_ROOT in your environment variables. And it must refer to your Android SDK location (../Android/sdk)

Related