Home > Mobile >  How to fix Ionic Photo Viewer gradle compiler error?
How to fix Ionic Photo Viewer gradle compiler error?

Time:01-31

So I wasted so many hours trying to simply add the photoviewer to my ionic angular app.

The steps seems simple.

$ npm install --save @ionic-native/core
$ npm install com-sarriaroman-photoviewer (this way cause I am using capacitor)
$ npm install --save @ionic-native/photo-viewer

I faced so many problems simply installing it because of the rxjs version. Whatever, that supposedly got resolved without having to use the force option. Then I run ionic build; npx cap sync android; npx cap open android because on the browser complains that I am using a cordova native component and can't work it. That's fine, my phone should be able to handle it. However when android studio is building the gradle it throws this

13:55 Gradle sync failed: Could not find method compile() for arguments [com.commit451:PhotoView:1.2.4] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. (16 s 923 ms)

What am I missing? It shouldn't be this hard to add a simple photo viewer!

There is nothing in the "official page"

CodePudding user response:

Ok, finally figured this out. So my gradle is up to date but it seems the com-sarriaroman module isn't. In its "photoviewer.gradle" file, it had

dependencies {
   compile 'com.commit451:PhotoView:1.2.4'
   compile 'com.squareup.picasso:picasso:2.71828'
}

which is unreadable by the new version of the gradle builder. I replaced "compile" with "implementation" and it worked. However, someone needs to let them know and update their module. I know I shouldn't be the one messing with anything in node_modules.

CodePudding user response:

The issue is in photoviewer.gradle file of the com-sarriaroman-photoviewer plugin.

Need to change the code to

dependencies {
   implementation 'com.commit451:PhotoView:1.2.4'
   implementation 'com.squareup.picasso:picasso:2.71828'
}

You can watch my demo on PhotoViewer at https://www.youtube.com/watch?v=q_FknLrJ_Kg&t=67s

  • Related