New flutter project fails with error
Steps: flutter doctor - all green flutter create test cd test flutter build app_bundle (successful) flutter pub add cryptography_flutter flutter build app_bundle
error:
* What went wrong:
A problem occurred configuring project ':cryptography_flutter'.
> Could not resolve all files for configuration ':cryptography_flutter:classpath'.
> Could not find com.android.tools.build:gradle:8.7.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.7/gradle-8.7.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/8.7/gradle-8.7.pom
Required by:
project :cryptography_flutter
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for project ':cryptography_flutter' of type org.gradle.api.Project.
> Could not get unknown property 'android' for project ':cryptography_flutter' of type org.gradle.api.Project.
There's nothing in the documentation that would indicate steps required to make this work with some changes. But I tried updating to gradle 8.7 in gradle-wrapper.properties and it still errors.
Also there is no such thing as android tools 8.7, 8.4 is the latest.
I was able to sort of get around this be going into the package cache for this library and adding this to the build.gradle:
namespace "dev.dint.cryptography_flutter"
That eliminated the error. There are TONS of depreciation warnings though from this library.
I was able to sort of get around this be going into the package cache for this library and adding this to the build.gradle:
namespace "dev.dint.cryptography_flutter"
That eliminated the error. There are TONS of depreciation warnings though from this library.
Also need to remove package property in AndroidManifest.xml
Same warning here +1
try adding this to your android/build.gradle
subprojects {
afterEvaluate { project ->
if (project.plugins.hasPlugin("com.android.application") ||
project.plugins.hasPlugin("com.android.library")) {
project.android {
compileSdkVersion 34
}
}
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace = project.group.toString() // Set namespace as fallback
}
project.tasks.whenTaskAdded { task ->
if (task.name.contains('processDebugManifest') || task.name.contains('processReleaseManifest')) {
task.doFirst {
File manifestFile = file("${projectDir}/src/main/AndroidManifest.xml")
if (manifestFile.exists()) {
String manifestContent = manifestFile.text
if (manifestContent.contains('package=')) {
manifestContent = manifestContent.replaceAll(/package="[^"]*"/, "")
manifestFile.write(manifestContent)
println "Removed 'package' attribute from ${manifestFile}"
}
}
}
}
}
}
}
}
This code will make the required changes in all packages' AndroidManifest.xml