[英]How to fix Ionic Photo Viewer gradle compiler error?
So I wasted so many hours trying to simply add the photoviewer to my ionic angular app.所以我浪费了很多时间试图将照片查看器简单地添加到我的 ionic angular 应用程序中。
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.由于 rxjs 版本,我仅仅安装它就遇到了很多问题。 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
然后我运行
ionic build; npx cap sync android; npx cap open android
ionic build; npx cap sync android; npx cap open android
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. ionic build; npx cap sync android; npx cap open android
因为在浏览器上抱怨我正在使用 cordova 本机组件并且无法使用它。 That's fine, my phone should be able to handle it.没关系,我的手机应该可以处理它。 However when android studio is building the gradle it throws this
然而,当 android 工作室正在构建 gradle 时,它会抛出这个
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.
13:55 Gradle 同步失败:无法在 org.gradle.api.internal.artifacts.dslDependency.dependency.dependency.dependency.object 上找到 arguments [com.commit451:PhotoView:1.2.4] 的方法编译() (16 s 923 ms)
(16 秒 923 毫秒)
What am I missing?我错过了什么? It shouldn't be this hard to add a simple photo viewer!
添加一个简单的照片查看器应该不难!
There is nothing in the "official page" “官方页面”中没有任何内容
Ok, finally figured this out.好的,终于想通了。 So my gradle is up to date but it seems the com-sarriaroman module isn't.
所以我的 gradle 是最新的,但 com-sarriaroman 模块似乎不是。 In its "photoviewer.gradle" file, it had
在它的“photoviewer.gradle”文件中,它有
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.这是 gradle 构建器的新版本无法读取的。 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.
我知道我不应该搞乱 node_modules 中的任何东西。
The issue is in photoviewer.gradle file of the com-sarriaroman-photoviewer plugin.问题出在 com-sarriaroman-photoviewer 插件的 photoviewer.gradle 文件中。
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您可以在https://www.youtube.com/watch?v=q_FknLrJ_Kg&t=67s上的 PhotoViewer 上观看我的演示
问题未解决?试试以下方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.