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

Configuration MainActivity.class issue / Error 4 #29

Open
Sulorb opened this issue Apr 6, 2024 · 1 comment
Open

Configuration MainActivity.class issue / Error 4 #29

Sulorb opened this issue Apr 6, 2024 · 1 comment

Comments

@Sulorb
Copy link

Sulorb commented Apr 6, 2024

Hello,

I'm struggling to install correctly the plugin. The only thing I didn't succeed from the setup is this part:

Then on your MainActivity.class file you will need to import and register the plugin in your onCreate method:
@Override public void onCreate(Bundle savedInstanceState) { registerPlugin(CapacitorGameConnectPlugin.class); super.onCreate(savedInstanceState); }

Do I have to put it in android/app/src/main/java/io/ionic/start/MainActivity.java ?

I tried like this:

`
package app.myapp.www;

import com.getcapacitor.BridgeActivity;

public class MainActivity extends BridgeActivity {
@OverRide
public void onCreate(Bundle savedInstanceState) {
registerPlugin(CapacitorGameConnectPlugin.class);
super.onCreate(savedInstanceState);
}
}
`

But when I run it to my android device it returns me this error:

symbol: class Bundle [capacitor] location: class MainActivity [capacitor] C:\Users\alexi\OneDrive\...\android\app\src\main\java\io\ionic\starter\MainActivity.java:8: error: cannot find symbol [capacitor] registerPlugin(CapacitorGameConnectPlugin.class); [capacitor] ^ [capacitor] symbol: class CapacitorGameConnectPlugin [capacitor] location: class MainActivity [capacitor] 2 errors [capacitor] [capacitor] FAILURE: Build failed with an exception.

Also without that part I succeed to run it on my phone but when I try to signIn as follows:

import { CapacitorGameConnect } from '@openforge/capacitor-game-connect'; ... const user = await CapacitorGameConnect.signIn();

It returns me this error in the inspector console:

`
ERROR Error: 4:
at returnResult (VM3:912:32)
at win.androidBridge.onmessage (VM3:887:21)
handleError @ main.2b90b40a20af0514.js:1

`

Please help me finish the setup, I don't know what the "Error 4" means and how to "register the plugin in your onCreate method". 🙏

@Sulorb Sulorb changed the title Configuration MainActivity.class issue Configuration MainActivity.class issue / Error 4 Apr 7, 2024
@Sulorb
Copy link
Author

Sulorb commented Apr 7, 2024

I think my message was a bit confusing, but basically I had the common "error 4". Just solved it, here is what I did, maybe it'll help someone here:

  • In the strings.xml, i wrognly put my package id instead of my game project id (that you'll find under your project name in the google play console):
    <string translatable="false" name="game_services_project_id"> 0123456789</string>

The MainActivity.java fil must look like this:

`package io.ionic.starter;

import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.openforge.capacitorgameconnect.CapacitorGameConnectPlugin;

public class MainActivity extends BridgeActivity {
@OverRide
public void onCreate(Bundle savedInstanceState) {
registerPlugin(CapacitorGameConnectPlugin.class);
super.onCreate(savedInstanceState);
}
}
`

Please update your readme by adding this important line otherwise there is a bug:

import com.openforge.capacitorgameconnect.CapacitorGameConnectPlugin;

The error 4 apparently comes from a bad SHA1 in the oAuth. After reading the troubleshoot of this official documentation:
https://developers.google.com/games/services/console/enabling

I noticed you can easily debug directly your app by putting a SHA1 from the debug keystore and it'll work directly:

To get the debug certificate fingerprint, run the following command:

keytool -list -keystore -v

Note: On Windows, the debug keystore is located at C:\Users<USERNAME>.android\debug.keystore. On Mac or Linux, the debug keystore is typically located at ~/.android/debug.keystore.

I will have to change this SHA1 once the app is available in the Store, but you can at least debug your app with this debut keystore.

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

No branches or pull requests

1 participant