com.phonegap.plugins.facebookconnect 和 phonegap-plugin-push 不能一起工作
com.phonegap.plugins.facebookconnect and phonegap-plugin-push not working together
我正在构建新的 Cordova 应用程序,无法使 com.phonegap.plugins.facebookconnect
和 phonegap-plugin-push
插件一起工作。
这里是 cordova run
输出:
:com.phonegap.plugins.facebookconnect:FacebookLib:compileLint
:com.phonegap.plugins.facebookconnect:FacebookLib:copyDebugLint UP-TO-DATE
:com.phonegap.plugins.facebookconnect:FacebookLib:mergeDebugProguardFiles
:com.phonegap.plugins.facebookconnect:FacebookLib:preBuild
:com.phonegap.plugins.facebookconnect:FacebookLib:preDebugBuild
:com.phonegap.plugins.facebookconnect:FacebookLib:checkDebugManifest
:com.phonegap.plugins.facebookconnect:FacebookLib:preDebugTestBuild
:com.phonegap.plugins.facebookconnect:FacebookLib:prepareAndroidCordovaLibUnspecifiedDebugLibrary
:com.phonegap.plugins.facebookconnect:FacebookLib:prepareDebugDependencies
:com.phonegap.plugins.facebookconnect:FacebookLib:compileDebugAidl
:com.phonegap.plugins.facebookconnect:FacebookLib:compileDebugRenderscript
:com.phonegap.plugins.facebookconnect:FacebookLib:generateDebugBuildConfig
:com.phonegap.plugins.facebookconnect:FacebookLib:generateDebugAssets UP-TO-DATE
:com.phonegap.plugins.facebookconnect:FacebookLib:mergeDebugAssets
:com.phonegap.plugins.facebookconnect:FacebookLib:generateDebugResValues
:com.phonegap.plugins.facebookconnect:FacebookLib:generateDebugResources
:com.phonegap.plugins.facebookconnect:FacebookLib:mergeDebugResources
:com.phonegap.plugins.facebookconnect:FacebookLib:processDebugManifest
:com.phonegap.plugins.facebookconnect:FacebookLib:processDebugResources
:com.phonegap.plugins.facebookconnect:FacebookLib:generateDebugSources
:com.phonegap.plugins.facebookconnect:FacebookLib:compileDebugJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:com.phonegap.plugins.facebookconnect:FacebookLib:processDebugJavaRes UP-TO-DATE
:com.phonegap.plugins.facebookconnect:FacebookLib:packageDebugJar
:com.phonegap.plugins.facebookconnect:FacebookLib:compileDebugNdk
:com.phonegap.plugins.facebookconnect:FacebookLib:packageDebugJniLibs UP-TO-DATE
:com.phonegap.plugins.facebookconnect:FacebookLib:packageDebugLocalJar
:com.phonegap.plugins.facebookconnect:FacebookLib:packageDebugRenderscript UP-TO-DATE
:com.phonegap.plugins.facebookconnect:FacebookLib:packageDebugResources
:com.phonegap.plugins.facebookconnect:FacebookLib:bundleDebug
:prepareAndroidComPhonegapPluginsFacebookconnectFacebookLibUnspecifiedDebugLibrary
:prepareAndroidCordovaLibUnspecifiedDebugLibrary
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:compileDebugJava
C:\workspace\myApp\platforms\android\src\com\adobe\phonegap\push\GCMIntentService.java:390: error: cannot find symbol
mBuilder.setColor(iconColor);
^
symbol: method setColor(int)
location: variable mBuilder of type Builder
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.
1 error
: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
Total time: 27.011 secs
c:\workspace\myApp\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "c:\workspace\myApp\platforms\android\gradlew cdvBuildDebug -b c:\workspace\myApp\platforms\android\build.gradle -PcdvBuildArch=arm
-Dorg.gradle.daemon=true"
ERROR running one or more of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to run this project
来自 https://github.com/phonegap/phonegap-plugin-push/issues/51 我了解到 facebookconnect
使用 android-support-v4.jar
与 phonegap-plugin-push
的 android-support-v13.jar
冲突。
我已按照建议尝试 remove/replace android-support-v*.jar
但这无济于事。
科尔多瓦版本:5.2.0
phonegap-plugin-push 版本:1.2.0
com.phonegap.plugins.facebookconnect版本:0.11.0
一种方法是通过安装推送插件来解决问题:cordova-plugin-push-notification
,因为它也使用 android-support-v4.jar
。 Link 到此版本的 documentation。
运行 安装命令:
cordova plugin add cordova-plugin-push-notification
更新
此解决方案不适用于最新的 com.phonegap.plugins.facebookconnect
插件。
我用 cordova-plugin-facebook4 fork 替换了 Facebook 插件。它使用 v4 Android 库并且与 phonegap-plugin-push
插件不冲突。
终于在其他论坛的一些帮助下,我能够让它工作!
这是我所做的:
- 移除
\plugins\com.phonegap.plugins.facebookconnect\platforms\android\FacebookLib\libs\android-support-v4.jar
文件
- 将
\plugins\phonegap-plugin-push\src\android\libs\android-support-v13.jar
文件复制到\plugins\com.phonegap.plugins.facebookconnect\platforms\android\FacebookLib\libs\
- 在文本编辑器中打开
\plugins\com.phonegap.plugins.facebookconnect\platforms\android\FacebookLib\build.gradle
文件(使用 Notepad++ 或任何其他新行友好的编辑器)
在依赖块下,将 support-v4
替换为 support-v13
。它应该是这样的:
dependencies {
compile 'com.android.support:support-v13:[20,21)'
compile 'com.parse.bolts:bolts-android:1.1.2'
}
删除\platforms\android\build\
文件夹并用cordova build
编译项目
所有路径都与 Cordova 项目的根相关。
我正在构建新的 Cordova 应用程序,无法使 com.phonegap.plugins.facebookconnect
和 phonegap-plugin-push
插件一起工作。
这里是 cordova run
输出:
:com.phonegap.plugins.facebookconnect:FacebookLib:compileLint
:com.phonegap.plugins.facebookconnect:FacebookLib:copyDebugLint UP-TO-DATE
:com.phonegap.plugins.facebookconnect:FacebookLib:mergeDebugProguardFiles
:com.phonegap.plugins.facebookconnect:FacebookLib:preBuild
:com.phonegap.plugins.facebookconnect:FacebookLib:preDebugBuild
:com.phonegap.plugins.facebookconnect:FacebookLib:checkDebugManifest
:com.phonegap.plugins.facebookconnect:FacebookLib:preDebugTestBuild
:com.phonegap.plugins.facebookconnect:FacebookLib:prepareAndroidCordovaLibUnspecifiedDebugLibrary
:com.phonegap.plugins.facebookconnect:FacebookLib:prepareDebugDependencies
:com.phonegap.plugins.facebookconnect:FacebookLib:compileDebugAidl
:com.phonegap.plugins.facebookconnect:FacebookLib:compileDebugRenderscript
:com.phonegap.plugins.facebookconnect:FacebookLib:generateDebugBuildConfig
:com.phonegap.plugins.facebookconnect:FacebookLib:generateDebugAssets UP-TO-DATE
:com.phonegap.plugins.facebookconnect:FacebookLib:mergeDebugAssets
:com.phonegap.plugins.facebookconnect:FacebookLib:generateDebugResValues
:com.phonegap.plugins.facebookconnect:FacebookLib:generateDebugResources
:com.phonegap.plugins.facebookconnect:FacebookLib:mergeDebugResources
:com.phonegap.plugins.facebookconnect:FacebookLib:processDebugManifest
:com.phonegap.plugins.facebookconnect:FacebookLib:processDebugResources
:com.phonegap.plugins.facebookconnect:FacebookLib:generateDebugSources
:com.phonegap.plugins.facebookconnect:FacebookLib:compileDebugJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:com.phonegap.plugins.facebookconnect:FacebookLib:processDebugJavaRes UP-TO-DATE
:com.phonegap.plugins.facebookconnect:FacebookLib:packageDebugJar
:com.phonegap.plugins.facebookconnect:FacebookLib:compileDebugNdk
:com.phonegap.plugins.facebookconnect:FacebookLib:packageDebugJniLibs UP-TO-DATE
:com.phonegap.plugins.facebookconnect:FacebookLib:packageDebugLocalJar
:com.phonegap.plugins.facebookconnect:FacebookLib:packageDebugRenderscript UP-TO-DATE
:com.phonegap.plugins.facebookconnect:FacebookLib:packageDebugResources
:com.phonegap.plugins.facebookconnect:FacebookLib:bundleDebug
:prepareAndroidComPhonegapPluginsFacebookconnectFacebookLibUnspecifiedDebugLibrary
:prepareAndroidCordovaLibUnspecifiedDebugLibrary
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:compileDebugJava
C:\workspace\myApp\platforms\android\src\com\adobe\phonegap\push\GCMIntentService.java:390: error: cannot find symbol
mBuilder.setColor(iconColor);
^
symbol: method setColor(int)
location: variable mBuilder of type Builder
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.
1 error
: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
Total time: 27.011 secs
c:\workspace\myApp\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "c:\workspace\myApp\platforms\android\gradlew cdvBuildDebug -b c:\workspace\myApp\platforms\android\build.gradle -PcdvBuildArch=arm
-Dorg.gradle.daemon=true"
ERROR running one or more of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to run this project
来自 https://github.com/phonegap/phonegap-plugin-push/issues/51 我了解到 facebookconnect
使用 android-support-v4.jar
与 phonegap-plugin-push
的 android-support-v13.jar
冲突。
我已按照建议尝试 remove/replace android-support-v*.jar
但这无济于事。
科尔多瓦版本:5.2.0
phonegap-plugin-push 版本:1.2.0
com.phonegap.plugins.facebookconnect版本:0.11.0
一种方法是通过安装推送插件来解决问题:cordova-plugin-push-notification
,因为它也使用 android-support-v4.jar
。 Link 到此版本的 documentation。
运行 安装命令:
cordova plugin add cordova-plugin-push-notification
更新
此解决方案不适用于最新的 com.phonegap.plugins.facebookconnect
插件。
我用 cordova-plugin-facebook4 fork 替换了 Facebook 插件。它使用 v4 Android 库并且与 phonegap-plugin-push
插件不冲突。
终于在其他论坛的一些帮助下,我能够让它工作!
这是我所做的:
- 移除
\plugins\com.phonegap.plugins.facebookconnect\platforms\android\FacebookLib\libs\android-support-v4.jar
文件 - 将
\plugins\phonegap-plugin-push\src\android\libs\android-support-v13.jar
文件复制到\plugins\com.phonegap.plugins.facebookconnect\platforms\android\FacebookLib\libs\
- 在文本编辑器中打开
\plugins\com.phonegap.plugins.facebookconnect\platforms\android\FacebookLib\build.gradle
文件(使用 Notepad++ 或任何其他新行友好的编辑器) 在依赖块下,将
support-v4
替换为support-v13
。它应该是这样的:dependencies { compile 'com.android.support:support-v13:[20,21)' compile 'com.parse.bolts:bolts-android:1.1.2' }
删除
\platforms\android\build\
文件夹并用cordova build
编译项目
所有路径都与 Cordova 项目的根相关。