Failed to resolve local AAR built from local source module
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have a library module that I want to include as an AAR dependency into a sample app:
:my-library
:sample-app
So in sample/build.gradle
, I do the following:
repositories {
flatDir {
dirs "../my-library/build/outputs/aar"
}
}
// I have different flavors that specify whether to use the source or binary (aar) dependency
flavorDimensions "SOURCE_OR_BINARY"
productFlavors {
source { }
binary { }
}
dependencies {
sourceImplementation project(':my-library')
binaryImplementation(name: 'my-library-release', ext: 'aar') // <-- this line fails with error
}
tasks.whenTaskAdded { task ->
def taskName = task.name.toLowerCase()
if (taskName.toLowerCase().contains("binary")) {
// Prepare libs as binaries
task.dependsOn ('my-library:assembleRelease')
}
}
This works fine with ./gradlew
on the command line, but Android Studio reports a Failed to resolve: :my-library-release:
during gradle sync. If I do a ./gradlew assemble
on the command line, then sync Android Studio, the the AS Gradle sync succeeds.
The issue has to do with the timing of binaryImplementation(name: 'my-library-release', ext: 'aar')
. When Gradle Sync is executed, the aar
does not exist yet because it has yet to be built.
Is there a better way to do this that will avoid the Failed to resolve
Android Studio Gradle sync error?
android gradle android-gradle
add a comment |
I have a library module that I want to include as an AAR dependency into a sample app:
:my-library
:sample-app
So in sample/build.gradle
, I do the following:
repositories {
flatDir {
dirs "../my-library/build/outputs/aar"
}
}
// I have different flavors that specify whether to use the source or binary (aar) dependency
flavorDimensions "SOURCE_OR_BINARY"
productFlavors {
source { }
binary { }
}
dependencies {
sourceImplementation project(':my-library')
binaryImplementation(name: 'my-library-release', ext: 'aar') // <-- this line fails with error
}
tasks.whenTaskAdded { task ->
def taskName = task.name.toLowerCase()
if (taskName.toLowerCase().contains("binary")) {
// Prepare libs as binaries
task.dependsOn ('my-library:assembleRelease')
}
}
This works fine with ./gradlew
on the command line, but Android Studio reports a Failed to resolve: :my-library-release:
during gradle sync. If I do a ./gradlew assemble
on the command line, then sync Android Studio, the the AS Gradle sync succeeds.
The issue has to do with the timing of binaryImplementation(name: 'my-library-release', ext: 'aar')
. When Gradle Sync is executed, the aar
does not exist yet because it has yet to be built.
Is there a better way to do this that will avoid the Failed to resolve
Android Studio Gradle sync error?
android gradle android-gradle
Are you sure there isn't any other task that contains 'binary'?
– lelloman
Nov 19 '18 at 19:20
Are you are building an Android lib along with the application? If YES, I would suggest adding the lib module as a dependency from Project settings window. And once your lib is ready for production you can build aar from lib module and you can add to the app.
– Nikhil
Nov 20 '18 at 12:28
add a comment |
I have a library module that I want to include as an AAR dependency into a sample app:
:my-library
:sample-app
So in sample/build.gradle
, I do the following:
repositories {
flatDir {
dirs "../my-library/build/outputs/aar"
}
}
// I have different flavors that specify whether to use the source or binary (aar) dependency
flavorDimensions "SOURCE_OR_BINARY"
productFlavors {
source { }
binary { }
}
dependencies {
sourceImplementation project(':my-library')
binaryImplementation(name: 'my-library-release', ext: 'aar') // <-- this line fails with error
}
tasks.whenTaskAdded { task ->
def taskName = task.name.toLowerCase()
if (taskName.toLowerCase().contains("binary")) {
// Prepare libs as binaries
task.dependsOn ('my-library:assembleRelease')
}
}
This works fine with ./gradlew
on the command line, but Android Studio reports a Failed to resolve: :my-library-release:
during gradle sync. If I do a ./gradlew assemble
on the command line, then sync Android Studio, the the AS Gradle sync succeeds.
The issue has to do with the timing of binaryImplementation(name: 'my-library-release', ext: 'aar')
. When Gradle Sync is executed, the aar
does not exist yet because it has yet to be built.
Is there a better way to do this that will avoid the Failed to resolve
Android Studio Gradle sync error?
android gradle android-gradle
I have a library module that I want to include as an AAR dependency into a sample app:
:my-library
:sample-app
So in sample/build.gradle
, I do the following:
repositories {
flatDir {
dirs "../my-library/build/outputs/aar"
}
}
// I have different flavors that specify whether to use the source or binary (aar) dependency
flavorDimensions "SOURCE_OR_BINARY"
productFlavors {
source { }
binary { }
}
dependencies {
sourceImplementation project(':my-library')
binaryImplementation(name: 'my-library-release', ext: 'aar') // <-- this line fails with error
}
tasks.whenTaskAdded { task ->
def taskName = task.name.toLowerCase()
if (taskName.toLowerCase().contains("binary")) {
// Prepare libs as binaries
task.dependsOn ('my-library:assembleRelease')
}
}
This works fine with ./gradlew
on the command line, but Android Studio reports a Failed to resolve: :my-library-release:
during gradle sync. If I do a ./gradlew assemble
on the command line, then sync Android Studio, the the AS Gradle sync succeeds.
The issue has to do with the timing of binaryImplementation(name: 'my-library-release', ext: 'aar')
. When Gradle Sync is executed, the aar
does not exist yet because it has yet to be built.
Is there a better way to do this that will avoid the Failed to resolve
Android Studio Gradle sync error?
android gradle android-gradle
android gradle android-gradle
edited Nov 16 '18 at 19:58
ZakTaccardi
asked Nov 16 '18 at 15:02
ZakTaccardiZakTaccardi
5,96193478
5,96193478
Are you sure there isn't any other task that contains 'binary'?
– lelloman
Nov 19 '18 at 19:20
Are you are building an Android lib along with the application? If YES, I would suggest adding the lib module as a dependency from Project settings window. And once your lib is ready for production you can build aar from lib module and you can add to the app.
– Nikhil
Nov 20 '18 at 12:28
add a comment |
Are you sure there isn't any other task that contains 'binary'?
– lelloman
Nov 19 '18 at 19:20
Are you are building an Android lib along with the application? If YES, I would suggest adding the lib module as a dependency from Project settings window. And once your lib is ready for production you can build aar from lib module and you can add to the app.
– Nikhil
Nov 20 '18 at 12:28
Are you sure there isn't any other task that contains 'binary'?
– lelloman
Nov 19 '18 at 19:20
Are you sure there isn't any other task that contains 'binary'?
– lelloman
Nov 19 '18 at 19:20
Are you are building an Android lib along with the application? If YES, I would suggest adding the lib module as a dependency from Project settings window. And once your lib is ready for production you can build aar from lib module and you can add to the app.
– Nikhil
Nov 20 '18 at 12:28
Are you are building an Android lib along with the application? If YES, I would suggest adding the lib module as a dependency from Project settings window. And once your lib is ready for production you can build aar from lib module and you can add to the app.
– Nikhil
Nov 20 '18 at 12:28
add a comment |
3 Answers
3
active
oldest
votes
You need to add this to your app main build.gradle.
repositories {
/...
/...
flatDir {
dirs 'libs'
}
}
Lets say if you .aar file in the lib folder,then you could do something like this.
implementation files('libs/assembleRelease.aar')
this still fails. When Gradle Sync is executed, the aar does not exist yet because it has yet to be built.Unable to resolve dependency for ':sample@binaryDebug/compileClasspath': Failed to transform file 'my-library-release.aar' to match attributes {artifactType=processed-aar} using transform IdentityTransform
– ZakTaccardi
Nov 16 '18 at 19:58
add a comment |
You can try import with this way,
File -> New Module -> Import .Jar/.AAR package
add a comment |
I suggest that you use a local maven repository rather that flatDir. Dependencies which come from FileCollection and/or flatDir are not as full-featured as those coming from a "real" repository (eg maven/ivy)
Eg:
repositories {
maven {
url file("${rootProject.projectDir}/mavenRepo")
}
}
dependencies {
binaryImplementation "my-group:my-library:1.0@aar"
...
}
You'd then store the artifact using the maven repository directory layout. Eg:
rootProject/mavenRepo/my-group/my-artifact/1.0/my-artifact-1.0.aar
Once these two issues are implemented, then I can try this approach. I don't know if this issue will occur again when the artifact does not exist in the maven repo at gradle-sync time? but does exist after build time?
– ZakTaccardi
Apr 2 at 13:13
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340361%2ffailed-to-resolve-local-aar-built-from-local-source-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to add this to your app main build.gradle.
repositories {
/...
/...
flatDir {
dirs 'libs'
}
}
Lets say if you .aar file in the lib folder,then you could do something like this.
implementation files('libs/assembleRelease.aar')
this still fails. When Gradle Sync is executed, the aar does not exist yet because it has yet to be built.Unable to resolve dependency for ':sample@binaryDebug/compileClasspath': Failed to transform file 'my-library-release.aar' to match attributes {artifactType=processed-aar} using transform IdentityTransform
– ZakTaccardi
Nov 16 '18 at 19:58
add a comment |
You need to add this to your app main build.gradle.
repositories {
/...
/...
flatDir {
dirs 'libs'
}
}
Lets say if you .aar file in the lib folder,then you could do something like this.
implementation files('libs/assembleRelease.aar')
this still fails. When Gradle Sync is executed, the aar does not exist yet because it has yet to be built.Unable to resolve dependency for ':sample@binaryDebug/compileClasspath': Failed to transform file 'my-library-release.aar' to match attributes {artifactType=processed-aar} using transform IdentityTransform
– ZakTaccardi
Nov 16 '18 at 19:58
add a comment |
You need to add this to your app main build.gradle.
repositories {
/...
/...
flatDir {
dirs 'libs'
}
}
Lets say if you .aar file in the lib folder,then you could do something like this.
implementation files('libs/assembleRelease.aar')
You need to add this to your app main build.gradle.
repositories {
/...
/...
flatDir {
dirs 'libs'
}
}
Lets say if you .aar file in the lib folder,then you could do something like this.
implementation files('libs/assembleRelease.aar')
answered Nov 16 '18 at 17:15
Ramesh YankatiRamesh Yankati
70659
70659
this still fails. When Gradle Sync is executed, the aar does not exist yet because it has yet to be built.Unable to resolve dependency for ':sample@binaryDebug/compileClasspath': Failed to transform file 'my-library-release.aar' to match attributes {artifactType=processed-aar} using transform IdentityTransform
– ZakTaccardi
Nov 16 '18 at 19:58
add a comment |
this still fails. When Gradle Sync is executed, the aar does not exist yet because it has yet to be built.Unable to resolve dependency for ':sample@binaryDebug/compileClasspath': Failed to transform file 'my-library-release.aar' to match attributes {artifactType=processed-aar} using transform IdentityTransform
– ZakTaccardi
Nov 16 '18 at 19:58
this still fails. When Gradle Sync is executed, the aar does not exist yet because it has yet to be built.
Unable to resolve dependency for ':sample@binaryDebug/compileClasspath': Failed to transform file 'my-library-release.aar' to match attributes {artifactType=processed-aar} using transform IdentityTransform
– ZakTaccardi
Nov 16 '18 at 19:58
this still fails. When Gradle Sync is executed, the aar does not exist yet because it has yet to be built.
Unable to resolve dependency for ':sample@binaryDebug/compileClasspath': Failed to transform file 'my-library-release.aar' to match attributes {artifactType=processed-aar} using transform IdentityTransform
– ZakTaccardi
Nov 16 '18 at 19:58
add a comment |
You can try import with this way,
File -> New Module -> Import .Jar/.AAR package
add a comment |
You can try import with this way,
File -> New Module -> Import .Jar/.AAR package
add a comment |
You can try import with this way,
File -> New Module -> Import .Jar/.AAR package
You can try import with this way,
File -> New Module -> Import .Jar/.AAR package
answered Nov 22 '18 at 13:51
jefry jackyjefry jacky
419611
419611
add a comment |
add a comment |
I suggest that you use a local maven repository rather that flatDir. Dependencies which come from FileCollection and/or flatDir are not as full-featured as those coming from a "real" repository (eg maven/ivy)
Eg:
repositories {
maven {
url file("${rootProject.projectDir}/mavenRepo")
}
}
dependencies {
binaryImplementation "my-group:my-library:1.0@aar"
...
}
You'd then store the artifact using the maven repository directory layout. Eg:
rootProject/mavenRepo/my-group/my-artifact/1.0/my-artifact-1.0.aar
Once these two issues are implemented, then I can try this approach. I don't know if this issue will occur again when the artifact does not exist in the maven repo at gradle-sync time? but does exist after build time?
– ZakTaccardi
Apr 2 at 13:13
add a comment |
I suggest that you use a local maven repository rather that flatDir. Dependencies which come from FileCollection and/or flatDir are not as full-featured as those coming from a "real" repository (eg maven/ivy)
Eg:
repositories {
maven {
url file("${rootProject.projectDir}/mavenRepo")
}
}
dependencies {
binaryImplementation "my-group:my-library:1.0@aar"
...
}
You'd then store the artifact using the maven repository directory layout. Eg:
rootProject/mavenRepo/my-group/my-artifact/1.0/my-artifact-1.0.aar
Once these two issues are implemented, then I can try this approach. I don't know if this issue will occur again when the artifact does not exist in the maven repo at gradle-sync time? but does exist after build time?
– ZakTaccardi
Apr 2 at 13:13
add a comment |
I suggest that you use a local maven repository rather that flatDir. Dependencies which come from FileCollection and/or flatDir are not as full-featured as those coming from a "real" repository (eg maven/ivy)
Eg:
repositories {
maven {
url file("${rootProject.projectDir}/mavenRepo")
}
}
dependencies {
binaryImplementation "my-group:my-library:1.0@aar"
...
}
You'd then store the artifact using the maven repository directory layout. Eg:
rootProject/mavenRepo/my-group/my-artifact/1.0/my-artifact-1.0.aar
I suggest that you use a local maven repository rather that flatDir. Dependencies which come from FileCollection and/or flatDir are not as full-featured as those coming from a "real" repository (eg maven/ivy)
Eg:
repositories {
maven {
url file("${rootProject.projectDir}/mavenRepo")
}
}
dependencies {
binaryImplementation "my-group:my-library:1.0@aar"
...
}
You'd then store the artifact using the maven repository directory layout. Eg:
rootProject/mavenRepo/my-group/my-artifact/1.0/my-artifact-1.0.aar
edited Nov 26 '18 at 17:07
answered Nov 26 '18 at 17:00
lance-javalance-java
17k12964
17k12964
Once these two issues are implemented, then I can try this approach. I don't know if this issue will occur again when the artifact does not exist in the maven repo at gradle-sync time? but does exist after build time?
– ZakTaccardi
Apr 2 at 13:13
add a comment |
Once these two issues are implemented, then I can try this approach. I don't know if this issue will occur again when the artifact does not exist in the maven repo at gradle-sync time? but does exist after build time?
– ZakTaccardi
Apr 2 at 13:13
Once these two issues are implemented, then I can try this approach. I don't know if this issue will occur again when the artifact does not exist in the maven repo at gradle-sync time? but does exist after build time?
– ZakTaccardi
Apr 2 at 13:13
Once these two issues are implemented, then I can try this approach. I don't know if this issue will occur again when the artifact does not exist in the maven repo at gradle-sync time? but does exist after build time?
– ZakTaccardi
Apr 2 at 13:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340361%2ffailed-to-resolve-local-aar-built-from-local-source-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you sure there isn't any other task that contains 'binary'?
– lelloman
Nov 19 '18 at 19:20
Are you are building an Android lib along with the application? If YES, I would suggest adding the lib module as a dependency from Project settings window. And once your lib is ready for production you can build aar from lib module and you can add to the app.
– Nikhil
Nov 20 '18 at 12:28