cryptography
cryptography copied to clipboard
Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl
I'm getting this when trying to run (Android Studio):
Launching lib/main.dart on sdk gphone64 x86 64 in debug mode... Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
- What went wrong: A problem occurred configuring project ':cryptography_flutter'.
Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl. Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.
If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org.
BUILD FAILED in 1s Exception: Gradle task assembleDebug failed with exit code 1
Is this common problem or could this be caused by my misunderstood:
import 'package:cryptography/cryptography.dart';
import 'package:cryptography_flutter/cryptography_flutter.dart';
Future<(SecretKey, SimplePublicKey)> _getKeys(
SimplePublicKey remotePublicKey) async {
final cipher = FlutterX25519(X25519 as X25519);
final localKeyPair = await cipher.newKeyPair();
final sharedSecretKey = await cipher.sharedSecretKey(
keyPair: localKeyPair, remotePublicKey: remotePublicKey);
final localPublicKey = await localKeyPair.extractPublicKey();
return (sharedSecretKey, localPublicKey);
}
Future<SecretBox> _symmetricEncrypt(String inString, SecretKey sKey) async {
final cipher = FlutterChacha20.poly1305Aead();
final eString = await cipher.encryptString(inString, secretKey: sKey);
return eString;
}
Are cryptography_flutter methods used as default on supported platforms when used cryptography methods? i.e. Chacha20.poly1305Aead() automatically inits as FlutterChacha20.poly1305Aead() ? Since didn't found any example using Flutter prefixed methods. Could this be the source of this error?
I've removed cryptography_flutter from dependencies, changed to common non-flutter methods and I can build and run. Still don't know why I can't use cryptography_flutter.
This seems caused by an incompatibility with Android Gradle Plugin 8.x. I have opened a PR.