Cordova-plugin-facebook4-无法构建离子应用程序

时间:2018-07-03 17:52:56

标签: android facebook cordova ionic-framework cordova-plugins

我正在尝试在android模拟器中构建离子应用程序,但是奇怪的是我无法构建该应用程序。当我运行 ionic cordova运行android 时,构建失败,并出现以下错误:

 symbol:   class GraphRequest
 location: class ConnectPlugin
/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java:761: error: cannot find symbol
    GraphRequest graphRequest = GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken(), graphAction, new GraphRequest.Callback() {
                                                                 ^
 symbol:   variable AccessToken
 location: class ConnectPlugin
/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java:761: error: package GraphRequest does not exist
    GraphRequest graphRequest = GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken(), graphAction, new GraphRequest.Callback() {
                                                                                                                                   ^
/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java:761: error: cannot find symbol
    GraphRequest graphRequest = GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken(), graphAction, new GraphRequest.Callback() {
                                ^
 symbol:   variable GraphRequest
 location: class ConnectPlugin
/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java:810: error: cannot find symbol
    final AccessToken accessToken = AccessToken.getCurrentAccessToken();
          ^
 symbol:   class AccessToken
 location: class ConnectPlugin
/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java:810: error: cannot find symbol
    final AccessToken accessToken = AccessToken.getCurrentAccessToken();
                                    ^
 symbol:   variable AccessToken
 location: class ConnectPlugin
/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java:864: error: cannot find symbol
    if (error instanceof FacebookServiceException) {
                         ^
 symbol:   class FacebookServiceException
 location: class ConnectPlugin
/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java:865: error: cannot find symbol
        return getFacebookRequestErrorResponse(((FacebookServiceException) error).getRequestError());
                                                 ^
 symbol:   class FacebookServiceException
 location: class ConnectPlugin
/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java:870: error: cannot find symbol
    if (error instanceof FacebookDialogException) {
                         ^
 symbol:   class FacebookDialogException
 location: class ConnectPlugin
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.
100 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 6s
at ChildProcess.whenDone (/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
[2K[G(node:13843) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
[2K[G(node:13843) [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.

问题可能出在cordova-plugin-facebook4上,因为当我删除此插件时它可以工作。我遵循了插件页面上的Android指南说明,但不知道如何解决。 有什么办法可以解决并使用此插件吗?

  • 离子:3.20.0
  • 科尔多瓦:8.0.0
  • cordova-plugin-facebook4:2.2.0

1 个答案:

答案 0 :(得分:0)

只需检查一个运行正常的特定版本1.7.4,所以请尝试使用以下命令

ionic cordova plugin add cordova-plugin-facebook4@1.7.4 --variable APP_ID="xxxxx" --variable APP_NAME="XXXX XXXX"