最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - pub.dev package ssh2 v2.2.3 stopped working after Flutter upgrade to 3.27.2 - Stack Overflow

programmeradmin3浏览0评论

I am using ssh2 in my project. It worked fine until I upgraded flutter 6 days ago and now the project will not build.

For the error shown below, I am using the example code main.dart in /packages/ssh2/example

peter@solsona:~/AndroidStudioProjects/peter72_xssh2$ flutter run
Launching lib/main.dart on Pixel 8 Pro in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':ssh2'.
> 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  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  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 .

BUILD FAILED in 10s
Running Gradle task 'assembleDebug'...                             10.9s
Error: Gradle task assembleDebug failed with exit code 1

This build failed for an Android phone Pixel 8 Pro using Flutter 3.27.2, Dart 3.6.1, and gradle 8.3.

peter@solsona:~/AndroidStudioProjects/peter72_xssh2$ flutter --version
Flutter 3.27.2 • channel stable • .git
Framework • revision 68415ad1d9 (6 days ago) • 2025-01-13 10:22:03 -0800
Engine • revision e672b006cb
Tools • Dart 3.6.1 • DevTools 2.40.2
peter@solsona:~/AndroidStudioProjects/peter72_xssh2$ cat android/gradle/wrapper/gradle-wrapper.properties 
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle/distributions/gradle-8.3-all.zip

I checked the website but I have no file named build.gradle.kts in my project.

I checked the website but in android-studio, Tools>AGP Upgrade Assistant is greyed out and unavailable.

Is this fixable or is my only option to downgrade Flutter to where it was before?

I am using ssh2 in my project. It worked fine until I upgraded flutter 6 days ago and now the project will not build.

For the error shown below, I am using the example code main.dart in https://pub.dev/packages/ssh2/example

peter@solsona:~/AndroidStudioProjects/peter72_xssh2$ flutter run
Launching lib/main.dart on Pixel 8 Pro in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':ssh2'.
> 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 10s
Running Gradle task 'assembleDebug'...                             10.9s
Error: Gradle task assembleDebug failed with exit code 1

This build failed for an Android phone Pixel 8 Pro using Flutter 3.27.2, Dart 3.6.1, and gradle 8.3.

peter@solsona:~/AndroidStudioProjects/peter72_xssh2$ flutter --version
Flutter 3.27.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 68415ad1d9 (6 days ago) • 2025-01-13 10:22:03 -0800
Engine • revision e672b006cb
Tools • Dart 3.6.1 • DevTools 2.40.2
peter@solsona:~/AndroidStudioProjects/peter72_xssh2$ cat android/gradle/wrapper/gradle-wrapper.properties 
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip

I checked the website https://d.android.com/r/tools/upgrade-assistant/set-namespace but I have no file named build.gradle.kts in my project.

I checked the website https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant but in android-studio, Tools>AGP Upgrade Assistant is greyed out and unavailable.

Is this fixable or is my only option to downgrade Flutter to where it was before?

Share Improve this question asked Jan 20 at 2:10 Peter ThompsonPeter Thompson 7710 bronze badges 1
  • there is suggestion here : Namespace not specified. inside error – Hardik Mehta Commented Jan 20 at 4:39
Add a comment  | 

1 Answer 1

Reset to default 0

Hardik Mehta was correct. Searching "namespace not specified" gives websites which show the solution used.

Placing the following code into android/build.gradle will solve the issue

subprojects {
afterEvaluate { project ->
    if (project.hasProperty('android')) {
        project.android {
            if (namespace == null) {
                namespace project.group
            }
        }
    }
}

}

It must be placed in the correct position in build.gradle. In my case I put it right after

subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"

}

The websites are Android getting error: Namespace not specified

https://medium.com/@derricktab44/resolving-the-namespace-not-specified-error-in-flutter-builds-1ce818214b54

发布评论

评论列表(0)

  1. 暂无评论