Search code examples
buildsdkandroid-emulatorapkupgrade

Why does my Flutter application work perfectly on the emulator, but errors occur when building the APK?


I am trying to build an APK and I am getting an error:


Running Gradle task 'assembleRelease'...                        

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_pdfview:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
   > Android resource linking failed
     ERROR:C:\Users\Admin\AndroidStudioProjects\rozdzielnie\build\flutter_pdfview\intermediates\merged_res\release\values\values.xml:132: AAPT: error: resource android:attr/lStar not found.

I expect Android Studio to build an APK that I will transfer to my phone.

In the pubspec.yaml file, I have dependencies:

flutter_pdfview: ^1.2.1. I also tried a newer version, 1.3.0, and the same thing happened.

In the build.gradle I upgraded the SDK version

    compileSdkVersion 33
    minSdkVersion 21
    targetSdkVersion 33

I have previously built an APK with the flutter_pdfview package after upgrading the SDK version to 33. I'm not sure at what point I became unable to build the APK.

I have already tried deleting the .dart_tool directory and running `flutter packages get`.

I have installed the latest version of Android Studio and Flutter.


Solution

  • The library is currently facing an error on its last version (that is 1.3.0).

    I faced the same issue, and fixed it by downgrading my version in the pubspec.yaml with : flutter_pdfview: 1.2.9

    Note : remove the ^ also is important here.