binSaed / flutter_cached_pdfview

Enhanced PDF view for Flutter.
https://pub.dev/packages/flutter_cached_pdfview
MIT License
121 stars 70 forks source link

Fails to build for Android. #71

Open tomtitherington opened 2 years ago

tomtitherington commented 2 years ago

Describe the bug Flutter build for Android fails with a Gradle task exception.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.github.barteksc:android-pdf-viewer:3.2.0-beta.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/github/barteksc/android-pdf-viewer/3.2.0-beta.1/android-pdf-viewer-3.2.0-beta.1.pom
       - https://repo.maven.apache.org/maven2/com/github/barteksc/android-pdf-viewer/3.2.0-beta.1/android-pdf-viewer-3.2.0-beta.1.pom
       - https://storage.googleapis.com/download.flutter.io/com/github/barteksc/android-pdf-viewer/3.2.0-beta.1/android-pdf-viewer-3.2.0-beta.1.pom
     Required by:
         project :app > project :flutter_pdfview

* 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 5s
Running Gradle task 'assembleDebug'...                              6.2s
Exception: Gradle task assembleDebug failed with exit code 1

To Reproduce Steps to reproduce the behaviour: flutter build

Expected behaviour Project builds.

Smartphone (please complete the following information):

Additional Information flutter doctor -v

[✓] Flutter (Channel stable, 2.5.3, on Mac OS X 10.14.6 18G6032 darwin-x64, locale en-GB)
    • Flutter version 2.5.3 at /usr/local/Caskroom/flutter/2.5.3/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (3 months ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/tom_titherington/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    ✗ Flutter requires a minimum Xcode version of 12.0.1.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.10.0

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

[✓] Android Studio (version 2020.3)
    • 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 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.63.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 (2 available)
    • ONEPLUS A6003 (mobile) • 4a058905 • android-arm64  • Android 10 (API 29)
    • Chrome (web)           • chrome   • web-javascript • Google Chrome 97.0.4692.99

! Doctor found issues in 1 category.
salvatoremiccio commented 2 years ago

Same problem, but i noticed that the problem is with something in the package dependencies, because if i use an old version of my code it works fine but when i do in terminal "flutter pub update" with the latest update already installed (0.4.1) then the problem comes out.

binSaed commented 2 years ago

@RomjanHossain @salvatoremiccio @tomtitherington

This issue is coming from another package please try this solution and let me know

https://github.com/endigo/flutter_pdfview/issues/168#issuecomment-1017104214

salvatoremiccio commented 2 years ago

@RomjanHossain @salvatoremiccio @tomtitherington

This issue is coming from another package please try this solution and let me know

endigo/flutter_pdfview#168 (comment)

I tried and doesn't work for me

verkit commented 2 years ago

I have same issue. You can reproduce this error by creating a new project using flutter 2.10

verkit commented 2 years ago

You can do this step to solve this problem

open build.gradle on android/app directory change your compileSdkVersion

compileSdkVersion 31

open build.gradle on android directory

buildscript {
    ext.kotlin_version = '1.5.31' // change this kotlin version
    repositories {
        google()
        jcenter() // add this line
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.0' // change this version to 4.2.0
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        // add below code
        jcenter()
        maven {        
            url "http://jcenter.bintray.com/"
        }
    }
}

open file android/gradle/wrapper/gradle-wrapper.properties

change distributionUrl to

distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
memishood commented 2 years ago

The 100% solution is; add to jCenter() to your android root build.gradle file

 repositories {
        google()
        mavenCentral()
        jcenter() // here
    }
allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // and here
    }
}
RomjanHossain commented 2 years ago

Thanks a Lot, @memishood ! your solution worked!

salvatoremiccio commented 2 years ago

I confirm, @memishood's solution works. Great job man ;-)

salvatoremiccio commented 2 years ago

@memishood's solution olso works without other instructions of @Jigneshiosdeveloper's solution. For example i use 'com.android.tools.build:gradle:7.0.2' and not 4.2.0 and works without iusses.