Could not get unknown property 'mavenUser' for Credentials

indent preformatted text by 4 spaces

Hi, All I am getting an error below in my build.Gradle in AndroidStudio

Could not get unknown property ‘mavenUser’ for Credentials [username: null] of type org.gradle.api.internal.artifacts.repositories.DefaultPasswordCredentials_Decorated.

and below my build.gradle

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:0.7.+’

    repositories {
        mavenCentral()
        maven {


            // ~/.gradle/gradle.properties should be configured!
            credentials {
                username mavenUser
                password mavenPassword
            }
            url 'http://dev.softwerk.se:8080/nexus/content/repositories/softwerk-repo'
        }
    }

    android {
        compileSdkVersion 19
        buildToolsVersion "19.0.1"

        defaultConfig {
            minSdkVersion 8
            targetSdkVersion 19
            versionCode 2014020601
            versionName "2.0.0"
        }

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    dependencies {
        compile 'com.android.support:support-v4:19.0.+'
        compile 'com.android.support:appcompat-v7:19.0.+'
        compile 'com.google.android.gms:play-services:4.0.30'

        // Sync framework
        compile 'se.softwerk.commons.android:android-framework:1.1.10@aar'
        compile 'com.googlecode.plist:dd-plist:1.0'
        compile 'com.google.code.gson:gson:1.7.1'
        compile 'commons-io:commons-io:2.1'
    }
}`Preformatted text`

}

Th answer is already in your commented line.

// ~/.gradle/gradle.properties should be configured!
            credentials {
                username mavenUser
                password mavenPassword
            }
            url 'http://dev.softwerk.se:8080/nexus/content/repositories/softwerk-repo'

Edit or create ~/.gradle/gradle.properties if not exist yet.
Then add

mavenUser=yourusername
mavenPassword=secretpassword

The yourusername and secretpassword are to be provided from the maven repo dev.softwerk.se

We would like to set username and password for Artifactory using JVM arguments

Our build.gradle has
repositories {
maven {
url ‘https://Artifactory_url/’
credentials {
username = “{artifactory_username}" password = "{artifactory_password}”
}
}
}

we have set the JVM arguments as
-Partifactory_username=<jfrog_artifactory_username> -Partifactory_password=<jfrog_artifactory_password> -Prelease.version=<version_number>

This doesn’t work in MyEclipse when it starts up during auto build and throws an exception.

Build file ‘C:\Users\Vikram.Mahuvakar_SER\git\mytest\build.gradle’ line: 45
A problem occurred evaluating root project ‘mytest’.
Could not get unknown property ‘artifactory_username’ for Credentials [username: null] of type org.gradle.internal.credentials.DefaultPasswordCredentials_Decorated.
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution ‘https://services.gradle.org/distributions/gradle-5.1.1-bin.zip’.

This works when I select the project and right mouse select Run as Configuration mytest - build where I have set value of all the -P arguments shown above.

Any suggestion how I can resolve this?