Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl #172

Open
d3im opened this issue Feb 13, 2024 · 6 comments · May be fixed by #178
Open

Comments

@d3im
Copy link

d3im commented Feb 13, 2024

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;
}
@d3im
Copy link
Author

d3im commented Feb 14, 2024

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?

@d3im
Copy link
Author

d3im commented Feb 21, 2024

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.

@mvarendorff2 mvarendorff2 linked a pull request Mar 18, 2024 that will close this issue
@mvarendorff2
Copy link

This seems caused by an incompatibility with Android Gradle Plugin 8.x. I have opened a PR.

@Merlinski
Copy link

Any progress here? Will there be a compatibility with gradle 8.x?

@mvarendorff2
Copy link

Seems a bit dead, unfortunately 😕 The only person listed as part of the Dint organization hasn't been active on GitHub for ages.

As a workaround, you can use my fork as dependency which is what we are doing in our projects:

    cryptography_flutter:
        git:
            url: https://github.com/mvarendorff/cryptography
            ref: fix/compatibility-agp-8x
            path: cryptography_flutter

@savejeff
Copy link

@mvarendorff2 the fix seems to work. thx

so basically the security-relevant package is not maintained anymore and requires forsk to fix bugs? isn't that a major security issue? is there an official dart/flutter package for encryption?

petrleocompel added a commit to emz-hanauer/dart-cryptography that referenced this issue Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants