Search code examples
ionic-frameworkionic4ionic-native

ionic base64togallery plugin not working in android-targetSdkVersion 29


I'm using base64-to-gallery to save images for android devices in my ionic app.

Previously it was working fine but now after added <preference name="android-targetSdkVersion" value="29" />to config.xml file, under android platform, it's not working.

Please kindly help me with it.


Solution

  • Finally solved the issue. To anyone who is struggling, I will explain as below.

    As mentioned in the git, https://github.com/Nexxa/cordova-base64-to-gallery , ionic Cordova base64togallery plugin has been discontinued.

    And also when trying to submit the ionic mobile app for Android production, it's saying that the target SDK version should be more than 29.

    But as usual, if we add <preference name="android-targetSdkVersion" value="29" /> to the config.xml file under the Android platform, it will not work the base64togallery plugin (not saving images to your device)

    So you have to do like below,

    In your ionic project, go to build.gradle file (platforms\android\build.gradle) and change defaultTargetSdkVersion and defaultCompileSdkVersion to 29. (as below)

    defaultTargetSdkVersion=29 
    defaultCompileSdkVersion=29
    

    And then go to AndroidManifest.xml file (platforms\android\app\src\main\AndroidManifest.xml) and add android:requestLegacyExternalStorage="true" to the application tag, as showing below.

    <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:supportsRtl="true">
    

    Then try to build your app for debug or release versions.