square / in-app-payments-flutter-plugin

Flutter Plugin for Square In-App Payments SDK
https://developer.squareup.com/docs
Apache License 2.0
340 stars 121 forks source link

Cannot install - android:exported needs to be explicitly specified for <activity> #176

Closed Zelfapp closed 2 years ago

Zelfapp commented 2 years ago

Describe the issue

Targeting Android SDK 31 with min 24

When trying to run I'm getting this error:

Manifest merger failed: 

android:exported needs to be explicitly specified for <activity>. 

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.

https://developer.android.com/guide/topics/manifest/activity-element#exported

If I remove square_in_app_payments: ^1.7.2 my app runs with no issues. Only when I try to run with square_in_app_payments do I get the android:exported error and the build fails. I had another flutter package installed that had this issue and the developer had to update their manifest.xml for this SDK 31 requirement. I don't know that this is the issue, but I cannot install this package when targeting SDK 31.

Environment (please complete the following information):

flutter doctor -v results ```dart [✓] Flutter (Channel stable, 2.5.3, on Manjaro Linux 5.4.159-1-MANJARO, locale en_US.UTF-8) • Flutter version 2.5.3 at /opt/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 18116933e7 (7 weeks ago), 2021-10-15 10:46:35 -0700 • Engine revision d3ea636dc5 • Dart version 2.14.4 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc2) • Android SDK at /home/nate/Android/Sdk • Platform android-31, build-tools 31.0.0-rc2 • ANDROID_HOME = /opt/android-sdk • ANDROID_SDK_ROOT = /home/nate/Android/Sdk • Java binary at: /opt/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) • All Android licenses accepted. [✓] Chrome - develop for the web • CHROME_EXECUTABLE = /usr/bin/google-chrome-stable [✓] Android Studio (version 2020.3) • Android Studio at /opt/android-studio • Flutter plugin version 63.0.1 • Dart plugin version 203.8452 • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) [✓] Connected device (2 available) • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.45 • No issues found! ```
rmorrin commented 2 years ago

We were able to overcome this by adding the following to our own manifest.

<activity android:name="sqip.internal.SecureRemoteCommerceActivity"
    android:exported="false"
    tools:node="merge" />

If you don't already, you'll have to define the tools namespace on your manifest header:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" <-- add this
    package="com.example.app">

Ideally Square should update their Android SDK for compatibility with Android 31 but this workaround is working well for us until that happens!

CharmisG commented 2 years ago

Added line manifest android please pull latest code.