Closed DonaldDuck313 closed 2 weeks ago
I'm sorry, but I can't reproduce your problem. I get the following error when I try your sample build script:
Plugin [id: 'com.android.application'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (No included builds contain this plugin)
- Plugin Repositories (plugin dependency must include a version number for this source)
I suppose your script is part of a larger project? Can you please provide a sample script that can be executed separately? Thanks!
I guess the two first plugins aren't really part of this issue, sorry for that. The following script should be the minimal one to reproduce the issue:
plugins {
id 'de.undercouch.download' version '5.6.0'
}
apply plugin: 'de.undercouch.download'
import de.undercouch.gradle.tasks.download.Download
tasks.register('peerjs', Download) {
src 'https://unpkg.com/peerjs/dist/peerjs.min.js'
dest layout.projectDirectory.dir('src/main/assets')
}
gradle.projectsEvaluated {
assembleDebug.dependsOn peerjs
assembleRelease.dependsOn peerjs
}
But I don't understand why you get that error, all the other code in my gradle script was added automatically by Android Studio and should work in any Android project. This is a relatively new project, the only other stuff that I've done was create an activity which shouldn't affect the gradle script.
So if you just create a completely new project in Android Studio and add the code above you should be able to reproduce the issue.
I still cannot execute this build script. I get the following error:
Could not get unknown property 'assembleDebug' for root project 'issue401' of type org.gradle.api.Project.
I'm using Gradle 8.8 by the way.
If I comment out the gradle.projectsEvaluated
block, everything works as expected and the file will be downloaded to the assets folder.
So if you just create a completely new project in Android Studio and add the code above you should be able to reproduce the issue.
I'm sorry but I am not an Android developer. If the script works outside Android Studio but not inside, I suspect a compatibility issue with the IDE. Do you happen to know if src/main/assets
is a special directory that is protected by Android Studio somehow? Maybe the IDE modifies Gradle's configuration? Can you check this please?
I found similar issues on the Internet. For example, this one: https://github.com/gradle/gradle/issues/19555. It seems when Gradle returns this error, it always displays a reason too. Something like: Reason: Task ':sourcesJar' uses this output of task ':generateGrammarSource' without declaring an explicit or implicit dependency
.
Do you also get a reason? Can you post the whole error message please? If you don't get additional information, can you run Gradle with the -i
parameter? Thanks.
I'm sorry but I am not an Android developer.
I guess that's why you can't reproduce it, I'm quite sure this problem can only be reproduced in Android Studio since the assets folder is Android-specific and it works for other folders. (I didn't even know Gradle existed outside of Android Studio).
I found similar issues on the Internet. For example, this one: gradle/gradle#19555. It seems when Gradle returns this error, it always displays a reason too. Something like:
Reason: Task ':sourcesJar' uses this output of task ':generateGrammarSource' without declaring an explicit or implicit dependency
.Do you also get a reason? Can you post the whole error message please? If you don't get additional information, can you run Gradle with the
-i
parameter? Thanks.
It doesn't give a reason. The only relevant part is what I already posted, the rest is just generic help links and a summary that the build failed:
A problem was found with the configuration of task ':app:peerjs' (type 'Download').
- Gradle detected a problem with the following location: 'C:\Users\glind\Documents\GitHub\MapCollector\app\app\src\main\assets\peerjs.min.js'.
* Try:
> 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.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 16s
60 actionable tasks: 33 executed, 27 up-to-date
Did you try to run it with -i
(or --info
as it says in the output)?
I'm sorry but without more information, it will be very hard to help you. I suggest to contact Android Studio developers. As you said, the issue is only reproducible there, so it's more likely it's a problem with Android Studio and not gradle-download-task. Let me know what you find out.
This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in two weeks if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed due to inactivity. If it is still valid, please post a comment.
Describe the bug
I'm trying to download Javascript libraries into the assets folder at build time (so that a webview in my app can use them at runtime even when offline). But if I try to download a file into the assets folder, I get the following error:
If I change it to download into
src/main
(instead ofsrc/main/assets
) this error goes away and the file gets downloaded correctly, but then I can't use it from the webview at runtime.Sample build script