Could not get unknown property 'repositoryUrl' for project

458
May 15, 2017, at 06:47 AM

I have a project employing React-Native. I'm building the RN module from source, so my project has the ReactAndroid module as a dependency.

I was trying to upgrade the project to Android gradle build tools >=2.3.2, so I could use intant-run:

buildscript {
    repositories {
        jcenter()
        mavenLocal()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
        ...
    }
}

This change forced me to upgrade gradle itself from 3.1 to 3.5 (latest stable).

Building the project suddenly produces the following gradle error

Could not get unknown property 'repositoryUrl' for project ':ReactAndroid' of type org.gradle.api.Project.

Can anyone help?

Answer 1

Well, this turned out interesting.

The reason

The error pointed to the this line at the React-Native module's release.gradle:

def getRepositoryUrl() {
    return hasProperty('repositoryUrl')  ? property('repositoryUrl') : 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}

Strangely enough, the problem is that hasProperty('repositoryUrl') returns true, while property('repositoryUrl') causes the error.

On gradle 3.1, hasProperty('repositoryUrl') returns false.

Apparently in gradle 3.5, hasProperty() returns true in cases where the property is indeed missing but still has a getter. In our case the getter is

def getRepositoryUrl() {...}

This is vaguely explained here.

There is however another method of checking for properties, which ignores getters, named findProperty.

The fix

So the fix was to change the following block from release.gradle:

def getRepositoryUrl() {
    return hasProperty('repositoryUrl') ? property('repositoryUrl') : 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}
def getRepositoryUsername() {
    return hasProperty('repositoryUsername') ? property('repositoryUsername') : ''
}
def getRepositoryPassword() {
    return hasProperty('repositoryPassword') ? property('repositoryPassword') : ''
}

To this:

def getRepositoryUrl() {
    return findProperty('repositoryUrl') != null ? property('repositoryUrl') : 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}
def getRepositoryUsername() {
    return findProperty('repositoryUsername') !=null ? property('repositoryUsername') : ''
}
def getRepositoryPassword() {
    return findProperty('repositoryPassword') != null ? property('repositoryPassword') : ''
}

More pains where building the RN module from source here.

READ ALSO
When and why deliverResult is called in AsyncTaskLoader?

When and why deliverResult is called in AsyncTaskLoader?

I want to establish a good understanding of the AsyncTaskLoader lifecycleI checked several resources, everything is clear but the usage of deliverResult

223
My authorization on website with android does not working

My authorization on website with android does not working

My authorization on website with android does not workingI first investigated the requests for the site using the Chrome console

299
how can i make listview itmes open meny url in webview?

how can i make listview itmes open meny url in webview?

I tried several times to do an example like the picture in android but failed Is it possible to help with code example? To make this applicationenter image description here

232
Not able to properly sign out the user

Not able to properly sign out the user

I'm checking whether the signed in user email is exactly the same as the email in my firebase database

169