由于找不到符号 picasso.fit(),无法构建apk。

7

我正在尝试使用cordova build android命令构建APK文件,但在构建过程中发生了错误,因此无法生成构建文件。这个问题与PICASSO库有关。以下是所有相关细节信息:Ionic 信息:

 Ionic:
 ionic (Ionic CLI) : 4.8.0 (/usr/lib/node_modules/ionic)
 Ionic Framework   : ionic1 1.3.1
 @ionic/v1-toolkit : not installed
 Cordova:
 cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
 Cordova Platforms     : android 6.4.0
 Cordova Plugins       : cordova-plugin-ionic-webview 1.2.1, (and 19 
 other plugins)

 System:

 Android SDK Tools : 26.1.1 (/home/user/Android/Sdk)
 NodeJS            : v8.11.3 (/usr/bin/node)
 npm               : 5.6.0
 OS                : Linux 4.15

platforms/android/com-sarriaroman-photoviewer/abc123photoviewer.gradle文件中有以下代码

repositories{
jcenter()
}
dependencies {
implementaion 'com.commit451:PhotoView:1.2.4'
implementaion 'com.squareup.picasso:picasso:2.5.2'
}
android {

}

因此发生了错误。
    BUILD FAILED in 3s
38 actionable tasks: 36 executed, 2 up-to-date
/var/www/projects/ionic_practice/test/app_mobile_new/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/var/www/projects/ionic_practice/test/app_mobile_new/platforms/android/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:171: error: cannot find symbol
            picasso.fit();
                   ^
  symbol:   method fit()
  location: variable picasso of type Picasso
/var/www/projects/ionic_practice/test/app_mobile_new/platforms/android/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:175: error: cannot find symbol
            picasso.centerInside();
                   ^
  symbol:   method centerInside()
  location: variable picasso of type Picasso
/var/www/projects/ionic_practice/test/app_mobile_new/platforms/android/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:179: error: cannot find symbol
            picasso.centerCrop();
                   ^
  symbol:   method centerCrop()
  location: variable picasso of type Picasso
/var/www/projects/ionic_practice/test/app_mobile_new/platforms/android/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:200: error: cannot find symbol
                    .into(photo, new com.squareup.picasso.Callback() {
                    ^
  symbol:   method into(ImageView,<anonymous Callback>)
  location: class Picasso
/var/www/projects/ionic_practice/test/app_mobile_new/platforms/android/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:224: error: cannot find symbol
                    Piccasso picasso = Picasso.with(PhotoActivity.this)
                    ^
  symbol: class Piccasso
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.
5 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':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.

可能只是一个简单的打错字吧?Piccasso picasso = Picasso.. 应该只有一个 "c" (Picasso)。 - Kaddath
我会说同样的话,检查拼写。如果不是这个问题,那么我唯一能猜测的就是希望它没有被正确实现。但拼写错误是最有可能的原因。 - Vahalaru
@Vahalaru 我已经更改为 Picasso picasso = Picasso.with(PhotoActivity.this),但错误仍然存在。以下是当前的错误: error: incompatible types: RequestCreator cannot be converted to Picasso .load(mTempImage); @Kaddath - faran
我其实不知道 Picasso 是什么,也不知道如何在 Ionic 中实现它,只是看到了一个似乎是笔误的地方。你可能需要添加代码以便其他人可以帮助(我们无法看到 RequestCreatorPicasso.load 被调用的位置)。 - Kaddath
3个回答

12

这是插件版本1.20的问题。

您可以使用1.1.18版本,它可以正常运行。

以下是如何切换到1.1.18版本。

$ ionic cordova plugin rm com-sarriaroman-photoviewer
$ ionic cordova plugin add com-sarriaroman-photoviewer@1.1.18

建造它,它就会运行

cordova build android 

...
...
...
:app:transformResourcesWithMergeJavaResForDebug
:app:packageDebug
:app:assembleDebug
:app:cdvBuildDebug

BUILD SUCCESSFUL in 32s
46 actionable tasks: 46 executed

如果仍然出现与之前相同的错误,请尝试先移除 Android 平台,再重新添加它。

$ cordova platform rm android

$ cordova platform add android

通过运行上述命令,我能够生成APK文件。感谢您指出了确切的解决方案。photoviewer的正确版本是1.1.18。 谢谢,祝好。 - faran
我尝试了,但由于声望不足而无法接受。现在我该怎么办?@Mayank R Jain - faran
你好!一旦插件被移除,我们是否还需要使用“npm uninstall --save @ionic-native/photo-viewer”来卸载它? - variable
解决方案对我有效。1. 移除插件;2. 添加插件 @1.1.18;3. 移除平台;4. 添加平台; - variable
有人尝试过v1.2.1吗?也许问题已经解决了... - Josem

1

确认插件版本1.20的问题已在最新版本1.2.4中解决。

以下是如何升级到最新版本:

$ ionic cordova plugin rm com-sarriaroman-photoviewer
$ ionic cordova plugin add com-sarriaroman-photoviewer

0

版本1.2.5解决了这个问题

ionic cordova plugin rm com-sarriaroman-photoviewer
ionic cordova plugin add com-sarriaroman-photoviewer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接