ui-material-components icon indicating copy to clipboard operation
ui-material-components copied to clipboard

Gradle issues - Could not find com.android.tools.build:gradle:4.5.6

Open msl2000 opened this issue 3 years ago • 11 comments

Which platform(s) does your issue occur on?

-Android

Please, provide the following version numbers that your issue occurs with:

@nativescript-community/ui-material-bottomsheet v6.2.23

Please, tell us how to recreate the issue in as much detail as possible.

tns run android leads to the following error:

A problem occurred configuring root project 'ui_material_bottomsheet'.

Could not resolve all files for configuration ':classpath'. Could not find com.android.tools.build:gradle:4.5.6. Searched in the following locations: https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.5.6/gradle-4.5.6.pom https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.5.6/gradle-4.5.6.jar https://jcenter.bintray.com/com/android/tools/build/gradle/4.5.6/gradle-4.5.6.pom https://jcenter.bintray.com/com/android/tools/build/gradle/4.5.6/gradle-4.5.6.jar Required by: project :

This seems to have happened out of the blue today and have been unable to build my project since then.

Is there any code involved?

"dependencies": { "@fortawesome/fontawesome-pro": "^5.15.4", "@nativescript-community/ui-drawer": "^0.0.33", "@nativescript-community/ui-material-bottom-navigation": "^5.3.19", "@nativescript-community/ui-material-bottomsheet": "^6.2.23", "@nativescript-community/ui-material-tabs": "^5.3.19", "@nativescript-community/ui-svg": "0.0.8", "@nativescript/background-http": "^5.0.2", "@nativescript/camera": "^5.0.10", "@nativescript/core": "^8.0.11", "@nativescript/datetimepicker": "^2.1.9", "@nativescript/firebase": "^11.1.3", "@nativescript/imagepicker": "^1.0.6", "@nativescript/theme": "~3.0.1", "@nstudio/nativescript-pulltorefresh": "^3.0.2", "animate.css": "^4.1.1", "atob": "^2.1.2", "axios": "^0.24.0", "buffer": "^6.0.3", "file-system": "^2.2.2", "fs": "^0.0.1-security", "lodash": "^4.17.21", "moment": "^2.29.1", "nativescript-animate-sass": "^0.0.2", "nativescript-appversion": "^1.4.4", "nativescript-bottom-navigation": "^2.0.5", "nativescript-carousel": "^7.0.1", "nativescript-clipboard": "^2.1.1", "nativescript-google-maps-sdk": "^3.0.2", "nativescript-vue": "~2.9.0", "nativescript-vue-navigator": "^1.2.0", "vue-moment": "^4.1.0", "vue-slide-up-down": "^2.0.1", "vuex": "^3.6.2" }, .

msl2000 avatar Mar 08 '22 04:03 msl2000

the issue is not with this plugin but maybe with the cli or @nativescript/android. try to update them or ask on discors

farfromrefug avatar Mar 08 '22 07:03 farfromrefug

@msl2000 Please let me know when you manage to fix it. Updating the cli and @nativescript/android did not solve the problem for me.

ketuvin avatar Mar 08 '22 11:03 ketuvin

@ketuvin @msl2000 The issue is on the cli. You can fix it by installing npm i -g nativescript@next. Hope it wont break anything else...

farfromrefug avatar Mar 08 '22 12:03 farfromrefug

@farfromrefug it seems to be related so I am not creating a separate issue, but with the new cli using gradle 7+ I am getting:

Script '.../node_modules/@nativescript-community/ui-material-core/platforms/android/include.gradle' line: 7
A problem occurred evaluating script.
Could not find method compile() for arguments [androidx.appcompat:appcompat:1.2.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Command ./gradlew failed with exit code 1

nikoTM avatar Mar 23 '22 20:03 nikoTM

@nikoTM makes sure all.plugins are up to date and clean everything

farfromrefug avatar Mar 23 '22 21:03 farfromrefug

@farfromrefug it seems to be related so I am not creating a separate issue, but with the new cli using gradle 7+ I am getting:

Script '.../node_modules/@nativescript-community/ui-material-core/platforms/android/include.gradle' line: 7
A problem occurred evaluating script.
Could not find method compile() for arguments [androidx.appcompat:appcompat:1.2.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Command ./gradlew failed with exit code 1

Getting potentially same issue as well.

ui_material_core'.
> Could not find method compile() for arguments [androidx.appcompat:appcompat:1.2.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

have ran update on all plugins etc and still error appears

liamcharmer avatar Jul 25 '22 21:07 liamcharmer

@liamcharmer must be a clean issue. It is working fine with gradle 7.

farfromrefug avatar Jul 26 '22 14:07 farfromrefug

The issue is with NS cli. here is the workaround without updating anything else.

  1. Go to ns cli installation directory
  2. Search for getRuntimeGradleVersions method in android-plugin-build-service.js
  3. add runtimeGradleVersions = yield this.getGradleVersions(projectRuntimeVersion); line just after const projectRuntimeVersion = platformData.platformProjectService.getFrameworkVersion(projectData);. e.g.
    getRuntimeGradleVersions(projectDir) {
        return __awaiter(this, void 0, void 0, function* () {
            let runtimeGradleVersions = null;
            if (projectDir) {
                const projectData = this.$projectDataService.getProjectData(projectDir);
                const platformData = this.$platformsDataService.getPlatformData(this.$devicePlatformsConstants.Android, projectData);
                const projectRuntimeVersion = platformData.platformProjectService.getFrameworkVersion(projectData);
		runtimeGradleVersions = yield this.getGradleVersions(projectRuntimeVersion);
                this.$logger.trace(`Got gradle versions ${JSON.stringify(runtimeGradleVersions)} from runtime v${projectRuntimeVersion}`);
            }
            if (!runtimeGradleVersions) {
                const latestRuntimeVersion = yield this.getLatestRuntimeVersion();
                runtimeGradleVersions = yield this.getGradleVersions(latestRuntimeVersion);
                this.$logger.trace(`Got gradle versions ${JSON.stringify(runtimeGradleVersions)} from the latest runtime v${latestRuntimeVersion}`);
            }
            return runtimeGradleVersions || {};
        });
    }

Additional info (For windows)

  1. NS installed globally- android-plugin-build-service.js path for windows- %USERPROFILE%\AppData\Roaming\npm\node_modules\nativescript\lib\services
  2. In case you are maintaining the Node version via NVM then search under %USERPROFILE%\AppData\Roaming\nvm

rmn81 avatar Jan 29 '23 23:01 rmn81

@rmn81 thanks for the workaround. Wouldn't that mean that your CLI is not up to date?

farfromrefug avatar Jan 30 '23 20:01 farfromrefug

@farfromrefug Yep, my CLI is not up to date. First I tried to update CLI but after updating it, there were some build issues. So, right now I can't use the latest CLI.

rmn81 avatar Jan 31 '23 02:01 rmn81

Possible to share any detail on the build issue with latest cli?

NathanWalker avatar Jan 31 '23 03:01 NathanWalker