Nets-mobile-acceptance / Netaxept-Android-SDK

PiA Netaxept Android SDK is a library that provides the native In-App interaction to perform Netaxept payments directly from an app on Android devices while minimizing PCI DSS requirements for you.
31 stars 15 forks source link

Activity missing exported tag to work on Android 12 #61

Closed mbelchuke closed 1 year ago

mbelchuke commented 2 years ago

We can't seem to override the AndroidManifest.xml in Xamarin, to force the export tag to be added.

Is this something you are able to fix in the next release?

Error           android:exported needs to be explicitly specified for element <activity#eu.nets.pia.wallets.MobilepayActivity>
Error       android:exported needs to be explicitly specified for element <activity#eu.nets.pia.wallets.VippsTestActivity>. 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. JtkKantineShop.Android  C:\Workspaces\Apps\JtkKantineAPP2022\JtkKantineShop.Android\obj\Debug\120\AndroidManifest.xml   83  
Error       android:exported needs to be explicitly specified for element <activity#eu.nets.pia.wallets.VippsActivity>. 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. JtkKantineShop.Android  C:\Workspaces\Apps\JtkKantineAPP2022\JtkKantineShop.Android\obj\Debug\120\AndroidManifest.xml   98  
Error       android:exported needs to be explicitly specified for element <activity#eu.nets.pia.wallets.SwishActivity>. 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. JtkKantineShop.Android  C:\Workspaces\Apps\JtkKantineAPP2022\JtkKantineShop.Android\obj\Debug\120\AndroidManifest.xml   113

Xamarin Forms 5.0.0.2515 Android Target Framework Android 12.0

Miss-PiA commented 2 years ago

Hi @mbelchuke

In v2.6.4 there seems to be exported tag in all of the activities mentioned in the log. Which version of the SDK are you using and did you try with v2.6.4?

Even if some exported tags are missing you can try the node markers to modify merged manifest for now. https://developer.android.com/studio/build/manage-manifests#node_markers

Please let us know if this helps.

Thanks

mbelchuke commented 2 years ago

Hi. We are using 2.6.4

image

But it still seems to create the manifest file without exported tag.

We've tried the merge node, but it doesn't seem to be working.

mbelchuke commented 2 years ago

This is the manifest file created by version 2.6.4

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="eu.nets.pia" android:versionCode="160" android:versionName="2.4.0" >

<uses-sdk
    android:minSdkVersion="21"
    android:targetSdkVersion="30" />

<queries>
    <package android:name="fi.danskebank.mobilepay" />
    <package android:name="dk.danskebank.mobilepay.vendor.sprint" />
    <package android:name="no.dnb.vipps.mt" />
    <package android:name="no.dnb.vipps" />
    <package android:name="se.bankgirot.swish" />
</queries>

<uses-permission android:name="android.permission.INTERNET" />

<!-- section-start-to-remove-by-script -->
<!-- permissions required by card scanner -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />

<uses-feature
    android:name="android.hardware.camera"
    android:required="false" />
<uses-feature
    android:name="android.hardware.camera.autofocus"
    android:required="false" />

<!-- end -->
<!-- section-end-to-remove-by-script -->
<application
    android:allowBackup="true"
    android:supportsRtl="true" >
    <activity
        android:name="eu.nets.pia.ui.webview.PaytrailActivity"
        android:configChanges="uiMode"
        android:screenOrientation="portrait"
        android:theme="@style/Pia.AppTheme" />
    <activity
        android:name="eu.nets.pia.ui.webview.ThreeDSecureActivity"
        android:configChanges="uiMode"
        android:screenOrientation="portrait"
        android:theme="@style/Pia.AppTheme" />
    <activity
        android:name="eu.nets.pia.ui.webview.PayPalActivity"
        android:configChanges="uiMode"
        android:screenOrientation="portrait"
        android:theme="@style/Pia.AppTheme" />
    <activity
        android:name="eu.nets.pia.ui.main.PiaActivity"
        android:configChanges="uiMode"
        android:screenOrientation="portrait"
        android:theme="@style/Pia.AppTheme" />
    <activity
        android:name="eu.nets.pia.cardio.CardIOActivity"
        android:configChanges="keyboardHidden|orientation|uiMode"
        android:screenOrientation="portrait"
        android:theme="@style/Pia.AppTheme" />
    <activity
        android:name="eu.nets.pia.ui.wallet.WalletPaymentActivity"
        android:configChanges="keyboardHidden|orientation|uiMode"
        android:launchMode="singleTask"
        android:theme="@style/Pia.Theme.Transparent" />
    <activity
        android:name="eu.nets.pia.wallets.MobilepayActivity"
        android:launchMode="singleTask"
        android:theme="@style/Pia.Theme.Transparent" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="piasdk_mobilepay"
                android:scheme="${applicationId}" />
        </intent-filter>
    </activity>
    <activity
        android:name="eu.nets.pia.wallets.VippsTestActivity"
        android:launchMode="singleTask"
        android:theme="@style/Pia.Theme.Transparent" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="piasdk_vipps_test"
                android:scheme="${applicationId}" />
        </intent-filter>
    </activity>
    <activity
        android:name="eu.nets.pia.wallets.VippsActivity"
        android:launchMode="singleTask"
        android:theme="@style/Pia.Theme.Transparent" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="piasdk_vipps"
                android:scheme="${applicationId}" />
        </intent-filter>
    </activity>
    <activity
        android:name="eu.nets.pia.wallets.SwishActivity"
        android:launchMode="singleTask"
        android:theme="@style/Pia.Theme.Transparent" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="piasdk_swish"
                android:scheme="${applicationId}" />
        </intent-filter>
    </activity>
</application>

mbelchuke commented 2 years ago

Okay. Seems that you have some issues regarding your nuget package. If we uninstall the package and reference the DLL directly, it seems to be building and merging the manifest correctly with exported tag applied.

Though, there seems to be another conflict when doing this. It seems that the new DLL is missing these to methods:

public unsafe static ActivityResultContract CardPaymentActivityContractXamarin()

and

public unsafe static void StartCardProcessActivity(ActivityResultLauncher p0, CardProcess p1, Java.Lang.Boolean p2)

Miss-PiA commented 2 years ago

Hi @mbelchuke

Sorry for the late reply.

Try to modify your AndroidManifest.xml as follows

Add xmlns:tools="http://schemas.android.com/tools" attribute for <manifest> element as shown below

<manifest xmlns:tools="http://schemas.android.com/tools" ...>

And then add below lines between <application> and </application> element

<activity
    android:name="eu.nets.pia.wallets.MobilepayActivity"
    android:exported="true"
    android:launchMode="singleTask"
    android:theme="@style/Pia.Theme.Transparent"
    tools:node="merge">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="piasdk_mobilepay"
            android:scheme="${applicationId}" />
    </intent-filter>
</activity>
<activity
    android:name="eu.nets.pia.wallets.VippsTestActivity"
    android:exported="true"
    android:launchMode="singleTask"
    android:theme="@style/Pia.Theme.Transparent"
    tools:node="merge">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="piasdk_vipps_test"
            android:scheme="${applicationId}" />
    </intent-filter>
</activity>
<activity
    android:name="eu.nets.pia.wallets.VippsActivity"
    android:exported="true"
    android:launchMode="singleTask"
    android:theme="@style/Pia.Theme.Transparent"
    tools:node="merge">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="piasdk_vipps"
            android:scheme="${applicationId}" />
    </intent-filter>
</activity>
<activity
    android:name="eu.nets.pia.wallets.SwishActivity"
    android:exported="true"
    android:launchMode="singleTask"
    android:theme="@style/Pia.Theme.Transparent"
    tools:node="merge">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="piasdk_swish"
            android:scheme="${applicationId}" />
    </intent-filter>
</activity>

Please let us know if this helps.

Thanks

Miss-PiA commented 1 year ago

Closing this issue as solved, feel free to reopen the issue if required