tiki-deprecated / publish-sdk-flutter

TIKI SDK (Flutter) - Consumer Data Licensing
https://mytiki.com/docs/sdk-overview
MIT License
4 stars 4 forks source link

Fix flutter_secure_storage AAR dependency #232

Closed ricardobrg closed 1 year ago

ricardobrg commented 1 year ago

The flutter_secure_storage dependency can't be resolved by Android, using either the GitHub package manager or the local dependency. The issue appeared after version 1.1.3, which was the latest working version. It is necessary to debug what changed after version 1.1.3 and fix the creation of the AAR packages both locally and in GitHub packages.

Since this error happens both in the Github package and in local dependency, we need to first fix the local resolution to debug the GitHub package after.

Steps to reproduce:

  1. Run flutter build aar
  2. Add the flutter_secure_storage dependency to an Android project. Add the local repo in settings.gradle
    maven {
            url '<absolute path to tiki SDK flutter>/build/host/outputs/repo'
        }

    Add Flutter Secure Storage as a grade dependency in the module build.gradle

    implementation "com.it_nomads.fluttersecurestorage.flutter_secure_storage_release:1.0"
  3. Build the project. The project fails to build and the following error message is displayed:
    
    A problem occurred configuring project ':app'.
    > Could not resolve all dependencies for configuration ':app:debugEmbed'.
    > Could not find com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:.
     Required by:
         project :app

Possible solution:


### Debug data

- The maven metadata, aar and pom files exists in the local repository folder:

![Image](https://user-images.githubusercontent.com/8357343/229524009-a2580dd4-dd97-443c-b8f4-fe14b329e400.png)

- Maven metada.xml content:

<?xml version="1.0" encoding="UTF-8"?>

com.it_nomads.fluttersecurestorage flutter_secure_storage_debug 1.0 1.0 1.0 20230403132440
Debugging the dependency resolution with ` ./gradlew  -q dependencies --configuration scm --debug --refresh-dependencies | grep secure_storage`

2023-04-03T10:20:32.821-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Resolve com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:' started 2023-04-03T10:20:32.827-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Resolve com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:' 2023-04-03T10:20:32.827-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Resolve com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:' completed 2023-04-03T10:20:32.821-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0: using repositories [TIKI SDK Flutter local, GoogleApis, Google, MavenRepo] 2023-04-03T10:20:32.821-0300 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:' in repository 'TIKI SDK Flutter local'. 2023-04-03T10:20:32.822-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.PersistentModuleMetadataCache] Recording absence of module descriptor in cache: com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0: [changing = false] 2023-04-03T10:20:32.823-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Cached meta-data for missing module is expired: will perform fresh resolve of 'com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:' in 'GoogleApis' 2023-04-03T10:20:32.823-0300 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:' in repository 'GoogleApis'. 2023-04-03T10:20:32.825-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.PersistentModuleMetadataCache] Recording absence of module descriptor in cache: com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0: [changing = false] 2023-04-03T10:20:32.825-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Cached meta-data for missing module is expired: will perform fresh resolve of 'com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:' in 'Google' 2023-04-03T10:20:32.825-0300 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:' in repository 'Google'. 2023-04-03T10:20:32.825-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.PersistentModuleMetadataCache] Recording absence of module descriptor in cache: com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0: [changing = false] 2023-04-03T10:20:32.826-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Cached meta-data for missing module is expired: will perform fresh resolve of 'com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:' in 'MavenRepo' 2023-04-03T10:20:32.826-0300 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:' in repository 'MavenRepo'. 2023-04-03T10:20:32.827-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.PersistentModuleMetadataCache] Recording absence of module descriptor in cache: com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0: [changing = false] 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception. 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] What went wrong: 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] A problem occurred configuring project ':app'. 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not resolve all dependencies for configuration ':app:debugEmbed'. 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not find com.it_nomads.fluttersecurestorage.flutter_secure_storage_debug:1.0:. 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Required by: 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] project :app 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Try: 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --stacktrace option to get the stack trace. 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --scan to get full insights. 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org 2023-04-03T10:20:33.913-0300 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 2023-04-03T10:20:33.914-0300 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 46s

ricardobrg commented 1 year ago

An issue has been identified with the tiki-sdk-flutter version 2.1.2 in the tiki-sdk-android build.gradle file where the flutter_secure_storage library cannot be found. Attempts to import the secure_storage library from the local Flutter SDK using the flutter build aar command were unsuccessful due to the inability to locate the separate libraries.

As a workaround, tiki-sdk-android was reset to version 1.0.0, which allowed it to find all necessary dependencies. The build.gradle file from tiki-sdk-android 1.0.0 was then copied, and the dependencies required for the new features in Android were added.

Upgrading to tiki-sdk-flutter version 1.1.3 resolved the issue with all dependencies being found. However, upgrading to version 2.0.2 resulted in all dependencies except for flutter_secure_storage being found. Further upgrading to version 2.1.2 resulted in neither flutter_secure_storage nor sqlite_libs being found, despite being present on the GitHub packages page.

Attempts to regenerate the libraries by re-running the action encountered a conflict as the libraries were already present. The issue was then reproduced using a local build. The version has been bumped to 2.1.3 and the correct libraries were generated.

Aftwerwards the github packages were cleaned up to keep just the necessary libraries.