Skip to content

Not possible to add application to AndroidManifest.xml #73

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

Closed
CamronLDNF opened this issue Oct 22, 2021 · 4 comments
Closed

Not possible to add application to AndroidManifest.xml #73

CamronLDNF opened this issue Oct 22, 2021 · 4 comments

Comments

@CamronLDNF
Copy link

CamronLDNF commented Oct 22, 2021

I've gone through your Flutter SDK to integrate CleverTap in our Flutter app. Are the instructions up to date? The Android integration section says:

If you do not have an Application class, add this to your AndroidManifest.xml

    <application
        android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
        android:name="com.clevertap.android.sdk.Application"> 

The problem is that it is not possible to do that because I have my default application data there already (and adding the above for CleverTap conflicts and renders an error).

    <application
        android:requestLegacyExternalStorage="true"
        android:name="io.flutter.app.FlutterApplication"
        android:label="Beanie"
        android:icon="@mipmap/ic_launcher">

What is the solution here? The AndroidManifest.xml file in your example code does not reflect the above instructions.

@darshanclevertap
Copy link
Contributor

@CamronLDNF If you have a custom application class, call ActivityLifecycleCallback.register(this); before super.onCreate() in your class.

We're in the process of upgrading our Flutter documentation. We'll add this there as well. 👍🏾

@CamronLDNF
Copy link
Author

@darshanclevertap about this:

@CamronLDNF If you have a custom application class, call ActivityLifecycleCallback.register(this); before super.onCreate() in your class.

That is already stated in your documentation. I don't have a custom application class though, so that is why I instead followed the instructions on If you do not have an Application class.... But I'm getting aforementioned error. What do I do?

@darshanclevertap
Copy link
Contributor

@CamronLDNF Please create an Application class in your Android project and extend it from FlutterApplication class and then do the following -

If you have a custom application class, call ActivityLifecycleCallback.register(this); before super.onCreate() in your class.

We need this to correctly track App launches, FCM tokens, render InApp Notifications and other session-related stuff.

@CamronLDNF
Copy link
Author

@darshanclevertap the solution was actually much simpler (or so it seems). Your documentation states:

If you do not have an Application class, add this to your AndroidManifest.xml

The word "add" in your instructions is what through me off. Apparently there can be only one android:name attribute, which is the class that is instantiated before any of the application's components. Instead of adding, I replaced android:name="io.flutter.app.FlutterApplication" with android:name="com.clevertap.android.sdk.Application" and now it works. Like this:

<application
    android:requestLegacyExternalStorage="true"
    android:name="com.clevertap.android.sdk.Application" 
    android:label="Beanie"
    android:icon="@mipmap/ic_launcher">

So now when the app is started, this CleverTap custom class is instantiated before any of the application's components.

I think this should be clarified in your Flutter documentation.

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

2 participants