benjamindean/flutter_vibration

Face this error in android studio terminal

Closed this issue · 4 comments

My flutter doctor information is ..

`[✓] Flutter (Channel stable, 3.10.0, on macOS 13.3.1 22E261 darwin-arm64
(Rosetta), locale ko-KR)
• Flutter version 3.10.0 on channel stable at /Users/ted/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 84a1e904f4 (7 days ago), 2023-05-09 07:41:44 -0700
• Engine revision d44b5a94c9
• Dart version 3.0.0
• DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/ted/Library/Android/sdk
• Platform android-33, build-tools 33.0.2
• ANDROID_HOME = /Users/ted/Library/Android/sdk
• ANDROID_SDK_ROOT = /Users/ted/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E222b
• CocoaPods version 1.11.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio
• Android Studio at /Applications/Android Studio Preview.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.

[✓] Android Studio (version 2022.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.78.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 13 (API 33) (emulator)
• iPhone SE (3rd generation) (mobile) • 98B320D4-E91C-4C52-95EB-EA4C62207BF5 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.3.1 22E261 darwin-arm64 (Rosetta)
• Chrome (web) • chrome • web-javascript • Google Chrome 113.0.5672.92

[✓] Network resources
• All expected network resources are available.
`

and my android emulator is API 33 Fold-in Type,

i'd run 'flutter pub get' then run on my emulator,

i expect run on my emulator but i got this error

`
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • Where:
    Build file '/Users/ted/.pub-cache/hosted/pub.dev/vibration-1.7.7/android/build.gradle' line: 25

  • What went wrong:
    A problem occurred evaluating project ':vibration'.

Could not find method namespace() for arguments [com.benjaminabel.vibration] on extension 'android' of type com.android.build.gradle.LibraryExtension.

  • 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.
==============================================================================

2: Task failed with an exception.

  • Where:
    Script '/Users/ted/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 468

  • What went wrong:
    A problem occurred configuring project ':vibration'.

Failed to notify project evaluation listener.
Cannot invoke method substring() on null object
compileSdkVersion is not specified. Please add it to build.gradle

  • 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.
==============================================================================

BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1
`

so, i removed this line

... 25 namespace 'com.benjaminabel.vibration' ...

it is work well build,

Is it okay for me to remove this line?

The project is on Android Gradle Plugin 8.0. You can either upgrade, or remove the namespace if it's not possible to upgrade.

Are you sure @benjamindean ? because on the build.gradle file it is importing this version:

classpath 'com.android.tools.build:gradle:3.5.0'

I am also having the same problem of @30eggis and trying to find a solution

I've fixed by upgrading my gradle to 7.2.2 on my app's build.gradle:

dependencies {
		classpath 'com.android.tools.build:gradle:7.2.2'
}

i solved this issue, it is my fault.

my problem occured after upgrade Flutter version ( to 3.10.0 )

if you face similar this issue, then check your android project

1st step : gradle.wrapper.properties.
maybe you had older gradle version,
(in my case -> distributionUrl=https://services.gradle.org/distributions/gradle-7.2-all.zip)
you should match gradle version to support gradle version of flutter.
(in my case -> distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip)

2nd step : app/build.gradle
buildscript {
ext.kotlin_version = $kotlin_version
dependencies {
classpath 'com.android.tools.build:gradle:$gradle_version'
}
}
also $kotlin_version and $gradle_version fix to match from flutter version

happy coding,

Thank you for your response