acoutts / flutter_libphonenumber

Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps. Includes a TextInputFormatter to allow real-time AsYouType formatting.
MIT License
60 stars 73 forks source link

Resource android:attr/lStar not found #78

Open ne3Vubeki opened 2 months ago

ne3Vubeki commented 2 months ago

When trying to build an application on the new version of Flutter 3.24.0 on Android, the build crashes:

* What went wrong:
Execution failed for task ':flutter_libphonenumber_android:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
   > Android resource linking failed
     ERROR:/Users/xxx/Work/Xxx/build/flutter_libphonenumber_android/intermediates/merged_res/release/values/values.xml:194: AAPT: error: resource android:attr/lStar not found.

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.0, on macOS 14.5 23F79 darwin-arm64 (Rosetta), locale ru-RU)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/macos-android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.91.1)
[✓] Connected device (5 available)
[✓] Network resources
aleexbt commented 2 months ago

Same problem here

venomanse commented 2 months ago

Hello, I am experiencing same issue. The project runs in debug mode, but i unable to build profile and release.

Here is gradle configuration:

gradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

build.gradle:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id "com.google.gms.google-services"
    id "com.google.firebase.crashlytics"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    compileSdkVersion 34
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).

        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 24
        targetSdkVersion 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
        release {
  }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation(platform("com.google.firebase:firebase-bom:32.7.0"))
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
}

settings.gradle:

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.4.2" apply false
    id "org.jetbrains.kotlin.android" version "1.9.20" apply false
    id "com.google.gms.google-services" version "4.4.1" apply false
    id "com.google.firebase.crashlytics" version "2.9.9" apply false
}

include ":app"

flutter doctor -v:

[✓] Flutter (Channel stable, 3.24.0, on macOS 14.6.1 23G93 darwin-arm64, locale en-UA)
    • Flutter version 3.24.0 on channel stable at /Users/oleksandrkrinickyi/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 80c2e84975 (13 days ago), 2024-07-30 23:06:49 +0700
    • Engine revision b8800d88be
    • Dart version 3.5.0
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/oleksandrkrinickyi/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/oleksandrkrinickyi/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2024.1)
    • 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.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.91.1)
    • VS Code at /Users/oleksandrkrinickyi/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.94.0

[✓] Connected device (5 available)
    • Hindenburg (mobile)             • 00008020-001A35D23C30003A            • ios            •
      iOS 17.6.1 21G93
    • iPhone 15 Pro Max (mobile)      • 760538B9-38FF-4C7C-B42E-83F436178715 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   •
      macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         •
      macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript •
      Google Chrome 127.0.6533.100

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

• No issues found!

Error message:

> * What went wrong:
> Execution failed for task ':flutter_libphonenumber_android:verifyProfileResources'.
> > A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
>    > Android resource linking failed
>      ERROR:/Users/.../app_client/build/flutter_libphonenumber_android/intermediates/merged_res/profile/values/values.xml:194: AAPT: error: resource android:attr/lStar not found.

BUILD FAILED in 57s
Running Gradle task 'assembleProfile'...                           58.6s
Error: Gradle task assembleProfile failed with exit code 1
#0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1      AndroidGradleBuilder.buildGradleApp
(package:flutter_tools/src/android/gradle.dart:500:9)
<asynchronous suspension>
#2      AndroidGradleBuilder.buildApk (package:flutter_tools/src/android/gradle.dart:224:5)
<asynchronous suspension>
#3      AndroidDevice.startApp (package:flutter_tools/src/android/android_device.dart:584:7)
<asynchronous suspension>
#4      FlutterDevice.runCold (package:flutter_tools/src/resident_runner.dart:534:33)
<asynchronous suspension>
#5      ColdRunner.run (package:flutter_tools/src/run_cold.dart:55:28)
<asynchronous suspension>
#6      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:867:27)
<asynchronous suspension>
#7      FlutterCommand.run.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command.dart:1408:27)
<asynchronous suspension>
#8      AppContext.run.<anonymous closure>
(package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#10     FlutterCommandRunner.runCommand.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command_runner.dart:420:9)
<asynchronous suspension>
#11     AppContext.run.<anonymous closure>
(package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#12     FlutterCommandRunner.runCommand
(package:flutter_tools/src/runner/flutter_command_runner.dart:364:5)
<asynchronous suspension>
#13     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:130:9)
<asynchronous suspension>
#14     AppContext.run.<anonymous closure>
(package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#15     main (package:flutter_tools/executable.dart:93:3)
<asynchronous suspension>
ne3Vubeki commented 2 months ago

If I change flutter_libphonenumber_android in build.gradle compileSdkVersion 29 => 31, the build is successful. But I don't want to fork((

acoutts commented 2 months ago

can you please try again on v2.3.1?

MFerraz commented 2 months ago

I was facing this issue and upgrading to v2.3.1 solved it.