Search code examples
androidgradlegroovybuild.gradle

Android app failed on Android 11 devices when I build it using release build type. The debug version can be launched without problems


My Android videogame launches on Android devices with Android 8 and Android 10. I have tested my videogame also on my Android tablet with Android 11 and on Poco X4 Pro 5G, Android 11, MIUI 13.0.14. The game falls when I use the signed release build type at the start of the game and works without errors with debug build configuration. I have tried to launch the release configuration direct from Intellij Idea with the connected Android device (Android 11) but I can not see any logs. What can be the trouble on the new Android OS? My Gradle file:

plugins {
    id 'com.android.application'
}

var keystorePropertiesFile = rootProject.file("keystore.properties");
var keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {

    lintOptions {
        checkReleaseBuilds false
    }
    signingConfigs {
        release {
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
        }
    }
    compileSdk 33
    defaultConfig {
        applicationId "com.mgdsstudio.blueberet.mainpackage"
        minSdk 24
        targetSdk 33
        versionCode 1
        multiDexEnabled true
        versionName "2.8"
        project.archivesBaseName = "BlueBeret-" + defaultConfig.versionName;
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    signingConfigs{
        debug {

        }
        unsigned{
            storePassword = ""
            keyAlias = ""
            keyPassword = ""
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {

        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    buildFeatures {
        viewBinding true
    }
    namespace 'com.mgdsstudio.blueberet'
}

dependencies {
    // list of all libraries I use
}

repositories {
    mavenCentral()
}

I have created a new clear project in Android Studio yesterday. I have created all the same activities, copied the buildgradle code, created a simple graphic application using Processing-core.jar library. And the problem is same. I think I need to publish this project on GitHub and open the link here


Solution

  • Stacktrace found the problem. The processing core library throws the exception:

    processing.opengl.PSurfaceGLES that attempts to sub-type erroneous
    class     processing.core.PSurfaceNone (declaration of
    'processing.opengl.PSurfaceGLES'     appears in
    /data/app/~~7Gjjuyxyz-WE0f4-FZ7zjg==/com.mgdsstudio.blueberet.mainpackage-Rj61KCG5iQ2VERlCqPHlkQ==/base.apk!classes3.dex)
    at
    processing.opengl.PGraphicsOpenGL.createSurface(PGraphicsOpenGL.java:783)
    at processing.core.PApplet.initSurface(PApplet.java:538)  ```
    

    Processing 4 and above can not create the rendering window in release assemblies. The simplest way is to downgrade to Processing 3.