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

ACRA integration does not work #90445

Closed
argrento opened this issue Apr 9, 2024 · 2 comments
Closed

ACRA integration does not work #90445

argrento opened this issue Apr 9, 2024 · 2 comments

Comments

@argrento
Copy link

argrento commented Apr 9, 2024

Tested versions

  • Reproducible in: 4.1.2.stable

System information

Linux mint 6.5.0-17-generic #17~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 16 14:32:32 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Issue description

I am trying to integrate ACRA (Application Crash Reports for Android -- https://github.com/ACRA/acra) into the my game. I do all the necessary steps from the ACRA Manual: https://www.acra.ch/docs/Setup

New class with ACRA Initailized (in android/build/src/com/godot/game/GodotACRAApp.java):

/*
 * Copyright (c) 2021
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.godot.game;

import android.app.Application;
import android.content.Context;
import org.acra.ACRA;
import org.acra.config.CoreConfigurationBuilder;
import org.acra.config.HttpSenderConfigurationBuilder;
import org.acra.data.StringFormat;
 
public class GodotACRAApp extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
 
        ACRA.init(this, new CoreConfigurationBuilder()
                .withBuildConfigClass(BuildConfig.class)
                .withReportFormat(StringFormat.JSON)
                .withPluginConfigurations(
                        new HttpSenderConfigurationBuilder()
                                .withUri("https://yourserver.com/report")
                                .build()
                )
        );
    }
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.godot.game"
    android:versionCode="1"
    android:versionName="1.0"
    android:installLocation="auto" >

    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true" />

    <uses-feature
        android:glEsVersion="0x00030000"
        android:required="true" />

    <application
        android:label="@string/godot_project_name_string"
        android:allowBackup="false"
        android:icon="@mipmap/icon"
        android:appCategory="game"
        android:isGame="true"
        android:hasFragileUserData="false"
        android:requestLegacyExternalStorage="false"
        tools:ignore="GoogleAppIndexingWarning" >

        <!-- Records the version of the Godot editor used for building -->
        <meta-data
            android:name="org.godotengine.editor.version"
            android:value="${godotEditorVersion}" />

        <activity
            android:name=".GodotACRAApp"  << -- new class name
            android:label="@string/godot_project_name_string"
            android:theme="@style/GodotAppSplashTheme"
            android:launchMode="singleInstancePerTask"
            android:excludeFromRecents="false"
            android:exported="true"
            android:screenOrientation="landscape"
            android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
            android:resizeableActivity="false"
            tools:ignore="UnusedAttribute" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

I use headless mode to export APK: ./Godot_v4.2.1-stable_linux.x86_64 --headless --export-debug android-arm64-v8a /opt/game/game.apk and see the following error.

0 param: --xr_mode_regular
1 param: --use_immersive
ERROR: Export: Building of Android project failed, check output for the error:

WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 33

This Android Gradle plugin (7.2.1) was tested up to compileSdk = 32

This warning can be suppressed by adding
    android.suppressUnsupportedCompileSdk=33
to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 33
> Task :clean
> Task :assetPacks:installTime:clean UP-TO-DATE
> Task :preBuild UP-TO-DATE
> Task :preDebugBuild UP-TO-DATE
> Task :mergeDebugNativeDebugMetadata NO-SOURCE
> Task :compileDebugAidl NO-SOURCE
> Task :compileDebugRenderscript NO-SOURCE
> Task :generateDebugBuildConfig
> Task :checkDebugAarMetadata
> Task :generateDebugResValues
> Task :generateDebugResources
> Task :createDebugCompatibleScreenManifests
> Task :extractDeepLinksDebug
> Task :mergeDebugResources

> Task :processDebugMainManifest FAILED
/opt/game/android/build/src/debug/AndroidManifest.xml:11:5-132 Warning:
	uses-feature#android.hardware.vulkan.level was tagged at AndroidManifest.xml:11 to replace another declaration but no other declaration present
/opt/game/android/build/src/debug/AndroidManifest.xml:12:5-140 Warning:
	uses-feature#android.hardware.vulkan.version was tagged at AndroidManifest.xml:12 to replace another declaration but no other declaration present
/opt/game/android/build/src/debug/AndroidManifest.xml:23:9-29:20 Warning:
	activity#com.godot.game.GodotApp@android:screenOrientation was tagged at AndroidManifest.xml:23 to replace other declarations but no other declaration present
/opt/game/android/build/src/debug/AndroidManifest.xml:23:9-29:20 Warning:
	activity#com.godot.game.GodotApp@android:excludeFromRecents was tagged at AndroidManifest.xml:23 to replace other declarations but no other declaration present
/opt/game/android/build/src/debug/AndroidManifest.xml:23:9-29:20 Warning:
	activity#com.godot.game.GodotApp@android:resizeableActivity was tagged at AndroidManifest.xml:23 to replace other declarations but no other declaration present
/opt/game/android/build/src/debug/AndroidManifest.xml:36:9-42:51 Warning:
	provider#org.acra.attachment.AcraContentProvider@android:authorities was tagged at AndroidManifest.xml:36 to replace other declarations but no other declaration present
/opt/game/android/build/src/debug/AndroidManifest.xml:23:9-29:20 Error:
	android:exported needs to be explicitly specified for element <activity#com.godot.game.GodotApp>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugMainManifest'.
> Manifest merger failed with multiple errors, see logs

* 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 4s
9 actionable tasks: 8 executed, 1 up-to-date

In the autogenerated maifest in src/debug/AndroidManifest.xml main activity is still GodotApp.

...
        <activity android:name="com.godot.game.GodotApp" tools:replace="android:screenOrientation,android:excludeFromRecents,android:resizeableActivity" tools:node="mergeOnlyAttributes" android:excludeFromRecents="false" android:screenOrientation="landscape" android:resizeableActivity="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

Steps to reproduce

/*
 * Copyright (c) 2021
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.godot.game;

import android.app.Application;
import android.content.Context;
import org.acra.ACRA;
import org.acra.config.CoreConfigurationBuilder;
import org.acra.config.HttpSenderConfigurationBuilder;
import org.acra.data.StringFormat;
 
public class GodotACRAApp extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
 
        ACRA.init(this, new CoreConfigurationBuilder()
                .withBuildConfigClass(BuildConfig.class)
                .withReportFormat(StringFormat.JSON)
                .withPluginConfigurations(
                        new HttpSenderConfigurationBuilder()
                                .withUri("https://yourserver.com/report")
                                .build()
                )
        );
    }
}

Minimal reproduction project (MRP)

game_mrp.zip

Deleted from the archive:

  • android/build/lib/*
  • android/build/res/*
  • .gradle/*
@melquiadess
Copy link
Contributor

The issue is in your setup:

  • ACRA is initialized in the custom application class: GodortACRAApp, which extends Application, but...
  • it is specified for an activity in AndroidManifest.xml, so
 <activity
            android:name=".GodotACRAApp"  << -- new class name

is the wrong place to do it.

Can you please try the following:

  • in AndroidManifest.xml, add the android:name=".GodotACRAApp" in the <application> tag, not <activity> tag
  • remove the one that's been added in the <activity> tag, and revert to the android:name=".GodotApp" as before

and try again, in essence following the ACRA documentation:

acra

With this fix, your MRP fails building for me for some reason, but I was able to setup ACRA in a new project, and export it on my machine (Windows 11, Godot 4.2.1) from the Godot Editor successfully (it should work for you on Linux too)

The relevant <application> section in your AndroidManifest.xml will look something like this:

<application
        android:label="@string/godot_project_name_string"
        android:name=".GodotACRAApp"
        android:allowBackup="false"
        android:icon="@mipmap/icon"
        android:appCategory="game"
        android:isGame="true"
        android:hasFragileUserData="false"
        android:requestLegacyExternalStorage="false"
        tools:ignore="GoogleAppIndexingWarning" >

        <!-- Records the version of the Godot editor used for building -->
        <meta-data
            android:name="org.godotengine.editor.version"
            android:value="${godotEditorVersion}" />

        <activity
            android:name=".GodotApp"
            android:label="@string/godot_project_name_string"
            android:theme="@style/GodotAppSplashTheme"
            android:launchMode="singleInstancePerTask"
            android:excludeFromRecents="false"
            android:exported="true"
            android:screenOrientation="landscape"
            android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
            android:resizeableActivity="false"
            tools:ignore="UnusedAttribute" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

@argrento
Copy link
Author

This is what happens when someone tries to work with Android with zero Android knowledge.

Thank you so much, with your changes everything works!

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

No branches or pull requests

3 participants