tmthecoder / dargon2

Argon2 Dart Bindings
https://docs.tmthecoder.dev/dargon2/
MIT License
18 stars 12 forks source link

[dargon2] Can't build for android/ios with newer versions #16

Closed Nikoo00o closed 1 year ago

Nikoo00o commented 1 year ago

Hi, first of all thank you for the great library.

Sadly with higher versions than 2.1.0 of dargon2_flutter in my pubspec.yaml, i can't build my project for android, because of the following error:

Plugin project :dargon2_flutter_mobile not found. Please update settings.gradle. FAILURE: Build failed with an exception. Script 'C:\Standalones\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 462

I can reproduce the error by just creating a new empty flutter project with flutter 3.7.3 on windows and adding "dargon2_flutter: ^3.2.0" as a dependency in the pubspec.yaml and then running "flutter build apk".

Nikoo00o commented 1 year ago

This might be related to the way the "settings.gradle" file is generated for a new project and how it works with plugins which have components that are specific to a different platform other than android.

The following issues are similar: 46304, 57777, 55827

To fix this, i had to modify my project when using newer versions of the dargon2_flutter library for android. I added the following code to the bottom of the file "android/settings.gradle":

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
    pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}

plugins.each { name, path ->
    def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
    include ":$name"
    project(":$name").projectDir = pluginDirectory
}
Nikoo00o commented 1 year ago

Sadly for iOS i had a similiar problem with higher versions than 2.1.0 of dargon2_flutter. In this case on macOS with flutter 3.7.7 and cocoapods 1.12.0 none of the dargon2_flutter packages will be included inside of the podfile.lock as a dependency. The "Argon2Swift" dependency is also not included.

So then of course when building and running the application, the bindings are not found.

iamnijat commented 1 year ago

@Nikoo00o how did you solve this problem on ios?

Nikoo00o commented 1 year ago

@iamnijat i'm sorry, i didn't kept looking into it for ios. I just used a lower version when building for ios as a workaround.

tmthecoder commented 1 year ago

Hi, @Nikoo00o @iamnijat, Looks like the Android issue is a problem with Flutter and adding the code you mentioned in settings.gradle does the trick. Also looks like a PR is up here to fix it. I'm unable to replicate an iOS errors and have builds working fine with both existing and new applications. Closing for now as the Android fix is on the way.