Status Update
Comments
xa...@google.com <xa...@google.com>
as...@gmail.com <as...@gmail.com> #2
It seems sync is bypassing gradle a lot running ExternalNativeBuildJsonGenerator directly based on output from gradle.api.verbose=true flag.
That makes it impossible to actually generate any native code using Gradle tasks as this won't exist while syncing and cause build failures.
jo...@google.com <jo...@google.com> #3
as...@gmail.com <as...@gmail.com> #4
Gradle version 4.4.1
NDK version: 17 beta 1
Android Plugin version 3.0.1
as...@gmail.com <as...@gmail.com> #5
gradle.afterProject {
tasks.getByName("generateJsonModelDebug").dependsOn "myPluginGenerateTask"
tasks.getByName("generateJsonModelRelease").dependsOn "myPluginGenerateTask"
}
and
android.libraryVariants.all { variant ->
tasks.getByName("generateJsonModel${variant.buildType.name.capitalize()}").dependsOn "myPluginGenerateTask"
tasks.getByName("generateJsonModel${variant.buildType.name.capitalize()}").dependsOn "myPluginGenerateTask"
}
The generating task exists - and generateJsonModel* does run it in normal ./gradlew build but not in Android Studio sync.
ok...@gmail.com <ok...@gmail.com> #6
I attached a simple project to demonstrate the issue. It has a library subproject and an app subproject that depends on the library. Both are using externalNativeBuild. The contents of the projects do not matter and the builds will not fail because the projects don't actually contain anything that uses the other project. However, the issue is that when syncing the output in Android Studio shows that the 'app' project is wrongly being configured first:
*** configuring app project ***
*** configuring library project ***
Android Studio version: 4.0
Android Gradle plugin version 4.0.0
Gradle version: 6.1.1
da...@google.com <da...@google.com> #7
Just to make sure I'm right with that dup, what are you actually trying to accomplish? The dependency in your sample appears to serve no purpose. I'm guessing that was just a reduction to show the missing dependency that reduced enough to hide the original intent :)
The original bug here was to make it possible for one module to use the output libraries of another. Assuming that's the goal here, getting the ordering of sync fixed won't help. Sync can't depend on the output of a build (this is policy rather than actually impossible; doing otherwise would potentially result in very long syncs, which means a very long time between opening the IDE and it being usable), so syncing your dependent library still won't be able to see the dependency. We do have a plan to enable that workflow though, and that's the duped bug.
If that's not your goal, please let us know what the goal is :) There isn't a dependency between sync tasks for dependent modules because there's no purpose that can serve as far as we know.
ok...@gmail.com <ok...@gmail.com> #8
The reason for this kind of setup is that the library is quite big and takes a long time to compile. There are multiple small native app projects referencing it, so just referencing the library from cmake would rebuild it for every app project. I don't want to prebuild the library project manually because it's the thing that is being actively developed and I don't want to build it separately from the small test/sample apps used in its development.
I guess if the other issue enables this kind of native library export-import scenario, it's an OK duplicate.
da...@google.com <da...@google.com> #9
I guess if the other issue enables this kind of native library export-import scenario, it's an OK duplicate.
Okay, sounds good. Thanks for clarifying.
jo...@google.com <jo...@google.com> #10
After that, when 'app' depends on 'lib' and there is a dependencies { implementation } in app to lib then lib's C++ configuration phase (generateJsonModel) will run before app's C++ configuration phase.
Any feedback, especially in canary or beta timeframes, is greatly appreciated.
Description
I would expect that task to depend on the required project's externalNativeBuild. This happens with all kinds of project dependencies.
Fixing this would allow the dependent project to use generated headers and libraries of the project being depended upon.
Doing this in pure CMake is not possible, as generateJsonDebug task may depend on some generated files of the other project.
(Adding the task dependency manually works but is a hack.)
To reproduce, create two projects, one depending on the other, both with native libs, attempt to use any generated file from the depended upon project in the dependent project.
Gradle version: 4.1
Android Plugin Version: 3.0.0-beta4
NDK version: 16.0.4293906 rc1
CMake version: 3.6.4111459