Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27835] Android: Repository specified in modules build.gradle is not able to be resolved when building an application

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionNot Our Bug
Resolution Date2020-04-08T16:01:47.000+0000
Affected Version/sRelease 9.0.0, Release 9.1.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterEwan Harris
AssigneeUnknown
Created2020-04-07T12:37:06.000+0000
Updated2020-04-08T16:01:51.000+0000

Description

Description

When providing an extra maven repository that provides a dependency in a modules build.gradle file, when building an application that uses that dependency cannot be resolved. *Workaround*: In your application, add a build.gradle to platform/android (classic) or app/platform/android (alloy) that contains the repository definition.

Steps to reproduce

1. Copy the below to a build.gradle file in a module
allprojects {
	repositories {
		maven { url 'https://dl.bintray.com/radiusnetworks/flybuy-sdk'}
	}
}
dependencies {
	implementation "com.radiusnetworks.flybuy:sdk:1.1.1"
	implementation "com.radiusnetworks.flybuy:api:1.1.1"
}

2. Build the module using appc run -p android (so the app creation/building happens)

Actual

During the *application build* the following error occurs
[ERROR] [GRADLE]
[ERROR] [GRADLE] FAILURE: Build failed with an exception.
[ERROR] [GRADLE]
[ERROR] [GRADLE] * What went wrong:
[ERROR] [GRADLE] Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
[ERROR] [GRADLE] > Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
[ERROR] [GRADLE]    > Could not find com.radiusnetworks.flybuy:api:1.1.1.
[ERROR] [GRADLE]      Required by:
[ERROR] [GRADLE]          project :app > com.awam:foo:1.0.0
[ERROR] [GRADLE]
[ERROR] [GRADLE] * Try:
[ERROR] [GRADLE] 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.
[ERROR] [GRADLE]
[ERROR] [GRADLE] * Get more help at https://help.gradle.org
[ERROR] [GRADLE]
[ERROR] [GRADLE] BUILD FAILED in 2s
[ERROR] "gradlew" tool returned exit code: 1
[ERROR] Failed to run ti /Users/awam/.nvm/versions/node/v10.16.3/bin/ti

Expected

My expectation is that the repository definition shouldn't be required in app and module (but I could be wrong)

Comments

  1. Joshua Quick 2020-04-07

    It's an issue with the "build.gradle" file. The "allprojects" part can only be used by the root "build.gradle" which the app developer cannot define; it's auto-generated by Titanium. So, just get rid of the "allprojects" part like the below. I've tested it and it works.
       repositories {
       	maven { url 'https://dl.bintray.com/radiusnetworks/flybuy-sdk'}
       }
       dependencies {
       	 implementation "com.radiusnetworks.flybuy:sdk:1.1.1"
       	 implementation "com.radiusnetworks.flybuy:api:1.1.1"
       }
       
  2. Joshua Quick 2020-04-07

    Note that if you're building a module, then you need the above "build.gradle" in your module's "android" directory. Unfortunately, gradle ignores custom repo URLs in the POM file used to declare the libraries dependencies. https://github.com/gradle/gradle/issues/8811 So, in your Titanium app project, you need to add a "build.gradle" under the "./platform/android" directory too
       repositories {
       	maven { url 'https://dl.bintray.com/radiusnetworks/flybuy-sdk'}
       }
       
  3. Ewan Harris 2020-04-08

    Closing as not our bug based off previous comments. This is a limitation in gradle where a repository set in a module isn't persisted in the built sources (gradle does this for security). As stated in the ticket description the repository needs to be set in both the

JSON Source