KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.36k stars 648 forks source link

Android Sample App Build Failure #1157

Closed a-u-93 closed 2 months ago

a-u-93 commented 2 months ago

Hello!

Please, suggest a solution to build and deploy sample app for Android.

Debian 12, Vulkan SDK installed and configured in PATH (unnecessary here, as I understand).

I have tried to build both in Android Studio (python script generates gradle project) and via system-level gradle manually.

I have launched gradle config suggested by A. Studio config migration tool.

Manual gradle invocation:

workloadhost gradle assembleRelease
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :app
WARNING: The option setting 'android.defaults.buildfeatures.buildconfig=true' is deprecated.
The current default is 'false'.
It will be removed in version 9.0 of the Android Gradle plugin.
To keep using this feature, add the following to your module-level build.gradle files:
    android.buildFeatures.buildConfig = true
or from Android Studio, click: `Refactor` > `Migrate BuildConfig to Gradle Build Files`.
WARNING: The option setting 'android.prefabVersion=2.0.0' is experimental.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > Could not create an instance of type com.android.build.api.variant.impl.ApplicationVariantImpl.
      > Namespace not specified. Specify a namespace in the module's build file: /home/alexander/Desktop/Vulkan-Samples/build/android_gradle/app/build.gradle. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

        If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.
   > Task with name 'mergeReleaseJniLibFolders' not found in project ':app'.

* 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.

BUILD FAILED in 1m 24s

Android studio:

Executing tasks: [:app:assembleDebugUnitTest, :app:assembleDebugAndroidTest, :app:assembleDebug] in project /home/alexander/Desktop/Vulkan-Samples/build/android_gradle

> Configure project :app
AGPBI: {"kind":"warning","text":"The option setting 'android.defaults.buildfeatures.buildconfig=true' is deprecated.\nThe current default is 'false'.\nIt will be removed in version 9.0 of the Android Gradle plugin.\nTo keep using this feature, add the following to your module-level build.gradle files:\n    android.buildFeatures.buildConfig = true\nor from Android Studio, click: `Refactor` > `Migrate BuildConfig to Gradle Build Files`.","sources":[{}]}
AGPBI: {"kind":"warning","text":"The option setting 'android.prefabVersion=2.0.0' is experimental.","sources":[{}]}

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > Could not create an instance of type com.android.build.api.variant.impl.ApplicationVariantImpl.
      > Namespace not specified. Specify a namespace in the module's build file: /home/alexander/Desktop/Vulkan-Samples/build/android_gradle/app/build.gradle. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

        If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.
   > Task with name 'mergeReleaseJniLibFolders' not found in project ':app'.

* 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.

BUILD FAILED in 8s

Assets - I did not copy it manually from your external directory, as some manuals suggests.

SaschaWillems commented 2 months ago

What version of the Android Studio, NDK and gradle are you using? This looks like they're too new and we would have to adjust our build files.

a-u-93 commented 2 months ago

@SaschaWillems, hello and thank you for your reply!

I will try to reproduce bug from the scratch.

git clone --recursive https://github.com/KhronosGroup/Vulkan-Samples.git --depth=1
cd Vulkan-Samples
python3 scripts/generate.py android
studio.sh

while processing project by A/Studio, I got a message

Undefined java.home on the project gradle/config.properties file when using the gradleJvm #GRADLE_LOCAL_JAVA_HOME macro. To mitigate the issue, this was changed to use the Embedded JDK (JetBrains Runtime 17.0.11). Select the Gradle JDK location
vulkan_samples.app.main | debug | arm64-v8a Compiler exited with error code 1: /home/alexander/.bin/android_sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -xc++ --target=aarch64-none-linux-android30 --sysroot=/home/alexander/.bin/android_sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/sysroot -DENABLE_HLSL -DENABLE_OPT=0 -DGLSLANG_OSINCLUDE_UNIX -DROOT_PATH_SIZE=39 -DVKB_DEBUG
Android Gradle plugin version 7.4.2 has an upgrade available. Start the AGP Upgrade Assistant to update this project's AGP version.

In my user shell config, BTW, all is ok, I hope (user-level settings are irrelevant here?)

export ANDROID_HOME="$HOME/.bin/android_sdk"                                    
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/27.1.12297006"                       
export PATH="$ANDROID_HOME/cmake/3.22.1/bin:$PATH"                              

export VULKAN_SDK="$HOME/.bin/vulkan_sdk/x86_64"                                
export PATH=$VULKAN_SDK/bin:$PATH                                               
export LD_LIBRARY_PATH=$VULKAN_SDK/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}     
export VK_LAYER_PATH=$VULKAN_SDK/share/vulkan/explicit_layer.d
SaschaWillems commented 2 months ago

So what Android Studio version are you using? The one from our build docs or something newer?

a-u-93 commented 2 months ago

The latest one

On Tue, Sep 10, 2024, 20:06 Sascha Willems @.***> wrote:

So what Android Studio version are you using? The one from our build docs or something newer?

— Reply to this email directly, view it on GitHub https://github.com/KhronosGroup/Vulkan-Samples/issues/1157#issuecomment-2341505031, or unsubscribe https://github.com/notifications/unsubscribe-auth/BJSJBQ63RBHKUDSHW7V7CX3ZV4RINAVCNFSM6AAAAABN5AL7VKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBRGUYDKMBTGE . You are receiving this because you authored the thread.Message ID: @.***>

SaschaWillems commented 2 months ago

And what version is that? And is it newer than what we have in our build instructions?

a-u-93 commented 2 months ago

@SaschaWillems

Android Studio Koala Feature Drop | 2024.1.2
Build #AI-241.18034.62.2412.12266719, built on August 23, 2024
Runtime version: 17.0.11+0-17.0.11b1207.24-11852314 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 6.10.6+bpo-amd64
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 2
Registry:
  ide.experimental.ui=true
Current Desktop: Undefined
plugins {
    id 'com.android.application'
}

ext.vvl_version='1.3.275.0'
apply from: "./download_vvl.gradle"

android {
    compileSdk 33
    buildToolsVersion "33.0.0"
    ndkVersion "25.2.9519653"

    defaultConfig {
        applicationId "com.khronos.vulkan_samples"
        minSdk 30
        targetSdk 33
        versionCode 1
        versionName "1.0"

        externalNativeBuild {
            cmake {
                abiFilters.addAll( 'arm64-v8a' )
                arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_static', '-DVKB_VALIDATION_LAYERS=OFF'
            }
        }
    }

    buildTypes {
        debug {
            debuggable true
            jniDebuggable true
        }

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
            signingConfig debug.signingConfig
        }
        applicationVariants.all{variant ->
            variant.outputs.each{output->
                def tempName = output.outputFile.name
                tempName = tempName.replace("app-", "vulkan_samples-")
                output.outputFileName  = tempName
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    sourceSets {
        main {

            res.srcDirs += [ '../../../app/android/res' ]
            java.srcDirs += [ '../../../app/android/java' ]

            manifest.srcFile '../../../app/android/AndroidManifest.xml'
        }
    }

    externalNativeBuild {
        cmake {
            version "3.22.1"
            path '../../../CMakeLists.txt'
            buildStagingDirectory 'build-native'
        }
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    buildFeatures {
        viewBinding true
        prefab true
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.core:core:1.9.0'
    implementation 'androidx.games:games-activity:2.0.0'
}