hyperledger-archives / aries-mobile-agent-xamarin

Apache License 2.0
38 stars 31 forks source link

Aries Xamarin isn't compatible with Android API 30 #52

Closed x0axz closed 2 years ago

x0axz commented 2 years ago

Hi,

I'm trying to upload my app to Google Play Store, but it isn't allowing me to publish it.

Your app currently targets API level 29 and must target at least API level 30 to ensure it is built on the latest APIs optimized for security and performance. Change your app's target API level to at least 30. 

When I tried to upgrade the API level to 30, I'm keep getting an IO error while trying to create a pool. On Android 30 can't create a pool, however with Android 29, it works fine.

AndroidManifest.xml

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

<application android:requestLegacyExternalStorage="true" android:allowBackup="false" android:fullBackupOnly="false"></application>

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Error Logs

9/28/2021 5:59:16 PM - Couldn't create pool config: Hyperledger.Indy.IOException: An IO error occurred. at Hyperledger.Aries.Ledger.DefaultPoolService.Crea tePoolAsync (System.String poolName, System.String genesisFile) [0x00072] in :0 at Osma.Mobile.App. Services.PoolConfigurator.ConfigurePoolsAsync() [0x0023c] in :0

9/28/2021 5:59:16 PM - Couldn't create pool config: Hyperledger.Indy.IOException: An IO error occurred. at Hyperledger.Aries.Ledger.DefaultPoolService.Crea tePoolAsync (System.String poolName, System.String genesis File) [0x00072] in :0 at Osma.Mobile.App.

Services.PoolConfigurator.Configure PoolsAsync()

[0x0023c] in :0

9/28/2021 5:59:16 PM - Couldn't create pool config: Hyperledger.Indy.IOException: An IO error occurred. at Hyperledger.Aries.Ledger.Default PoolService.Crea tePoolAsync (System.String poolName, System.String genesisFile) [0x00072] in :0 at Osma.Mobile.App. Services.PoolConfigurator.Configure PoolsAsync()
x0axz commented 2 years ago

Resolved it.

Starting in Android 11, apps cannot create their own app-specific directory on external storage. To access the directory that the system provides for your app, call getExternalFilesDirs().

getExternalFilesDirs https://developer.android.com/reference/android/content/Context#getExternalFilesDirs(java.lang.String)

To get private ExternalStorage you can use this:

Android.App.Application.Context.GetExternalFilesDir(null).AbsolutePath;

So, in Services/PoolConfigurator.cs, change

Path.Combine(FileSystem.CacheDirectory, config.Value);

to

Path.Combine(Android.App.Application.Context.GetExternalFilesDir(FileSystem.CacheDirectory).AbsolutePath, config.Value);

x0axz commented 2 years ago

Have a look into this Issue too, it'll be helpful: https://github.com/hyperledger/aries-mobile-agent-xamarin/issues/53.