Android Question (Solved) error: no suitable method found for onCreate(no arguments)


Active Member
Licensed User
Longtime User
Hi everyone, again me,

Im integrating the Huawei SDK and Analytics Kit, added all the JARS needed, and using this Java Inline code on Main:

    '--------------------HUAWEI SERVICES -----------------------
#if Java

import com.huawei.agconnect.config.AGConnectServicesConfig;
import com.huawei.agconnect.config.LazyInputStream;
import static*;
import static*;
import android.content.Context;
import android.util.Log;

public class MyApplication extends main{

    public void onCreate() {

    protected void attachBaseContext() {
        Context context = this;
        AGConnectServicesConfig config = AGConnectServicesConfig.fromContext(context);
        config.overlayWith(new LazyInputStream(context) {
            public InputStream get(Context context) {
                try {
                    return context.getAssets().open("agconnect-services.json");
                } catch (IOException e) {
                    return null;
    // TODO: End

    public void initHMS(){
         HiAnalyticsInstance instance;
        // TODO: Initiate Analytics Kit
        // Enable Analytics Kit Log
        // Generate the Analytics Instance
        instance = HiAnalytics.getInstance(this);
        // You can also use Context initialization
        // Context context = this.getApplicationContext();
        // instance = HiAnalytics.getInstance(context);

        // Enable collection capability
        // Enable Automatically collection capability

        // TODO: Registering the HMS Service
        // Register the HMS service and collect automatic events (account event or InAppPurchase event).
        // Automatic account event collection requires HMS APK or a later version.

#End If

Then i call the Methods here:
    NativeMe.RunMethod("attachBaseContext",Null) 'This is to set the configuration file [I][U]agconnect-services.json[/U][/I]
    NativeMe.RunMethod("initHMS", Null)

The app works if i dont call the method NativeMe.RunMethod("attachBaseContext",Null)
But this method is needed to read the file agconnect-services.json, if i don't call it, the library loads OK but says no config file loaded, so it dont work.

The error thrown:

B4A Version: 9.80
Java Version: 8
Parsing code.    (0.09s)
Building folders structure.    (0.04s)
Compiling code.    (0.40s)
Compiling layouts code.    (0.02s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Generating R file.    (0.00s)
Compiling generated Java code.    Error
B4A line: 1065
End Sub
javac 1.8.0_231
src\stickers\memetflix\ error: no suitable method found for onCreate(no arguments)
    method Activity.onCreate(Bundle) is not applicable
      (actual and formal argument lists differ in length)
    method Activity.onCreate(Bundle,PersistableBundle) is not applicable
      (actual and formal argument lists differ in length)
    method main.onCreate(Bundle) is not applicable
      (actual and formal argument lists differ in length)

Im using the integration tutorial:
Step 5 The Eclipse IDE does not support the AppGallery Connect plug-in. Therefore, you need to place the agconnect-services.json file in the assets directory of your project and add the following code to the Application subclass of the project. If the project does not have an Application subclass, you need to create a subclass that is inherited from the Application subclass. For example, create a MyApplication class.

  1. public class MyApplication extends Application{
  2. @Override
  3. public void onCreate() {
  4. super.onCreate();
  5. }
  6. // TODO: Add the following code:
  7. @Override
  8. protected void attachBaseContext(Context context) {
  9. super.attachBaseContext(context);
  10. AGConnectServicesConfig config = AGConnectServicesConfig.fromContext(context);
  11. config.overlayWith(new LazyInputStream(context) {
  12. public InputStream get(Context context) {
  13. try {
  14. return context.getAssets().open("agconnect-services.json");
  15. } catch (IOException e) {
  16. return null;
  17. }
  18. }
  19. });
  20. }
  21. // TODO: End
  22. }

Is there any other way that i can use to set and read the "agconnect-services.json" on AGConnectServicesConfig config = AGConnectServicesConfig.fromContext(context);

I spent more than 3 hours realizing what is the problem, help are very appreciated! :D
Last edited:


Active Member
Licensed User
Longtime User
I solved it deleteing the onCreate() and the super declaration. it worked!
Upvote 0