Skip to content

App Crashes When Opening #66

Description

@Haruki-Hotarou-2021

I am compiling in a mobile IDE based on "AndroidIDE" called "Android Code Studio".

Since it is an Android environment, there is the limitation of using only the NDK and CMake provided by the IDE.

When trying to compile the project with NDK r29 (29.0.14206865) and CMake 4.1.2, the app compiles correctly (with some warnings in the console) and installs correctly on my device (Android 14, API 34, arm64-v8a), but when I open the app, it closes almost instantly.

Below is the console output during compilation:

Executar tarefas : [:app:assembleDebug]

> Configure project :app

> Task :app:preBuild
> Task :app:preDebugBuild
> Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
> Task :app:dataBindingMergeDependencyArtifactsDebug
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:mergeDebugResources
> Task :app:packageDebugResources
> Task :app:generateDebugBuildConfig
> Task :app:javaPreCompileDebug
> Task :app:parseDebugLocalResources
> Task :app:checkDebugAarMetadata
> Task :app:dataBindingGenBaseClassesDebug
> Task :app:mapDebugSourceSetPaths
> Task :app:createDebugCompatibleScreenManifests
> Task :app:extractDeepLinksDebug
> Task :app:processDebugMainManifest
> Task :app:processDebugManifest
> Task :app:mergeDebugShaders
> Task :app:compileDebugShaders NO-SOURCE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets
> Task :app:compressDebugAssets
> Task :app:processDebugManifestForPackage
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:checkDebugDuplicateClasses
> Task :app:mergeDebugJavaResource

> Task :app:configureCMakeDebug[arm64-v8a]
[CXX5304] Observed package id 'tools' in inconsistent location '/data/user/0/com.tom.rv2ide/files/home/android-sdk/cmdline-tools/latest' (Expected '/data/user/0/com.tom.rv2ide/files/home/android-sdk/tools')
[CXX5304] Observed package id 'tools' in inconsistent location '/data/user/0/com.tom.rv2ide/files/home/android-sdk/cmdline-tools/latest' (Expected '/data/user/0/com.tom.rv2ide/files/home/android-sdk/tools')

> Task :app:processDebugResources
> Task :app:desugarDebugFileDependencies

> Task :app:configureCMakeDebug[arm64-v8a]
C/C++: CMake Warning:
C/C++:   Manually-specified variables were not used by the project:
C/C++:     GL_VERSION

> Task :app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :app:dexBuilderDebug
> Task :app:mergeDebugGlobalSynthetics
> Task :app:mergeLibDexDebug
> Task :app:mergeExtDexDebug
> Task :app:mergeProjectDexDebug
> Task :app:l8DexDesugarLibDebug

> Task :app:buildCMakeDebug[arm64-v8a]
C/C++: ninja: Entering directory `/storage/emulated/0/AndroidIDEProjects/raymob/app/.cxx/Debug/65264s60/arm64-v8a'
C/C++: In file included from /storage/emulated/0/AndroidIDEProjects/raymob/app/src/main/cpp/deps/raylib/src/raudio.c:218:
C/C++: /storage/emulated/0/AndroidIDEProjects/raymob/app/src/main/cpp/deps/raylib/src/external/stb_vorbis.c:1404:75: warning: pointer comparison always evaluates to false [-Wtautological-compare]
C/C++:  1404 |       if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) {
C/C++:       |                                                                           ^
C/C++: 1 warning generated.

> Task :app:configureCMakeDebug[armeabi-v7a]
C/C++: CMake Warning:
C/C++:   Manually-specified variables were not used by the project:
C/C++:     GL_VERSION

> Task :app:buildCMakeDebug[armeabi-v7a]
C/C++: ninja: Entering directory `/storage/emulated/0/AndroidIDEProjects/raymob/app/.cxx/Debug/65264s60/armeabi-v7a'
C/C++: In file included from /storage/emulated/0/AndroidIDEProjects/raymob/app/src/main/cpp/deps/raylib/src/raudio.c:218:
C/C++: /storage/emulated/0/AndroidIDEProjects/raymob/app/src/main/cpp/deps/raylib/src/external/stb_vorbis.c:1404:75: warning: pointer comparison always evaluates to false [-Wtautological-compare]
C/C++:  1404 |       if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) {
C/C++:       |                                                                           ^
C/C++: 1 warning generated.

> Task :app:configureCMakeDebug[x86]
C/C++: CMake Warning:
C/C++:   Manually-specified variables were not used by the project:
C/C++:     GL_VERSION

> Task :app:buildCMakeDebug[x86]
C/C++: ninja: Entering directory `/storage/emulated/0/AndroidIDEProjects/raymob/app/.cxx/Debug/65264s60/x86'
C/C++: In file included from /storage/emulated/0/AndroidIDEProjects/raymob/app/src/main/cpp/deps/raylib/src/raudio.c:218:
C/C++: /storage/emulated/0/AndroidIDEProjects/raymob/app/src/main/cpp/deps/raylib/src/external/stb_vorbis.c:1404:75: warning: pointer comparison always evaluates to false [-Wtautological-compare]
C/C++:  1404 |       if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) {
C/C++:       |                                                                           ^
C/C++: 1 warning generated.

> Task :app:configureCMakeDebug[x86_64]
C/C++: CMake Warning:
C/C++:   Manually-specified variables were not used by the project:
C/C++:     GL_VERSION

> Task :app:buildCMakeDebug[x86_64]
C/C++: ninja: Entering directory `/storage/emulated/0/AndroidIDEProjects/raymob/app/.cxx/Debug/65264s60/x86_64'
C/C++: In file included from /storage/emulated/0/AndroidIDEProjects/raymob/app/src/main/cpp/deps/raylib/src/raudio.c:218:
C/C++: /storage/emulated/0/AndroidIDEProjects/raymob/app/src/main/cpp/deps/raylib/src/external/stb_vorbis.c:1404:75: warning: pointer comparison always evaluates to false [-Wtautological-compare]
C/C++:  1404 |       if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) {
C/C++:       |                                                                           ^
C/C++: 1 warning generated.

> Task :app:mergeDebugJniLibFolders
> Task :app:mergeDebugNativeLibs
> Task :app:validateSigningDebug
> Task :app:writeDebugAppMetadata
> Task :app:writeDebugSigningConfigVersions
> Task :app:stripDebugDebugSymbols
> Task :app:packageDebug
> Task :app:createDebugApkListingFileRedirect
> Task :app:assembleDebug
[Incubating] Problems report is available at: file:///storage/emulated/0/AndroidIDEProjects/raymob/build/reports/problems/problems-report.html

BUILD SUCCESSFUL in 1m 42s
47 actionable tasks: 47 executed

The only changes I made to the project were changing the NDK to r29, changing CMake to 4.1.2, and changing the Java Version to 17 in the "app/build.gradle":

plugins {
    id 'com.android.application'
}

def updateFile(filePath, toReplace, replacement) {
    def file = file(filePath)
    def modifiedContent = file.text.replaceAll(toReplace, replacement)
    file.write(modifiedContent)
}

def isAtLeastOnePropertyTrueForPrefix(String prefix) {
    def properties = project.properties
    return properties.any { key, value ->
        key.startsWith(prefix) && value == 'true'
    }
}

static def getGLVersionCode(String version) {
    def versionCodes = [
            'ES20': '0x00020000',
            'ES30': '0x00030000',
            'ES31': '0x00030001',
            'ES32': '0x00030002'
    ]
    if (!versionCodes.containsKey(version)) {
        throw new IllegalArgumentException("Version '${version}' is not valid. Valid versions are: ${versionCodes.keySet()}")
    }
    return versionCodes[version]
}

android {
    namespace project.properties['app.application_id']
    compileSdk 34
    ndkVersion "29.0.14206865"  // Changed the NDK to r29

    defaultConfig {
        minSdk 24
        targetSdk 34

        applicationId project.properties['app.application_id']
        versionCode Integer.parseInt(project.properties['app.version_code'])
        versionName project.properties['app.version_name']

        resValue "string", "app_name", project.properties['app.name']

        buildConfigField("boolean", "FEATURE_DISPLAY_KEEP_ON", project.properties['display.keep_on'] ?: "false")
        buildConfigField("boolean", "FEATURE_DISPLAY_IMMERSIVE", project.properties['display.immersive'] ?: "false")
        buildConfigField("boolean", "FEATURE_DISPLAY_INTO_CUTOUT", project.properties['display.into_cutout'] ?: "false")

        manifestPlaceholders = [
            'GL_VERSION_CODE': getGLVersionCode(project.properties['gl.version']) ?: "0x00020000",
            'APP_LIB_NAME': project.properties['app.native_library_name'] ?: "raymob",
            'APP_ORIENTATION': project.properties['app.orientation'] ?: "landscape",
            'APP_CATEGORY': project.properties['app.category'] ?: "DEFAULT",
            'REQUIRE_INTERNET': project.properties['requirements.internet'] ?: "false",
            'REQUIRE_VIBRATION': project.properties['requirements.vibration'] ?: "false",
            'REQUIRE_GYROSCOPE': project.properties['requirements.gyroscope'] ?: "false",
            'REQUIRE_ACCELEROMETER': project.properties['requirements.accelerometer'] ?: "false"
        ]

        externalNativeBuild {
            cmake {
                def nativeLibName = project.findProperty('app.native_library_name') ?: 'raymob'
                def glVersion = project.findProperty('gl.version') ?: 'ES20'

                arguments "-DPLATFORM=Android",
                          "-DBUILD_EXAMPLES=OFF",
                          "-DAPP_LIB_NAME=$nativeLibName",
                          "-DGL_VERSION=$glVersion"
            }
        }

        applicationVariants.all { variant ->
            variant.outputs.all {
                outputFileName = outputFileName.replace("com.raylib.raymob", project.properties['app.application_id'])
                outputFileName = outputFileName.replace("raymob", project.properties['app.native_library_name'])
            }
        }

    }

    preBuild.doLast {

        updateFile("src/main/java/com/raylib/raymob/NativeLoader.java", "package com.raylib.raymob;", "package " + project.properties['app.application_id'] + ";")
        updateFile("src/main/java/com/raylib/raymob/NativeLoader.java", "System.loadLibrary\\(\"raymob\"\\);", "System.loadLibrary\\(\"" + project.properties['app.native_library_name'] + "\"\\);")

        updateFile("src/main/java/com/raylib/raymob/DisplayManager.java", "package com.raylib.raymob;", "package " + project.properties['app.application_id'] + ";")
        updateFile("src/main/java/com/raylib/raymob/SoftKeyboard.java", "package com.raylib.raymob;", "package " + project.properties['app.application_id'] + ";")

        updateFile("proguard-rules.pro", "com.raylib.raymob", project.properties['app.application_id'])

        updateFile("src/main/cpp/deps/raymob/display.c", "com/raylib/raymob", project.properties['app.application_id'].replace(".", "/"))
        updateFile("src/main/cpp/deps/raymob/soft_keyboard.c", "com/raylib/raymob", project.properties['app.application_id'].replace(".", "/"))

    }

    gradle.buildFinished {

        updateFile("src/main/java/com/raylib/raymob/NativeLoader.java", "package " + project.properties['app.application_id'] + ";", "package com.raylib.raymob;")
        updateFile("src/main/java/com/raylib/raymob/NativeLoader.java", "System.loadLibrary\\(\"" + project.properties['app.native_library_name'] + "\"\\);", "System.loadLibrary\\(\"raymob\"\\);")

        updateFile("src/main/java/com/raylib/raymob/DisplayManager.java", "package " + project.properties['app.application_id'] + ";", "package com.raylib.raymob;")
        updateFile("src/main/java/com/raylib/raymob/SoftKeyboard.java", "package " + project.properties['app.application_id'] + ";", "package com.raylib.raymob;")

        updateFile("proguard-rules.pro", project.properties['app.application_id'], "com.raylib.raymob")

        updateFile("src/main/cpp/deps/raymob/display.c", project.properties['app.application_id'].replace(".", "/"), "com/raylib/raymob")
        updateFile("src/main/cpp/deps/raymob/soft_keyboard.c", project.properties['app.application_id'].replace(".", "/"), "com/raylib/raymob")

    }

    buildTypes {
        debug {
            debuggable true
            jniDebuggable true
        }
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

            debuggable false
            jniDebuggable false
            pseudoLocalesEnabled false
            zipAlignEnabled true
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17  // Changed the Java Version to 17
        targetCompatibility JavaVersion.VERSION_17  // Changed the Java Version to 17
    }
    externalNativeBuild {
        cmake {
            path file('src/main/cpp/CMakeLists.txt')
            version '4.1.2'  // Changed the CMake to 4.1.2
        }
    }
    buildFeatures {
        buildConfig true
        viewBinding true
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions