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

far*_*ran 6 android cordova picasso ionic-framework

我正在尝试使用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
Run Code Online (Sandbox Code Playgroud)

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 {

}
Run Code Online (Sandbox Code Playgroud)

因此错误

    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.
Run Code Online (Sandbox Code Playgroud)

May*_*ain 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
Run Code Online (Sandbox Code Playgroud)

构建它会工作

cordova build android 

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

BUILD SUCCESSFUL in 32s
46 actionable tasks: 46 executed
Run Code Online (Sandbox Code Playgroud)

如果这仍然给你带来与之前相同的错误,请尝试删除android平台一次并再次添加,

$ cordova platform rm android

$ cordova platform add android
Run Code Online (Sandbox Code Playgroud)