-
-
Notifications
You must be signed in to change notification settings - Fork 142
Closed
Description
Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):
- NativeScript-Vue
- CLI: 8.5.3
- NativeScript: 8.5.3
- Android Runtime: 8.5.0
Describe the bug
ns run android gets to Gradle build and fails. Below is the output form the terminal:
Gradle build...
+ applying user-defined configuration from /<path>/app/App_Resources/Android/settings.gradle
FAILURE: Build failed with an exception.
* Where:
Script '/<path>/app/App_Resources/Android/settings.gradle' line: 3
* What went wrong:
A problem occurred evaluating script.
> Could not find method task() for arguments [replaceSettings, settings_9f0ihdbhsry4akdttkhpjzk68$_run_closure1@860396b] on settings 'proto' of type org.gradle.initialization.DefaultSettings.
* 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 510ms
Unable to apply changes on device: emulator-5554. Error is: Command ./gradlew failed with exit code 1.
Here is the settings.gradle file:
import groovy.json.JsonSlurper
task replaceSettings {
description "Replaces configuration settings."
def jsonSlurper = new JsonSlurper()
def pathToSettingsJson
if (project.hasProperty("appResourcesPath")) {
pathToSettingsJson = "$project.appResourcesPath/Android/settings.json";
} else {
pathToSettingsJson = "$rootDir/../../app/App_Resources/Android/settings.json";
}
def settingsJsonFile = file(pathToSettingsJson);
def settingsResolvedPath = settingsJsonFile.getAbsolutePath();
if(settingsJsonFile.exists())
{
println "\t Applying settings from $settingsResolvedPath"
String settingsGradleTemplate = """android {
defaultConfig {
applicationId = "__appId__"
if (__minSdkVersion__) {
minSdkVersion = __minSdkVersion__
}
if (__targetSdkVersion__) {
targetSdkVersion = __targetSdkVersion__
}
}
}"""
def settingsJsonContent = settingsJsonFile.getText("UTF-8");
def settingsMap = jsonSlurper.parseText(settingsJsonContent);
for ( setting in settingsMap ) {
def placeholder = "__${setting.key}__";
def settingValue = setting.value;
if (settingValue == null) {
settingValue = false
}
settingsGradleTemplate = settingsGradleTemplate.replaceAll( placeholder, settingValue as String);
}
new File( "$rootDir/temp_setting.gradle" ).write( settingsGradleTemplate, 'UTF-8');
apply from: "$rootDir/temp_setting.gradle";
}
}Here is the app.gradle file:
android {
defaultConfig {
minSdkVersion 27
generatedDensities = []
targetSdkVersion 33
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
def settingsGradlePath
if(project.hasProperty("appResourcesPath")){
settingsGradlePath = "$project.appResourcesPath/Android/settings.gradle";
} else {
settingsGradlePath = "$rootDir/../../app/App_Resources/Android/settings.gradle";
}
def settingsGradleFile = new File(settingsGradlePath);
if(settingsGradleFile.exists())
{
apply from: settingsGradleFile;
}Here is my package.json -
"dependencies": {
"@nativescript-community/https": "4.1.0",
"@nativescript-community/ui-material-tabs": "^7.0.37",
"@nativescript/core": "8.5.3",
"@nativescript/email": "^2.0.5",
"@nativescript/firebase": "^11.1.3",
"@nativescript/secure-storage": "^3.0.0",
"@nstudio/nativescript-barcodescanner": "^5.0.1",
"@nstudio/nativescript-filterable-listpicker": "^3.0.0",
"@nstudio/root-detection": "^2.0.1",
"@triniwiz/nativescript-socketio": "^5.0.1",
"@triniwiz/nativescript-toasty": "^4.1.3",
"@types/aes-js": "^3.1.1",
"aes-js": "^3.1.2",
"date-fns": "^2.15.0",
"electron": "^25.0.0",
"js-sha256": "^0.9.0",
"nativescript-carousel": "^7.0.1",
"nativescript-exit": "^1.0.1",
"nativescript-fonticon": "^2.0.2",
"nativescript-modal-datetimepicker": "^2.1.5",
"nativescript-phone": "^3.0.2",
"nativescript-picker": "^2.1.2",
"nativescript-socketio": "^3.3.1",
"nativescript-toasty": "3.0.0-alpha.2",
"nativescript-videoplayer": "^5.0.1",
"nativescript-vue": "^2.7.1",
"nativescript-vue-shadow": "^0.1.0",
"vuex": "^3.6.2"
},
"devDependencies": {
"@babel/core": "^7.11.1",
"@babel/preset-env": "^7.11.0",
"@nativescript/android": "~8.5.0",
"@nativescript/ios": "8.5.2",
"@nativescript/types": "^8.0.1",
"@nativescript/webpack": "~5.0.13",
"@types/node": "20.2.5",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"babel-loader": "9.1.2",
"eslint": "8.41.0",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-html": "7.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "9.14.1",
"hard-source-webpack-plugin": "^0.13.1",
"nativescript-vue-template-compiler": "^2.7.1",
"sass": "1.62.1",
"typescript": "^5.0.4",
"vue": "^2.7.14",
"vue-loader": "^17.1.2"
}I have tried upgrading to latest version of node (18.16.0), upgrading Android Studio (Flamingo), removing the gradle file from my home directory so it re-installs on ns run android but I'm still getting the error. Reverting to older versions of the run time / cli also doesn't help.
Any help with this would be greatly appreciated. Thanks.
Metadata
Metadata
Assignees
Labels
No labels