Just recently I've been having some trouble building my Android platform. When I build, I get two task errors.
1: Task failed with an exception.
-----------
* Where:
Build file '/Users/.../platforms/tempPlugin/core/build.gradle' line: 7
* What went wrong:
A problem occurred evaluating root project 'core'.
> Failed to apply plugin 'kotlin-android'.
> Kotlin: Unsupported version of com.android.tools.build:gradle plugin: version 7.1.3 or higher should be used with kotlin-android plugin
* 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 root project 'core'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
* 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 408ms
Failed to build plugin @nativescript/core :
Error: Command ./gradlew failed with exit code 1
I thus went ahead and specified the compileSDKVersion in my App_Resources/Android/app.gradle
file.
// You can add your native dependencies here
dependencies {
// implementation 'androidx.multidex:multidex:2.0.1'
implementation "com.android.billingclient:billing:7.1.1"
}
android {
compileSdkVersion 34
// buildToolsVersion "32.0.0"
// ndkVersion ""
defaultConfig {
minSdkVersion 21
targetSdkVersion 34
// Version Information
versionCode 69
versionName "3.1.6"
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
However, I'm not sure how to address the other task issue about the com.android.tools.build:gradle plugin
. I have a before-plugins.gradle
file in my App_Resouces/Android/
folder that looks like this
// this configurations is loaded before building plugins, as well as before building
// the app - this is where you can apply global settings and overrides
project.ext {
// androidXAppCompat = "1.4.1"
// androidXExifInterface = "1.3.3"
// androidXFragment = "1.4.1"
// androidXMaterial = "1.5.0"
// androidXMultidex = "2.0.1"
// androidXTransition = "1.4.1"
// androidXViewPager = "1.0.0"
// useKotlin = true
// kotlinVersion = "1.6.0"
}
I made a build.gradle file at the root of my NS directory with the following code:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0' // Example: Use a version >= 7.1.3
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20" // Example: A compatible Kotlin version
}
}
I did an NS clean and a fresh build and I still get the same error. Nothing is working. Can I please get some help with this?
Below is my package.json
{
"name": "...",
"main": "./src/main.ts",
"version": "1.0.0",
"private": true,
"dependencies": {
"@angular/animations": "~14.1.0",
"@angular/cdk": "^14.1.1",
"@angular/common": "~14.1.0",
"@angular/compiler": "~14.1.0",
"@angular/core": "~14.1.0",
"@angular/forms": "~14.1.0",
"@angular/platform-browser": "~14.1.0",
"@angular/platform-browser-dynamic": "~14.1.0",
"@angular/router": "~14.1.0",
"@bradmartin/nativescript-urlhandler": "^2.0.1",
"@mhtghn/nativescript-highcharts": "^1.0.2",
"@nativescript-community/ble": "^3.1.22",
"@nativescript-community/insomnia": "^2.0.2",
"@nativescript-community/perms": "2.2.13",
"@nativescript-community/sentry": "^4.6.2",
"@nativescript-community/ui-material-bottom-navigation": "^7.0.28",
"@nativescript-community/ui-material-bottomnavigationbar": "^7.0.25",
"@nativescript-community/ui-material-tabs": "^7.0.28",
"@nativescript/angular": "^14.0.0",
"@nativescript/core": "^8.4.1",
"@nativescript/datetimepicker": "^2.1.11",
"@nativescript/firebase-analytics": "^2.5.1",
"@nativescript/firebase-auth": "^2.5.1",
"@nativescript/firebase-core": "^2.5.1",
"@nativescript/firebase-database": "^2.5.1",
"@nativescript/firebase-firestore": "^2.5.1",
"@nativescript/firebase-functions": "^2.5.1",
"@nativescript/payments": "~3.0.2",
"@nativescript/theme": "~3.0.2",
"@triniwiz/nativescript-toasty": "^4.1.3",
"bluebird": "3.5.5",
"crypto-es": "^1.2.7",
"reflect-metadata": "^0.1.13",
"rxjs": "~6.6.7",
"zone.js": "~0.11.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "~14.1.0",
"@angular/compiler-cli": "~14.1.0",
"@nativescript/android": "~8.3.1",
"@nativescript/ios": "^8.3.3",
"@nativescript/types": "~8.3.0",
"@nativescript/webpack": "~5.0.9",
"@ngtools/webpack": "~14.1.0",
"typescript": "~4.7.0"
}
}