cordova-plugin-facebookads icon indicating copy to clipboard operation
cordova-plugin-facebookads copied to clipboard

Failed to build for android

Open lolaswift opened this issue 7 years ago • 31 comments

FacebookAdPlugin.java:28: error: import requires canonical name for Image

lolaswift avatar Jun 13 '18 09:06 lolaswift

Same error since yesterday (2018-06-12).

`Subproject Path: CordovaLib Subproject Path: app Starting a Gradle Daemon (subsequent builds will be faster) publishNonDefault is deprecated and has no effect anymore. All variants are now published. Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead. The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead. at build_dmzionmq5j4oq3q006j4dla7c.run(/myApp/platforms/android/app/build.gradle:148) :CordovaLib:preBuild UP-TO-DATE :CordovaLib:preReleaseBuild UP-TO-DATE :CordovaLib:compileReleaseAidl :CordovaLib:compileReleaseRenderscript :CordovaLib:checkReleaseManifest :CordovaLib:generateReleaseBuildConfig :CordovaLib:prepareLintJar :CordovaLib:generateReleaseResValues :CordovaLib:generateReleaseResources :CordovaLib:packageReleaseResources :CordovaLib:platformAttrExtractor :CordovaLib:processReleaseManifest :CordovaLib:javaPreCompileRelease :CordovaLib:processReleaseJavaRes NO-SOURCE :app:preBuild UP-TO-DATE :app:preReleaseBuild Download https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml Download https://jcenter.bintray.com/com/facebook/android/audience-network-sdk/maven-metadata.xml Download https://jcenter.bintray.com/com/facebook/android/audience-network-sdk/4.99.0/audience-network-sdk-4.99.0.pom Download https://repo1.maven.org/maven2/com/facebook/android/audience-network-sdk/maven-metadata.xml Download https://jcenter.bintray.com/com/android/support/support-compat/maven-metadata.xml Download https://jcenter.bintray.com/com/android/support/support-media-compat/maven-metadata.xml Download https://jcenter.bintray.com/com/android/support/support-core-utils/maven-metadata.xml Download https://jcenter.bintray.com/com/facebook/android/audience-network-sdk/4.99.0/audience-network-sdk-4.99.0.aar :app:compileReleaseAidl :CordovaLib:packageReleaseRenderscript NO-SOURCE :app:compileReleaseRenderscript :app:checkReleaseManifest :app:generateReleaseBuildConfig :app:prepareLintJar :app:generateReleaseResValues :app:generateReleaseResources :app:mergeReleaseResources :app:createReleaseCompatibleScreenManifests :app:processReleaseManifest :app:splitsDiscoveryTaskRelease :app:compileReleaseNdk NO-SOURCE :CordovaLib:mergeReleaseShaders :CordovaLib:compileReleaseShaders :CordovaLib:generateReleaseAssets :CordovaLib:mergeReleaseAssets :app:mergeReleaseShaders :app:compileReleaseShaders :app:generateReleaseAssets :app:mergeReleaseAssets :CordovaLib:compileReleaseNdk NO-SOURCE :CordovaLib:mergeReleaseJniLibFolders :CordovaLib:transformNativeLibsWithMergeJniLibsForRelease :CordovaLib:transformNativeLibsWithIntermediateJniLibsForRelease :app:mergeReleaseJniLibFolders :app:processReleaseJavaRes NO-SOURCE :CordovaLib:processReleaseResources :CordovaLib:generateReleaseSources :CordovaLib:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.

:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease :app:processReleaseResources :app:generateReleaseSources :app:javaPreCompileRelease :app:compileReleaseJavaWithJavac/myApp/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:28: error: import requires canonical name for Image import com.facebook.ads.NativeAd.Image; ^ /myApp/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:29: error: import requires canonical name for Rating import com.facebook.ads.NativeAd.Rating; ^ /myApp/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:223: error: incompatible types: <anonymous AdListener> cannot be converted to NativeAdListener unit.ad.setAdListener(new AdListener(){ ^ /myApp/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:260: error: cannot find symbol String titleForAd = unit.ad.getAdTitle(); ^ symbol: method getAdTitle() location: variable ad of type NativeAd /myApp/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:265: error: cannot find symbol String textForAdBody = unit.ad.getAdBody(); ^ symbol: method getAdBody() location: variable ad of type NativeAd /myApp/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:286: error: cannot find symbol coverInfo.put("url", coverImage.getUrl()); ^ symbol: method getUrl() location: variable coverImage of type Image /myApp/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:293: error: cannot find symbol iconInfo.put("url", iconForAd.getUrl()); ^ symbol: method getUrl() location: variable iconForAd of type Image /myApp/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:299: error: cannot find symbol adchoiceInfo.put("url", adChoiceIcon.getUrl()); ^ symbol: method getUrl() location: variable adChoiceIcon of type Image /myApp/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:319: error: no suitable method found for registerViewForInteraction(View) unit.ad.registerViewForInteraction(unit.tracking); ^ method NativeAd.registerViewForInteraction(View,MediaView) is not applicable (actual and formal argument lists differ in length) method NativeAd.registerViewForInteraction(View,MediaView,AdIconView) is not applicable (actual and formal argument lists differ in length) method NativeAd.registerViewForInteraction(View,MediaView,List<View>) is not applicable (actual and formal argument lists differ in length) method NativeAd.registerViewForInteraction(View,MediaView,AdIconView,List<View>) is not applicable (actual and formal argument lists differ in length) Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 9 errors FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileReleaseJavaWithJavac'.

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.

  • Get more help at https://help.gradle.org

BUILD FAILED in 28s `

ElieSauveterre avatar Jun 13 '18 14:06 ElieSauveterre

I'm getting the exact same error. Been at it for hours but still no luck

jstncno avatar Jun 14 '18 05:06 jstncno

Error log:

:app:compileDebugJavaWithJavac
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:28: error: import requires canonical name for Image

import com.facebook.ads.NativeAd.Image;
                                ^
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:29: error: import requires canonical name for Rating
import com.facebook.ads.NativeAd.Rating;
                                ^
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:212: error: incompatible types: <anonymous AdListener> cannot be converted to NativeAdListener

            	unit.ad.setAdListener(new AdListener(){
            	                      ^
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:249: error: cannot find symbol
					String titleForAd = unit.ad.getAdTitle();
					                           ^
  symbol:   method getAdTitle()
  location: variable ad of type NativeAd
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:254: error: cannot find symbol
					String textForAdBody = unit.ad.getAdBody();
					                              ^
  symbol:   method getAdBody()
  location: variable ad of type NativeAd
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:275: error: cannot find symbol
                        coverInfo.put("url", coverImage.getUrl());
                                                       ^
  symbol:   method getUrl()
  location: variable coverImage of type Image
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:282: error: cannot find symbol
                        iconInfo.put("url", iconForAd.getUrl());
                                                     ^
  symbol:   method getUrl()
  location: variable iconForAd of type Image
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:296: error: no suitable method found for registerViewForInteraction(View)

                  unit.ad.registerViewForInteraction(unit.tracking);
                         ^
    method NativeAd.registerViewForInteraction(View,MediaView) is not applicable
      (actual and formal argument lists differ in length)
    method NativeAd.registerViewForInteraction(View,MediaView,AdIconView) is not applicable
      (actual and formal argument lists differ in length)
    method NativeAd.registerViewForInteraction(View,MediaView,List<View>) is not applicable
      (actual and formal argument lists differ in length)

    method NativeAd.registerViewForInteraction(View,MediaView,AdIconView,List<View>) is not applicable
      (actual and formal argument lists differ in length)
Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.
Note: /app/platforms/android/app/src/main/java/com/initialxy/cordova/themeablebrowser/ThemeableBrowser.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
8 errors

 FAILED

FAILURE:
Build failed with an exception.

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

* Get more help at https://help.gradle.org


BUILD FAILED in 4s
27 actionable tasks: 3 executed, 24 up-to-date
(node:19267) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /app/platforms/android/gradlew: Command failed with exit code 1 Error output:
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:28: error: import requires canonical name for Image
import com.facebook.ads.NativeAd.Image;
                                ^
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:29: error: import requires canonical name for Rating
import com.facebook.ads.NativeAd.Rating;
                                ^
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:212: error: incompatible types: <anonymous AdListener> cannot be converted to NativeAdListener
            	unit.ad.setAdListener(new AdListener(){
            	                      ^
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:249: error: cannot find symbol
					String titleForAd = unit.ad.getAdTitle();
					                           ^
  symbol:   method getAdTitle()
  location: variable ad of type NativeAd
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:254: error: cannot find symbol
					String textForAdBody = unit.ad.getAdBody();
					                              ^
  symbol:   method getAdBody()
  location: variable ad of type NativeAd
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:275: error: cannot find symbol
                        coverInfo.put("url", coverImage.getUrl());
                                                       ^
  symbol:   method getUrl()
  location: variable coverImage of type Image
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:282: error: cannot find symbol
                        iconInfo.put("url", iconForAd.getUrl());
                                                     ^
  symbol:   method getUrl()
  location: variable iconForAd of type Image
/app/platforms/android/app/src/main/java/com/rjfun/cordova/facebookads/FacebookAdPlugin.java:296: error: no suitable method found for registerViewForInteraction(View)
                  unit.ad.registerViewForInteraction(unit.tracking);
                         ^
    method NativeAd.registerViewForInteraction(View,MediaView) is not applicable
      (actual and formal argument lists differ in length)
    method NativeAd.registerViewForInteraction(View,MediaView,AdIconView) is not applicable
      (actual and formal argument lists differ in length)
    method NativeAd.registerViewForInteraction(View,MediaView,List<View>) is not applicable
      (actual and formal argument lists differ in length)
    method NativeAd.registerViewForInteraction(View,MediaView,AdIconView,List<View>) is not applicable
      (actual and formal argument lists differ in length)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /app/platforms/android/app/src/main/java/com/initialxy/cordova/themeablebrowser/ThemeableBrowser.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
8 errors

FAILURE: Build failed with an exception.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
(node:19267) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

jstncno avatar Jun 14 '18 05:06 jstncno

Facebook has released a new version of the Audience Network Android SDK on June 12, 2018.

My workaround for now is to roll back to the previous version in my build.gradle file, from:

dependencies {
    ...
    compile "com.facebook.android:audience-network-sdk:4.+"
    ...
}

to:

dependencies {
    ...
    compile "com.facebook.android:audience-network-sdk:4.28.2"
    ...
}

jstncno avatar Jun 14 '18 06:06 jstncno

not done

vietnux avatar Jun 14 '18 07:06 vietnux

Thank you @earthican for finding the solution.

I made a fork of cordova-plugin-facebookads and of cordova-facebook-audnet-sdk which is the one who specify the version of the audience-network-sdk.

ElieSauveterre avatar Jun 18 '18 00:06 ElieSauveterre

help please, I'm getting the exact same error on PGB

moresharecorp avatar Jun 21 '18 07:06 moresharecorp

Hi, Thank you @earthican and @ElieSauveterre . Once I updated the version code as you mentioned I am not getting any error but ad is not displaying. For me banner and interstitial ad should display. In log I am getting "ad display" but in device nothing is showing. Please let me know if you have any pointers.

Talking for Android.

Thank you.

mrbankim avatar Jun 22 '18 20:06 mrbankim

I'm also seeing this suddenly fail to build on PGB with <plugin name="cordova-plugin-facebookads" version="4.23.2"/>. @floatinghotpot - if the workaround above is good, can it be incorporated and npm version updated for us PBG users?

blukis avatar Jun 25 '18 11:06 blukis

I have the same problem. I can not build android for this same reason. But I didn't understand the solution. Did you solve this? Please tell me solution clearly

halkoy avatar Jul 05 '18 23:07 halkoy

How to build this plugin with android? I can not solve the problem. The build error is the same that mentioned above. I need it urgently @floatinghotpot

halkoy avatar Jul 07 '18 19:07 halkoy

@halkoy You can use the fork I made => cordova-plugin-facebookads

ElieSauveterre avatar Jul 07 '18 23:07 ElieSauveterre

Does the the fork work? will it show facebook ads? @ElieSauveterre

Olofu avatar Jul 08 '18 12:07 Olofu

@Olofu It's working for me with native ads.

ElieSauveterre avatar Jul 08 '18 23:07 ElieSauveterre

@ElieSauveterre How can we use yours? I think I added it with ionic cordova plugin add ElieSauveterre/cordova-plugin-facebookads (i don't know if it is correct). Now my app runs but I'm getting this error: error: FacebookAds is not defined (I already added this line declare var FacebookAds: any; in my home.ts file).

IvanLencina avatar Jul 18 '18 04:07 IvanLencina

@IvanLencina You can install from a github url

ionic cordova plugin add https://github.com/ElieSauveterre/cordova-plugin-facebookads

You can also use a specific commit

ionic cordova plugin add https://github.com/ElieSauveterre/cordova-plugin-facebookads#d540140816f93ee37ebef8cf5b05e438db17588a

ElieSauveterre avatar Jul 18 '18 11:07 ElieSauveterre

@ElieSauveterre Thank you!

IvanLencina avatar Jul 18 '18 13:07 IvanLencina

@IvanLencina is it work with you if yes ! how can i do it with phonegap build @ElieSauveterre

wearta avatar Aug 04 '18 14:08 wearta

@wearta for phonegap build (and even cordova-proper?) replace this in your config.xml: <plugin name="cordova-plugin-facebookads" version="4.23.2"/> with this: <plugin name="cordova-plugin-facebookads" version="4.23.2" spec="https://github.com/ElieSauveterre/cordova-plugin-facebookads"/>

blukis avatar Aug 04 '18 14:08 blukis

I have the same problem , when I tried your solution I got an error adds loaded to frequently I'm using phone gap

hodaifa82 avatar Sep 15 '18 17:09 hodaifa82

its giving ads loaded to frequently in banner any suggesion

hodaifa82 avatar Sep 15 '18 17:09 hodaifa82

@mrbankim did you solve it?

hodaifa82 avatar Sep 16 '18 18:09 hodaifa82

@mrbankim did you solve it?

hodaifa82 avatar Sep 16 '18 18:09 hodaifa82

@floatinghotpot this is still an issue, and won't build in PhoneGap build. Is there an ETA for a fix?

The above mentioned fork now has a app-startup-crash very similar to this one https://github.com/sunnycupertino/cordova-plugin-admob-simple/issues/38 - so I'm out of workarounds for this plugin, again. Thanks!

blukis avatar Oct 07 '18 19:10 blukis

@ElieSauveterre I'm still getting the same build errors with your version. Anything changed?

bartzy avatar Oct 20 '18 17:10 bartzy

Any fix for this? The modified plugin doesn't work either

Vivek-abstract avatar Nov 21 '18 16:11 Vivek-abstract

      Any fix for this? The modified plugin doesn't work either

Did you find any fix Vivek?

hashmoody avatar Nov 24 '18 07:11 hashmoody

Not yet. The plugin doesn't build on Android. I just switched to using banner and interstitial ads using admobs

Vivek-abstract avatar Nov 24 '18 12:11 Vivek-abstract

      Not yet. The plugin doesn't build on Android. I just switched to using banner and interstitial ads using admobs

Strange. Looks like a monopoly move from Google. No-other publisher plugins are able to work/perform good.

So the last resort, move to Admob.

hashmoody avatar Nov 24 '18 12:11 hashmoody

facebook now not supporting 4.28.2 if you have 4.28.2 sdk for new apps will not show ads. anyone have fix ?? @floatinghotpot please fix and @ElieSauveterre any update from your side ?

zeeshan12312 avatar Dec 02 '18 06:12 zeeshan12312