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

Created on 10 Jun 2018  Â·  12Comments  Â·  Source: NativeScript/android-runtime

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.

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 [email protected] - the build works on [email protected]

More detailed info on the plug-in page.

Issue on the plug-in site

Most helpful comment

@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

All 12 comments

Same problem for me. It's happening when NativeScript is generating .aar from plugins under platforms/tempPlugin/nativescript_PLUGIN. I tried to change build.gradle file's repositories like this:

repositories {
         google()
        jcenter()
}

&

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

But that file got override each time & show error as above. I tried to prevent overriding & that time it worked. But need a good solution.

@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

@jibon57 your solution works very well.

This fixed the problem.

Thank you.

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.

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.

BUILD FAILED in 0s
``

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()
    }
}

😥

How is this marked as fixed? The only (working) work around involves modifying the nativescript library manually. This is not a practical or scalable solution.

Guessing just not reopened, hang on

@erjdriver, please re-open this. It needs to be fixed in the library.

@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.

Was this page helpful?
0 / 5 - 0 ratings