google-analytics-plugin icon indicating copy to clipboard operation
google-analytics-plugin copied to clipboard

Android 12 error Targeting S+

Open DalterioRaffaele opened this issue 2 years ago • 12 comments

Plugin don't work with android 12. Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

DalterioRaffaele avatar Nov 04 '22 16:11 DalterioRaffaele

any contribution is welcome

victorsosa avatar Nov 04 '22 16:11 victorsosa

if I set target=30 in config.xml : <preference name="android-targetSdkVersion" value="30" /> will it work on my Android 13 device?

ogousa avatar Nov 14 '22 15:11 ogousa

@DalterioRaffaele new version tested and works. what is the plugin version you are using?

EYALIN avatar Nov 16 '22 10:11 EYALIN

<plugin name="cordova-plugin-google-analytics" spec="^1.9.0">
    <variable name="GMS_VERSION" value="16.0.8" />
</plugin>

DalterioRaffaele avatar Nov 16 '22 10:11 DalterioRaffaele

@DalterioRaffaele so please upgrade to 1.9.2 (remove the plugin and add it again). that should solve your problem.

EYALIN avatar Nov 18 '22 12:11 EYALIN

@EYALIN Remove plugin and install 1.9.2 doesn't work (also tried to reset the project)

peggyyu526 avatar Nov 18 '22 16:11 peggyyu526

@peggyyu526 for some reason, upgrading the plugin does not update the whole files (it's happened to me only with this plugin). can you please share plugin.xml from the plugin? so I will try to understand what is missing there

EYALIN avatar Nov 18 '22 19:11 EYALIN

I'm using 1.9.2 and I'm still getting an error response from startTrackerWithId:

com.my.app: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

I'm on Android 13 - is it possible this fix didn't take or there's a regression from Android 12?

pugwonk avatar Jan 06 '23 19:01 pugwonk

Something that work in my specific case was to change the version of the com.google.android.gms:play-services-analytics dependency, I had setted 15.0.1, and this was causing the issue. After I update to

implementation "com.google.android.gms:play-services-analytics:18.0.1"

the issue was solved. In ionic for do this you should change the version of the google play services version on the config.xml

<plugin name="cordova-plugin-google-analytics" spec="1.8.6">
    <variable name="PLAY_SERVICES_VERSION" value="18.0.1" />
    <variable name="GMS_VERSION" value="18.0.1" />
</plugin>

or removing and adding the plugin again adding the parameters with the proper versions for PLAY_SERVICES_VERSION and GMS_VERSION.

Also becareful, make sure if you do this change that you change all play services to the same version (18.+ in my case), for example I use cordova-plugin-googleplus, so you should change also the PLAY_SERVICES_VERSION for this plugin and all that inject a play-services dependency in the build.gradle file after the build.

ZumelzuR avatar Jan 16 '23 16:01 ZumelzuR

any PR patch is welcome

victorsosa avatar Jan 16 '23 17:01 victorsosa

any PR patch is welcome

As I told, there is NO need of a PR with a patch. Simply is a matter of use the properties at the time of install this plugin. As you put in the documentation:

cordova plugin add cordova-plugin-google-analytics --variable GMS_VERSION=11.0.1 --PLAY_SERVICES_VERSION=11.0.1

instead of 11.0.1, 18.0.1

ZumelzuR avatar Jan 16 '23 18:01 ZumelzuR

yes, you are right

victorsosa avatar Jan 16 '23 18:01 victorsosa