Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to build apk due to cannot find symbol picasso.fit();

I am trying to build APK with cordova build android command but error occured during build and build can't be generated. The error is with PICASSO library. Please find all the relevant details below. Ionic info:

 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 ([email protected])
 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 has following code

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

}

Hence the error

    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.
like image 469
faran Avatar asked Jan 24 '19 08:01

faran


2 Answers

That's an issue with the version 1.20 of the plugin.

You can use 1.1.18 and it works well with that.

Here is how to move to 1.1.18

$ ionic cordova plugin rm com-sarriaroman-photoviewer
$ ionic cordova plugin add [email protected]

Build and it will work

cordova build android 

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

BUILD SUCCESSFUL in 32s
46 actionable tasks: 46 executed

If this still gives you the same error as earlier, try removing the android platform once and adding it again,

$ cordova platform rm android

$ cordova platform add android
like image 174
Mayank R Jain Avatar answered Nov 14 '22 22:11

Mayank R Jain


This is to confirm that the issue with the version 1.20 of the plugin is solved on the latest version : 1.2.4

Here is how to move to the latest

$ ionic cordova plugin rm com-sarriaroman-photoviewer
$ ionic cordova plugin add com-sarriaroman-photoviewer
like image 39
p90n33r Avatar answered Nov 15 '22 00:11

p90n33r