xmake-io / xmake-gradle

A gradle plugin that integrates xmake seamlessly
https://xmake.io
Apache License 2.0
46 stars 2 forks source link

When reinstalling, xmake rebuilds executable but it's not packaged #10

Open SirLynix opened 1 year ago

SirLynix commented 1 year ago

Xmake Version

2.7.6

Operating System Version and Architecture

Windows 11

Describe Bug

When running gradlew installDebug after a C++ change, xmake recompiles the .so binary but it doesn't get packaged, so the .apk contains the old code.

C:\Projets\Perso\NazaraNext\NazaraEngine\android>gradlew installDebug
Adding project android_test

> Configure project :android_test
[xmake/plugin]: activated for project: android_test

> Task :android_test:xmakeConfigureForArm64
>> xmake f -c -y -p android -a arm64-v8a -m debug --assimp=n --embed_rendererbackends=y --embed_plugins=y --link_openal=y --ndk=E:\Android\Sdk\ndk\23.1.7779620 --ndk_sdkver=28 --buildir=C:\Projets\Perso\NazaraNext\NazaraEngine\android\examples\android_test\build\xmake
checking for Android SDK directory ... no
checking for NDK directory ... E:\Android\Sdk\ndk\23.1.7779620
checking for SDK version of NDK ... 28
warning: You are working in the project directory(C:\Projets\Perso\NazaraNext\NazaraEngine) and you can also
force to build in current directory via run `xmake -P .`

> Task :android_test:xmakeBuildForArm64
>> xmake build AndroidApp
[100%]: build ok!
warning: You are working in the project directory(C:\Projets\Perso\NazaraNext\NazaraEngine) and you can also
force to build in current directory via run `xmake -P .`

> Task :android_test:xmakeConfigureForArmv7
>> xmake f -c -y -p android -a armeabi-v7a -m debug --assimp=n --embed_rendererbackends=y --embed_plugins=y --link_openal=y --ndk=E:\Android\Sdk\ndk\23.1.7779620 --ndk_sdkver=28 --buildir=C:\Projets\Perso\NazaraNext\NazaraEngine\android\examples\android_test\build\xmake
checking for Android SDK directory ... no
checking for NDK directory ... E:\Android\Sdk\ndk\23.1.7779620
checking for SDK version of NDK ... 28
warning: You are working in the project directory(C:\Projets\Perso\NazaraNext\NazaraEngine) and you can also
force to build in current directory via run `xmake -P .`

> Task :android_test:xmakeBuildForArmv7
>> xmake build AndroidApp
[100%]: build ok!
warning: You are working in the project directory(C:\Projets\Perso\NazaraNext\NazaraEngine) and you can also
force to build in current directory via run `xmake -P .`

> Task :android_test:xmakeInstall
>> install artifacts to C:\Projets\Perso\NazaraNext\NazaraEngine\android\examples\android_test\libs

> Task :android_test:installDebug
Installing APK 'android_test-debug.apk' on 'emulator-5554 - 9' for :android_test:debug
Installed on 1 device.

BUILD SUCCESSFUL in 8s
40 actionable tasks: 7 executed, 33 up-to-date

with more logs:

> Task :android_test:packageDebug UP-TO-DATE
Caching disabled for task ':android_test:packageDebug' because:
  Build cache is disabled
Skipping task ':android_test:packageDebug' as it is up-to-date.
:android_test:packageDebug (Thread[Execution worker Thread 4,5,main]) completed. Took 0.002 secs.
Resolve mutations for :android_test:createDebugApkListingFileRedirect (Thread[Execution worker Thread 18,5,main]) started.
Resolve mutations for :android_test:createDebugApkListingFileRedirect (Thread[Execution worker Thread 18,5,main]) completed. Took 0.0 secs.
:android_test:createDebugApkListingFileRedirect (Thread[Execution worker Thread 13,5,main]) started.
producer locations for task group 0 (Thread[Execution worker Thread 18,5,main]) started.
producer locations for task group 0 (Thread[Execution worker Thread 18,5,main]) completed. Took 0.0 secs.

Expected Behavior

That it assembles/packages everytime xmake produces a new build to update the .apk

Project Configuration

Here's my build.gradle:


plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'org.tboox.gradle-xmake-plugin' version '1.1.6'
}

android {
    namespace 'com.sirlynix.nazaraExample.androidTest'
    compileSdk 31

    defaultConfig {
        applicationId 'com.sirlynix.nazaraExample.androidTest'
        minSdk 28
        targetSdk 31
        versionCode 1
        versionName '1.0'

        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
        externalNativeBuild {
            xmake {
                sdkver 28
                path 'src/main/cpp/xmake.lua'

                arguments '--assimp=n', '--embed_rendererbackends=y', '--embed_plugins=y', '--link_openal=y'

                buildMode 'debug'

                abiFilters 'armeabi-v7a', 'arm64-v8a'

                targets 'AndroidApp'
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

task copyTask {
    copy {
        from '../../assets'
        into 'src/main/res/drawable'
        include 'icon.png'
    }
}```

### Additional Information and Error Logs

_No response_
waruqi commented 1 year ago

assembleDebug needs to be called, but installDebug does not call it. This should not be something that the xmake plugin does.

SirLynix commented 1 year ago

This is weird, because if I gradlew --info installDebug --rerun-tasks to force rerun (or gradlew clean beforehand) then everything works.

If I change a log in my C++ file, then run gradlew --info installDebug --rerun-tasks then run the .apk in my emulator the log is up to date

SirLynix commented 1 year ago

Full log: build_log.txt

SirLynix commented 1 year ago

assembleDebug can't be executed:

> Task :android_test:assembleDebug UP-TO-DATE
Skipping task ':android_test:assembleDebug' as it has no actions.
waruqi commented 1 year ago

assembleDebug can't be executed:

> Task :android_test:assembleDebug UP-TO-DATE
Skipping task ':android_test:assembleDebug' as it has no actions.

just java files are changed, it will be run.

SirLynix commented 1 year ago

My Java class only loads library, everything my app does is in the .so.

I don't know which task copies the .so to the .apk but this one needs to be run after xmake installed to make it up to date.

waruqi commented 1 year ago

My Java class only loads library, everything my app does is in the .so.

I don't know which task copies the .so to the .apk but this one needs to be run after xmake installed to make it up to date.

assembleDebug will generate apk, so it need be rerun

SirLynix commented 1 year ago

assembleDebug does nothing in my case, even if I execute it with --rerun-tasks. Cleaning the whole project and then running gradlew installDebug generates a .apk in build/outputs/apk/debug, but I don't know how to get better logs to know which task creates it.