android: Problem building nativescript-google-maps-sdk on Android

Using NS 4.1, tns-core 4.1 and tns-android 4.1.

Getting the following error during build on Android

`Unable to apply changes on device: emulator-5554. Error is: Failed to build plugin nativescript-google-maps-sdk : Error: Command ./gradlew failed with exit code 1 Error output:

FAILURE: Build failed with an exception.

  • What went wrong: Could not resolve all files for configuration ‘:releaseCompileClasspath’.

Could not find common.jar (android.arch.core:common:1.0.0). Searched in the following locations: https://jcenter.bintray.com/android/arch/core/common/1.0.0/common-1.0.0.jar

  • 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 1s`

The problem seems to be it’s looking for common-1.0.0.jar and it’s not on that jcenter site.

This happens on android@4.1.0 - the build works on android@4.0.1

More detailed info on the plug-in page.

Issue on the plug-in site

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 16 (1 by maintainers)

Most upvoted comments

@erjdriver got a working solution. You can try this: Open default build.gradle of nativescript from this location: for PC: C:\Users\USERNAME\AppData\Roaming\npm\node_modules\nativescript\vendor\gradle-plugin For Mac: /usr/local/lib/node_modules/nativescript/vendor/gradle-plugin change USERNAME to your username of PC. Now open the file build.gradle & change 2 parts as bellow:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
	jcenter()
        mavenLocal()
        mavenCentral()
    }
}

Now delete platforms directory & try to rebuild the app. It should work.

ref: https://stackoverflow.com/questions/50584437/android-studio-3-1-2-failed-to-resolve-runtime

Looks like in the latest version of build.gradle they moved one jcenter() but forgot to move the other one.

Faulty version:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenLocal()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }        
    }
}

Working version:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
    }
}

Here are my steps to reproduce:

`` $ tns create zzz --tsc $ cd zzz $ tns info ✔ Getting NativeScript components versions information… ✔ Component nativescript has 4.1.0 version and is up to date. ✔ Component tns-core-modules has 4.1.0 version and is up to date. ✔ Component tns-android has 4.1.3 version and is up to date. ✖ Component tns-ios is not installed.

$ tns plugin add nativescript-google-maps-sdk $ tns build android

Failed to build plugin nativescript-google-maps-sdk : Error: Command ./gradlew failed with exit code 1 Error output:

FAILURE: Build failed with an exception.

  • What went wrong: Could not resolve all files for configuration ‘:releaseCompileClasspath’.

Could not find runtime.jar (android.arch.lifecycle:runtime:1.0.0). Searched in the following locations: https://jcenter.bintray.com/android/arch/lifecycle/runtime/1.0.0/runtime-1.0.0.jar Could not find common.jar (android.arch.core:common:1.0.0). Searched in the following locations: https://jcenter.bintray.com/android/arch/core/common/1.0.0/common-1.0.0.jar

  • 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 0s ``

This fixed the problem.

Thank you.

@sitefinitysteve, are you able to re-open this, or should I open a separate issue? I am finding this issue when trying to install other plugins as well and it is making the experience quite broken.

Guessing just not reopened, hang on

So I got it to build but only after I manually changed global installed nativescript’s vendor/gradle-plugin/build.gradle file and put “google()” on the top in the repositories list. If I do npm remove -g nativescript && npm install -g nativescript and clear out the node_modules directory, it fails to build again.

I think it’s a bit too soon to close the issue.