由于找不到符号picasso.fit();

时间:2019-01-24 08:08:49

标签: android cordova ionic-framework picasso

我正在尝试使用cordova build android命令构建APK,但是在构建过程中发生错误,并且无法生成构建。该错误与PICASSO库有关。请在下面找到所有相关详细信息。 离子信息:

 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.

3 个答案:

答案 0 :(得分:11)

这是插件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

答案 1 :(得分:1)

这是为了确认插件1.20版的问题已在最新版本1.2.4上解决了

这是如何升级到最新版本

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

答案 2 :(得分:0)

版本1.2.5解决了此问题

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