sarriaroman / photoviewer

PhotoViewer Cordova Plugin
MIT License
155 stars 202 forks source link

Build error on android #192

Closed Bart1909 closed 4 years ago

Bart1909 commented 4 years ago

Hi,

I'm getting the following error when building for android with ionic 4:

BUILD FAILED in 9s
/Users/Tobi/ProjectN/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/Tobi/ProjectN/platforms/android/app/src/main/java/com/sarriaroman/PhotoViewer/PhotoActivity.java:25: error: cannot find symbol
import com.squareup.picasso.UrlConnectionDownloader;
                           ^
  symbol:   class UrlConnectionDownloader
  location: package com.squareup.picasso
/Users/Tobi/ProjectN/platforms/android/app/src/main/java/com/sarriaroman/PhotoViewer/PhotoActivity.java:197: error: cannot find symbol
                picasso = Picasso.with(PhotoActivity.this);
                                 ^
  symbol:   method with(PhotoActivity)
  location: class Picasso
/Users/Tobi/ProjectN/platforms/android/app/src/main/java/com/sarriaroman/PhotoViewer/PhotoActivity.java:203: error: <anonymous com.sarriaroman.PhotoViewer.PhotoActivity$3> is not abstract and does not override abstract method onError(Exception) in Callback
                    .into(photo, new com.squareup.picasso.Callback() {
                                                                     ^
/Users/Tobi/ProjectN/platforms/android/app/src/main/java/com/sarriaroman/PhotoViewer/PhotoActivity.java:209: error: method does not override or implement a method from a supertype
                        @Override
                        ^
/Users/Tobi/ProjectN/platforms/android/app/src/main/java/com/sarriaroman/PhotoViewer/PhotoActivity.java:227: error: cannot find symbol
                    Picasso picasso = Picasso.with(PhotoActivity.this);
                                             ^
  symbol:   method with(PhotoActivity)
  location: class Picasso
/Users/Tobi/ProjectN/platforms/android/app/src/main/java/com/sarriaroman/PhotoViewer/PhotoActivity.java:231: error: <anonymous com.sarriaroman.PhotoViewer.PhotoActivity$4$1> is not abstract and does not override abstract method onError(Exception) in Callback
                                .into(photo, new com.squareup.picasso.Callback() {
                                                                                 ^
/Users/Tobi/ProjectN/platforms/android/app/src/main/java/com/sarriaroman/PhotoViewer/PhotoActivity.java:237: error: method does not override or implement a method from a supertype
                                    @Override
                                    ^
/Users/Tobi/ProjectN/platforms/android/app/src/main/java/com/sarriaroman/PhotoViewer/PhotoActivity.java:335: error: cannot find symbol
        builder.downloader(new UrlConnectionDownloader(ctx) {
                               ^
  symbol:   class UrlConnectionDownloader
  location: class PhotoActivity
/Users/Tobi/ProjectN/platforms/android/app/src/main/java/com/sarriaroman/PhotoViewer/PhotoActivity.java:336: error: method does not override or implement a method from a supertype
            @Override
            ^
/Users/Tobi/ProjectN/platforms/android/app/src/main/java/com/sarriaroman/PhotoViewer/PhotoActivity.java:338: error: cannot find symbol
                HttpURLConnection connection = super.openConnection(uri);
                                                    ^
  symbol: method openConnection(Uri)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
10 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 9s
[ERROR] An error occurred while running subprocess cordova.

        cordova build android exited with exit code 1.

I already tried with version 1.1.18 and 1.2.1 but no one works...

Anyone an idea?

JoseGeorges8 commented 4 years ago

Same. Tried 1.18 to .24 and they all give me the same build issue... was working before

RobinGiel commented 4 years ago

Same here, and I also saw that the picasso version is not the latest. As soon as I introduce any push notification plugin I get these errors aswel

chadmilden commented 4 years ago

Same issue with all versions, can we get an update on this? cannot push out our product because of this error.

dhavalsoni2001 commented 4 years ago

Any update on this?

samuelfaj commented 4 years ago

Waiting reply

realsaintsteven commented 4 years ago

Sadly no solution provide yet!

gersonazgo commented 4 years ago

Same prob here. Any updates?

ilyasfoo commented 4 years ago

I think I found something, it seems that gradle is using com.squareup.picasso:picasso version 2.7 instead of 2.5.2 as defined in this repo.

Version 2.7 has breaking changes like the with method changed to get, onError exceptions requires a Throwable parameter, etc.

So far I dont have any clue on why this is happening to gradle, but I suspect that it might have something to do with latest versions of cordova-android, namely > 7

jorisbertomeu commented 4 years ago

Same issue too .. Unable to build my app after gradle update ..

ilyasfoo commented 4 years ago

I have confirmed the cause was having these plugins installed along:

cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter"
cordova-plugin-firebasex 9.0.1 "Google Firebase Plugin"
ilyasfoo commented 4 years ago

As a temporary workaround, I have made a fork of 1.1.8 that works with com.squareup.picasso library version 2.71828.

Please note that this might break anytime, I suspect gradle is pulling picasso's latest release which might contain more breaking change.

Try it and see if it works for you:

ionic cordova plugin rm com-sarriaroman-photoviewer
ionic cordova plugin add https://github.com/ilyasfoo/photoviewer.git
jorisbertomeu commented 4 years ago

Ok guys, i found a temp solution ..

  1. Downgrade photoviewer version ionic cordova plugin rm com-sarriaroman-photoviewer
  2. Install 1.1.18 version ionic cordova plugin add com-sarriaroman-photoviewer@1.1.18
  3. Install patch-package to apply a patch to PhotoActivity.java npm i patch-package -g
  4. Create a folder to root project dir named "patches" mkdir patches
  5. And create this file vi com-sarriaroman-photoviewer+1.1.18.patch
  6. Apply patch patch-package
  7. Remove android platform then reinstall it ionic cordova platform rm android; ionic cordova platform add android
  8. Let's gow ionic cordova prepare android
TdoubleG commented 4 years ago

I created a fork

https://github.com/TdoubleG/photoviewer

Feel free to use this solution as I updated the Picasso Library to the current version.