Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hello-libs native dependency not respected? #961

Open
reddwarf69 opened this issue Oct 6, 2023 · 0 comments
Open

hello-libs native dependency not respected? #961

reddwarf69 opened this issue Oct 6, 2023 · 0 comments

Comments

@reddwarf69
Copy link

reddwarf69 commented Oct 6, 2023

If I run this

$ git clone [email protected]:android/ndk-samples.git
Cloning into 'ndk-samples'...
remote: Enumerating objects: 15876, done.
remote: Counting objects: 100% (265/265), done.
remote: Compressing objects: 100% (141/141), done.
remote: Total 15876 (delta 90), reused 230 (delta 84), pack-reused 15611
Receiving objects: 100% (15876/15876), 51.87 MiB | 4.70 MiB/s, done.
Resolving deltas: 100% (8322/8322), done.
$ cd ndk-samples/hello-libs
$ rm -rf distribution 
$ sed -i "s|// include ':gen-libs'|include ':gen-libs'|" settings.gradle
$ sed -i "s|//    api project(':gen-libs')|    api project(':gen-libs')|" app/build.gradle
$ ./gradlew build

I end up with an error like

> Task :app:buildCMakeDebug[arm64-v8a] FAILED
C/C++: ninja: error: '/ndk-samples/hello-libs/distribution/gmath/lib/arm64-v8a/libgmath.a', needed by '/ndk-samples/hello-libs/app/build/intermediates/cxx/Debug/141w5z33/obj/arm64-v8a/libhello-libs.so', missing and no known rule to make it

Since the cmake build in gen-libs doesn't run before the one in app, despite the dependency being specified.

When running with --info, I can see

Selected primary task 'build' from project :
Tasks to be executed: [task ':app:preBuild', task ':app:preDebugBuild', task ':app:mergeDebugNativeDebugMetadata', task ':app:compileDebugAidl', task ':app:compileDebugRenderscript', task ':app:generateDebugBuildConfig', task ':app:javaPreCompileDebug', task ':app:checkDebugAarMetadata', task ':app:generateDebugResValues', task ':app:mapDebugSourceSetPaths', task ':app:generateDebugResources', task ':app:mergeDebugResources', task ':app:createDebugCompatibleScreenManifests', task ':app:extractDeepLinksDebug', task ':gen-libs:preBuild', task ':gen-libs:preDebugBuild', task ':gen-libs:compileDebugRenderscript', task ':gen-libs:generateDebugResValues', task ':gen-libs:extractDeepLinksDebug', task ':app:processDebugMainManifest', task ':app:processDebugManifest', task ':app:processDebugManifestForPackage', task ':gen-libs:checkDebugAarMetadata', task ':gen-libs:mapDebugSourceSetPaths', task ':gen-libs:generateDebugResources', task ':gen-libs:mergeDebugResources', task ':gen-libs:createDebugCompatibleScreenManifests', task ':gen-libs:processDebugMainManifest', task ':gen-libs:processDebugManifest', task ':gen-libs:processDebugManifestForPackage', task ':gen-libs:processDebugResources', task ':app:processDebugResources', task ':gen-libs:compileDebugAidl', task ':gen-libs:generateDebugBuildConfig', task ':gen-libs:javaPreCompileDebug', task ':gen-libs:compileDebugJavaWithJavac', task ':gen-libs:bundleDebugClassesToCompileJar', task ':app:compileDebugJavaWithJavac', task ':app:mergeDebugShaders', task ':app:compileDebugShaders', task ':app:generateDebugAssets', task ':app:mergeDebugAssets', task ':app:compressDebugAssets', task ':app:processDebugJavaRes', task ':gen-libs:processDebugJavaRes', task ':app:mergeDebugJavaResource', task ':gen-libs:bundleDebugClassesToRuntimeJar', task ':app:checkDebugDuplicateClasses', task ':app:dexBuilderDebug', task ':app:desugarDebugFileDependencies', task ':app:mergeExtDexDebug', task ':app:mergeDexDebug', task ':app:configureCMakeDebug[arm64-v8a]', task ':app:buildCMakeDebug[arm64-v8a]', task ':app:configureCMakeDebug[armeabi-v7a]', task ':app:buildCMakeDebug[armeabi-v7a]', task ':app:configureCMakeDebug[x86]', task ':app:buildCMakeDebug[x86]', task ':app:configureCMakeDebug[x86_64]', task ':app:buildCMakeDebug[x86_64]', task ':app:externalNativeBuildDebug', task ':app:mergeDebugJniLibFolders', task ':app:mergeDebugNativeLibs', task ':app:stripDebugDebugSymbols', task ':app:validateSigningDebug', task ':app:writeDebugAppMetadata', task ':app:writeDebugSigningConfigVersions', task ':app:packageDebug', task ':app:createDebugApkListingFileRedirect', task ':app:assembleDebug', task ':app:preReleaseBuild', task ':app:compileReleaseAidl', task ':app:compileReleaseRenderscript', task ':app:generateReleaseBuildConfig', task ':app:javaPreCompileRelease', task ':app:checkReleaseAarMetadata', task ':app:generateReleaseResValues', task ':app:mapReleaseSourceSetPaths', task ':app:generateReleaseResources', task ':app:mergeReleaseResources', task ':app:createReleaseCompatibleScreenManifests', task ':app:extractDeepLinksRelease', task ':gen-libs:preReleaseBuild', task ':gen-libs:compileReleaseRenderscript', task ':gen-libs:generateReleaseResValues', task ':gen-libs:extractDeepLinksRelease', task ':app:processReleaseMainManifest', task ':app:processReleaseManifest', task ':app:processReleaseManifestForPackage', task ':gen-libs:checkReleaseAarMetadata', task ':gen-libs:mapReleaseSourceSetPaths', task ':gen-libs:generateReleaseResources', task ':gen-libs:mergeReleaseResources', task ':gen-libs:createReleaseCompatibleScreenManifests', task ':gen-libs:processReleaseMainManifest', task ':gen-libs:processReleaseManifest', task ':gen-libs:processReleaseManifestForPackage', task ':gen-libs:processReleaseResources', task ':app:processReleaseResources', task ':gen-libs:compileReleaseAidl', task ':gen-libs:generateReleaseBuildConfig', task ':gen-libs:javaPreCompileRelease', task ':gen-libs:compileReleaseJavaWithJavac', task ':gen-libs:bundleReleaseClassesToCompileJar', task ':app:compileReleaseJavaWithJavac', task ':app:extractProguardFiles', task ':app:lintVitalAnalyzeRelease', task ':app:lintVitalReportRelease', task ':app:lintVitalRelease', task ':app:configureCMakeRelWithDebInfo[arm64-v8a]', task ':app:buildCMakeRelWithDebInfo[arm64-v8a]', task ':app:configureCMakeRelWithDebInfo[armeabi-v7a]', task ':app:buildCMakeRelWithDebInfo[armeabi-v7a]', task ':app:configureCMakeRelWithDebInfo[x86]', task ':app:buildCMakeRelWithDebInfo[x86]', task ':app:configureCMakeRelWithDebInfo[x86_64]', task ':app:buildCMakeRelWithDebInfo[x86_64]', task ':app:externalNativeBuildRelease', task ':app:mergeReleaseJniLibFolders', task ':app:mergeReleaseNativeLibs', task ':app:stripReleaseDebugSymbols', task ':app:extractReleaseNativeSymbolTables', task ':app:mergeReleaseNativeDebugMetadata', task ':gen-libs:bundleReleaseClassesToRuntimeJar', task ':app:checkReleaseDuplicateClasses', task ':app:dexBuilderRelease', task ':app:desugarReleaseFileDependencies', task ':app:mergeExtDexRelease', task ':app:mergeDexRelease', task ':app:mergeReleaseArtProfile', task ':app:compileReleaseArtProfile', task ':app:mergeReleaseShaders', task ':app:compileReleaseShaders', task ':app:generateReleaseAssets', task ':app:mergeReleaseAssets', task ':app:compressReleaseAssets', task ':app:processReleaseJavaRes', task ':gen-libs:processReleaseJavaRes', task ':app:mergeReleaseJavaResource', task ':app:optimizeReleaseResources', task ':app:collectReleaseDependencies', task ':app:sdkReleaseDependencyData', task ':app:writeReleaseAppMetadata', task ':app:writeReleaseSigningConfigVersions', task ':app:packageRelease', task ':app:createReleaseApkListingFileRedirect', task ':app:assembleRelease', task ':app:assemble', task ':app:bundleDebugClassesToCompileJar', task ':app:preDebugAndroidTestBuild', task ':app:processDebugAndroidTestManifest', task ':app:compileDebugAndroidTestRenderscript', task ':app:generateDebugAndroidTestResValues', task ':app:lintAnalyzeDebug', task ':app:lintReportDebug', task ':app:lintDebug', task ':app:lint', task ':app:bundleDebugClassesToRuntimeJar', task ':app:preDebugUnitTestBuild', task ':app:javaPreCompileDebugUnitTest', task ':app:compileDebugUnitTestJavaWithJavac', task ':app:processDebugUnitTestJavaRes', task ':app:testDebugUnitTest', task ':app:bundleReleaseClassesToRuntimeJar', task ':app:bundleReleaseClassesToCompileJar', task ':app:preReleaseUnitTestBuild', task ':app:javaPreCompileReleaseUnitTest', task ':app:compileReleaseUnitTestJavaWithJavac', task ':app:processReleaseUnitTestJavaRes', task ':app:testReleaseUnitTest', task ':app:test', task ':app:check', task ':app:build', task ':gen-libs:mergeDebugNativeDebugMetadata', task ':gen-libs:mergeDebugShaders', task ':gen-libs:compileDebugShaders', task ':gen-libs:generateDebugAssets', task ':gen-libs:mergeDebugAssets', task ':gen-libs:compressDebugAssets', task ':gen-libs:mergeDebugJavaResource', task ':gen-libs:checkDebugDuplicateClasses', task ':gen-libs:dexBuilderDebug', task ':gen-libs:desugarDebugFileDependencies', task ':gen-libs:mergeExtDexDebug', task ':gen-libs:mergeDexDebug', task ':gen-libs:configureCMakeDebug[arm64-v8a]', task ':gen-libs:buildCMakeDebug[arm64-v8a][gmath,gperf]', task ':gen-libs:configureCMakeDebug[armeabi-v7a]', task ':gen-libs:buildCMakeDebug[armeabi-v7a][gmath,gperf]', task ':gen-libs:configureCMakeDebug[x86]', task ':gen-libs:buildCMakeDebug[x86][gmath,gperf]', task ':gen-libs:configureCMakeDebug[x86_64]', task ':gen-libs:buildCMakeDebug[x86_64][gmath,gperf]', task ':gen-libs:externalNativeBuildDebug', task ':gen-libs:mergeDebugJniLibFolders', task ':gen-libs:mergeDebugNativeLibs', task ':gen-libs:stripDebugDebugSymbols', task ':gen-libs:validateSigningDebug', task ':gen-libs:writeDebugAppMetadata', task ':gen-libs:writeDebugSigningConfigVersions', task ':gen-libs:packageDebug', task ':gen-libs:createDebugApkListingFileRedirect', task ':gen-libs:assembleDebug', task ':gen-libs:extractProguardFiles', task ':gen-libs:lintVitalAnalyzeRelease', task ':gen-libs:lintVitalReportRelease', task ':gen-libs:lintVitalRelease', task ':gen-libs:configureCMakeRelWithDebInfo[arm64-v8a]', task ':gen-libs:buildCMakeRelWithDebInfo[arm64-v8a][gmath,gperf]', task ':gen-libs:configureCMakeRelWithDebInfo[armeabi-v7a]', task ':gen-libs:buildCMakeRelWithDebInfo[armeabi-v7a][gmath,gperf]', task ':gen-libs:configureCMakeRelWithDebInfo[x86]', task ':gen-libs:buildCMakeRelWithDebInfo[x86][gmath,gperf]', task ':gen-libs:configureCMakeRelWithDebInfo[x86_64]', task ':gen-libs:buildCMakeRelWithDebInfo[x86_64][gmath,gperf]', task ':gen-libs:externalNativeBuildRelease', task ':gen-libs:mergeReleaseJniLibFolders', task ':gen-libs:mergeReleaseNativeLibs', task ':gen-libs:stripReleaseDebugSymbols', task ':gen-libs:extractReleaseNativeSymbolTables', task ':gen-libs:mergeReleaseNativeDebugMetadata', task ':gen-libs:checkReleaseDuplicateClasses', task ':gen-libs:dexBuilderRelease', task ':gen-libs:desugarReleaseFileDependencies', task ':gen-libs:mergeExtDexRelease', task ':gen-libs:mergeDexRelease', task ':gen-libs:mergeReleaseArtProfile', task ':gen-libs:compileReleaseArtProfile', task ':gen-libs:mergeReleaseShaders', task ':gen-libs:compileReleaseShaders', task ':gen-libs:generateReleaseAssets', task ':gen-libs:mergeReleaseAssets', task ':gen-libs:compressReleaseAssets', task ':gen-libs:mergeReleaseJavaResource', task ':gen-libs:optimizeReleaseResources', task ':gen-libs:collectReleaseDependencies', task ':gen-libs:sdkReleaseDependencyData', task ':gen-libs:writeReleaseAppMetadata', task ':gen-libs:writeReleaseSigningConfigVersions', task ':gen-libs:packageRelease', task ':gen-libs:createReleaseApkListingFileRedirect', task ':gen-libs:assembleRelease', task ':gen-libs:assemble', task ':gen-libs:preDebugAndroidTestBuild', task ':gen-libs:processDebugAndroidTestManifest', task ':gen-libs:compileDebugAndroidTestRenderscript', task ':gen-libs:generateDebugAndroidTestResValues', task ':gen-libs:lintAnalyzeDebug', task ':gen-libs:lintReportDebug', task ':gen-libs:lintDebug', task ':gen-libs:lint', task ':gen-libs:preDebugUnitTestBuild', task ':gen-libs:javaPreCompileDebugUnitTest', task ':gen-libs:compileDebugUnitTestJavaWithJavac', task ':gen-libs:processDebugUnitTestJavaRes', task ':gen-libs:testDebugUnitTest', task ':gen-libs:preReleaseUnitTestBuild', task ':gen-libs:javaPreCompileReleaseUnitTest', task ':gen-libs:compileReleaseUnitTestJavaWithJavac', task ':gen-libs:processReleaseUnitTestJavaRes', task ':gen-libs:testReleaseUnitTest', task ':gen-libs:test', task ':gen-libs:check', task ':gen-libs:build']
Tasks that were excluded: []

So :gen-libs:buildCMakeDebug[arm64-v8a][gmath gperf] appears after :app:buildCMakeDebug[arm64-v8a].

If I run ./gradlew --info :app:assembleDebug I get

Selected primary task ':app:assembleDebug' from project :app
Tasks to be executed: [task ':app:preBuild', task ':app:preDebugBuild', task ':app:mergeDebugNativeDebugMetadata', task ':app:compileDebugAidl', task ':app:compileDebugRenderscript', task ':app:generateDebugBuildConfig', task ':app:javaPreCompileDebug', task ':app:checkDebugAarMetadata', task ':app:generateDebugResValues', task ':app:mapDebugSourceSetPaths', task ':app:generateDebugResources', task ':app:mergeDebugResources', task ':app:createDebugCompatibleScreenManifests', task ':app:extractDeepLinksDebug', task ':gen-libs:preBuild', task ':gen-libs:preDebugBuild', task ':gen-libs:compileDebugRenderscript', task ':gen-libs:generateDebugResValues', task ':gen-libs:extractDeepLinksDebug', task ':app:processDebugMainManifest', task ':app:processDebugManifest', task ':app:processDebugManifestForPackage', task ':gen-libs:checkDebugAarMetadata', task ':gen-libs:mapDebugSourceSetPaths', task ':gen-libs:generateDebugResources', task ':gen-libs:mergeDebugResources', task ':gen-libs:createDebugCompatibleScreenManifests', task ':gen-libs:processDebugMainManifest', task ':gen-libs:processDebugManifest', task ':gen-libs:processDebugManifestForPackage', task ':gen-libs:processDebugResources', task ':app:processDebugResources', task ':gen-libs:compileDebugAidl', task ':gen-libs:generateDebugBuildConfig', task ':gen-libs:javaPreCompileDebug', task ':gen-libs:compileDebugJavaWithJavac', task ':gen-libs:bundleDebugClassesToCompileJar', task ':app:compileDebugJavaWithJavac', task ':app:mergeDebugShaders', task ':app:compileDebugShaders', task ':app:generateDebugAssets', task ':app:mergeDebugAssets', task ':app:compressDebugAssets', task ':app:processDebugJavaRes', task ':gen-libs:processDebugJavaRes', task ':app:mergeDebugJavaResource', task ':gen-libs:bundleDebugClassesToRuntimeJar', task ':app:checkDebugDuplicateClasses', task ':app:dexBuilderDebug', task ':app:desugarDebugFileDependencies', task ':app:mergeExtDexDebug', task ':app:mergeDexDebug', task ':app:configureCMakeDebug[arm64-v8a]', task ':app:buildCMakeDebug[arm64-v8a]', task ':app:configureCMakeDebug[armeabi-v7a]', task ':app:buildCMakeDebug[armeabi-v7a]', task ':app:configureCMakeDebug[x86]', task ':app:buildCMakeDebug[x86]', task ':app:configureCMakeDebug[x86_64]', task ':app:buildCMakeDebug[x86_64]', task ':app:externalNativeBuildDebug', task ':app:mergeDebugJniLibFolders', task ':app:mergeDebugNativeLibs', task ':app:stripDebugDebugSymbols', task ':app:validateSigningDebug', task ':app:writeDebugAppMetadata', task ':app:writeDebugSigningConfigVersions', task ':app:packageDebug', task ':app:createDebugApkListingFileRedirect', task ':app:assembleDebug']
Tasks that were excluded: []

So, while some :gen-libs tasks are there, the CMake ones are not.

Somehow the

dependencies {
...
    api project(':gen-libs')
}

doesn't seem to apply to the native builds.

Am I misunderstanding how this is supposed to work?
Is this a bug in the Android Gradle Plugin or in the example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant