Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can no longer compile in Cordova 5.0.0 on Android #535

Closed
cvoisey opened this issue May 4, 2015 · 30 comments
Closed

Can no longer compile in Cordova 5.0.0 on Android #535

cvoisey opened this issue May 4, 2015 · 30 comments

Comments

@cvoisey
Copy link

cvoisey commented May 4, 2015

Is anyone else experiencing this issue? I saw some previous posts that mentioned that the location of the files in Android have moved, however this appears to be a problem with Cordova 5.0.0.

Here is my specific error:
myDir/platforms/android/src/de/appplant/cordova/plugin/localnotification/LocalNotification.java:495: error: cannot find symbol
webView.evaluateJavascript(js, null);
^
symbol: method evaluateJavascript(String,)
location: variable webView of type CordovaWebView
myDir/platforms/android/src/de/appplant/cordova/plugin/localnotification/LocalNotification.java:492: error: cannot find symbol
webView.post(new Runnable(){
^
symbol: method post()
location: variable webView of type CordovaWebView
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: myDir/platforms/android/src/org/apache/cordova/file/ContentFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
:compileDebugJava FAILED

@rocketfarmsteinar
Copy link

I also experience this error.

It seems that the methods post(...) and evaluateJavascript(...) are removed from the Cordova 5.0.0 CordovaWebView, and that Katzer's local notification plugin hasn't been updated to reflect these changes.

@rocketfarmsteinar
Copy link

Quick fix is to modify the block starting at LocalNotification:492 with the following:

webView.getView().post(new Runnable(){
  public void run(){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      webView.sendJavascript(js);
    } else {
      webView.loadUrl("javascript:" + js);
    }
  }
});

@seth100
Copy link

seth100 commented May 6, 2015

+1 for a fix please

@cvoisey
Copy link
Author

cvoisey commented May 6, 2015

The above changed recommended by nlinksteinar worked for me! I modified this and then re-added the Android plugin to my project and it compiled.

@cvoisey cvoisey closed this as completed May 6, 2015
@cvoisey
Copy link
Author

cvoisey commented May 6, 2015

NOTE: I am not comfortable modifying the code within this project to make the change permanently for others. Perhaps someone could do that??

jonasflament added a commit to jonasflament/cordova-plugin-local-notifications that referenced this issue May 8, 2015
@Honry
Copy link

Honry commented May 17, 2015

hi, all
I also reproduce this issue, and find this fix is still under review, can anyone help merged it? Would be very appreciate!

@netronicus
Copy link

i tried to compile my code with and without crosswalk plugin with no success, i have cordova 5.0.0 and android 4.0.0, y apply the solution proposed by nlinksteinar and i can compile with no problem :D, i modified the code inside the plugin on android project, not on the root (cordova project) c:

@mix3d
Copy link

mix3d commented May 19, 2015

I too am experiencing the webView.evaluateJavascript issue on cordova 5.0, and the fix helps.

@ankitbtanna
Copy link

webView.getView().post(new Runnable(){
public void run(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.sendJavascript(js);
} else {
webView.loadUrl("javascript:" + js);
}
}
});

This fix by nlinksteinar helped.

@sharifbdp
Copy link

+1 @nlinksteinar

@jtomaszewski
Copy link

+1 @nlinksteinar 's snippet

ttiurani added a commit to extendedmind/cordova-plugin-local-notifications that referenced this issue Jun 4, 2015
@cagb80
Copy link

cagb80 commented Jun 4, 2015

+1 for nlinksteinar... that solve the problem!!! My best...!

@biapar
Copy link

biapar commented Jun 14, 2015

Error with Cordova 5

@seth100
Copy link

seth100 commented Jun 28, 2015

@katzer could you please add the @nlinksteinar 's snippet?
Because at the moment I always have to manually edit LocalNotification.java files.
Thanks

@ghost
Copy link

ghost commented Jun 29, 2015

+1 @nlinksteinar 's snippet .
Thank you, nlinksteinar! you save my life brother...
Have good day!

@cagb80
Copy link

cagb80 commented Jun 29, 2015

Hi the @nlinksteinar's manual patch work in this way:

When we try to build Android Cordova App, some errors will marked.
Must search the files with the error, search the code line with the error and replace with @nlinksteinar code:

webView.getView().post(new Runnable(){
public void run(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.sendJavascript(js);
} else {
webView.loadUrl("javascript:" + js);
}
}
});

This fix 4 apps that I am creating.
TY again to @nlinksteinar for share it.

My Best!

@HNygard
Copy link

HNygard commented Jul 16, 2015

+1

@artdias90
Copy link

+1 for nlinksteinar

@helsont
Copy link

helsont commented Jul 30, 2015

+1 for nlinksteinar, and be sure that your editing the right file.

@seth100
Copy link

seth100 commented Jul 31, 2015

+1

1 similar comment
@AliGonabadi
Copy link

+1

@mix3d
Copy link

mix3d commented Aug 12, 2015

If you look at the latest commit, @nlinksteinar 's suggestions have been merged into master. This should be closed.

@fgarzonhz
Copy link

In 8.1 continue the error, we fixed with @nlinksteinar 's suggestions. Please add in the next release.

@murliatdure
Copy link

    webView.post(new Runnable(){
           ^

symbol: method post()
location: variable webView of type CordovaWebView
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.
2 errors
:compileDebugJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':compileDebugJava'.

    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.

BUILD FAILED

@sungwoncho
Copy link

Thanks @nlinksteinar. Using webView.loadUrl("javascript:" + myCode); and it works.

@homer-jay
Copy link

I'm sorry I'm a bit lost here. I understand that the evaluateJavascript method has been removed and therefore the need to fall back to sendJavascript. But then why are you keeping the Build.VERSION check? It is no longer needed!

ttiurani added a commit to extendedmind/cordova-plugin-local-notifications that referenced this issue Mar 19, 2016
Catch exception

Removed duplicate setting of lights

Use alpha channel 0 to prevent led from displaying

Try to also remove light blink timeout to prevent notification

Don't use default sound when sound is set to false

Quick fix from katzer#535

Fixed problems with notification plugin dependency namings. Removed smaller than 4.0.0 engine requirement

Attempted fix from katzer#495 to prevent notifications from firing again on boot.

Fixed adding local notification crashing app on iOS 9. Tested also that with this fix, iOS 8 also still works.
ttiurani added a commit to extendedmind/cordova-plugin-local-notifications that referenced this issue Mar 19, 2016
Catch exception

Removed duplicate setting of lights

Use alpha channel 0 to prevent led from displaying

Try to also remove light blink timeout to prevent notification

Don't use default sound when sound is set to false

Quick fix from katzer#535

Fixed problems with notification plugin dependency namings. Removed smaller than 4.0.0 engine requirement

Attempted fix from katzer#495 to prevent notifications from firing again on boot.

Fixed adding local notification crashing app on iOS 9. Tested also that with this fix, iOS 8 also still works.
@sdurandeu
Copy link

This is still failing for me on Cordova 6. Is there reliable fork I can use with the fix? Or shall I create my own?

Thanks!!

@cagb80
Copy link

cagb80 commented Sep 15, 2016

@sdurandeu Now there is a new upgrade for this plugin. Use the next one: https://www.npmjs.com/package/phonegap-plugin-push

@sdurandeu
Copy link

sdurandeu commented Sep 15, 2016

@cagb80 Thanks! My understanding was that phonegap-plugin-push could only receive external notifications. Is it possible to send local notifications with it?

Just in case it helps anyone reading, my issue was that the version in NPM of the plugin is quite outdated. Installing it from this repo worked as expected.

@Dinesh0405
Copy link

I want Local Notification when app is closed 0r killed but i am getting some problem with webView Can you Please any one help on this ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests