- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
首先:我使用 Cordova 3.4 构建 Android 应用程序,但是当我安装 PushWoosh 来推送通知时,我面临构建错误。
1- 我安装了 PushWoosh:
cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-3.0-plugin.git
2- PushWoosh 代码:
function init() {
document.addEventListener("deviceready", initPushwoosh, true);
//rest of the code
}
function initPushwoosh()
{
var pushNotification = window.plugins.pushNotification;
//set push notifications handler
document.addEventListener('push-notification', function(event) {
var title = event.notification.title;
var userData = event.notification.userdata;
if (typeof (userData) !== "undefined") {
console.warn('user data: ' + JSON.stringify(userData));
}
navigator.notification.alert(title);
});
//initialize Pushwoosh with projectid: "GOOGLE_PROJECT_ID", appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
pushNotification.onDeviceReady({projectid: "Google_Project_Number", appid: "ID_Of-PushWoosh"});
//register for pushes
pushNotification.registerDevice(
function(status) {
var pushToken = status;
console.warn('push token: ' + pushToken);
},
function(status) {
console.warn(JSON.stringify(['failed to register ', status]));
}
);
}
</script>
3- 构建项目时使用:cordova build android
cordova build android -d
cordova library for "android" already exists. No need to download. Continuing.
Generating config.xml from defaults for platform "android"
Calling plugman.prepare for platform "android"
Preparing android project
Processing configuration changes for plugins.
Iterating over installed plugins: [ 'org.apache.cordova.device',
'org.apache.cordova.console',
'org.apache.cordova.camera',
'org.apache.cordova.geolocation',
'org.apache.cordova.vibration',
'org.apache.cordova.splashscreen',
'org.apache.cordova.media-capture',
'org.apache.cordova.file-transfer',
'org.apache.cordova.battery-status',
'org.apache.cordova.contacts',
'org.apache.cordova.media',
'org.apache.cordova.network-information',
'org.apache.cordova.globalization',
'org.apache.cordova.device-motion',
'org.apache.cordova.dialogs',
'org.apache.cordova.device-orientation',
'de.appplant.cordova.plugin.background-mode',
'com.phonegap.plugins.PushPlugin',
'com.pushwoosh.plugins.pushwoosh',
'org.apache.cordova.file' ]
Writing out cordova_plugins.js...
Wrote out Android application name to "Insurance"
Wrote out Android package name to "com.coolappz.Insurance"
Running command: /Users/newaccount/projects/Insurance/platforms/android/cordova/build
Buildfile: /Users/newaccount/projects/Insurance/platforms/android/build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.3.0
[checkenv] Installed at /Users/newaccount/opt/android-sdk
-setup:
[echo] Project Name: Insurance
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.1
[echo] Resolving Build Target for Insurance...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[echo] ----------
[echo] Resolving Dependencies for Insurance...
[dependency] Library dependencies:
[dependency]
[dependency] ------------------
[dependency] Ordered libraries:
[dependency]
[dependency] ------------------
[echo] ----------
[echo] Building Libraries with 'debug'...
nodeps:
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.3.0
[checkenv] Installed at /Users/newaccount/opt/android-sdk
-setup:
[echo] Project Name: CordovaLib
[gettype] Project Type: Android Library
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.1
[echo] Resolving Build Target for CordovaLib...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[echo] ----------
[echo] Resolving Dependencies for CordovaLib...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] No changed resources. R.java and Manifest.java untouched.
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.
-pre-compile:
-compile:
[echo] Creating library output jar file...
-post-compile:
-obfuscate:
-dex:
[echo] Library project: do not convert bytecode...
-crunch:
[crunch] Crunching PNG Files in source dir: /Users/newaccount/projects/Insurance/platforms/android/CordovaLib/res
[crunch] To destination dir: /Users/newaccount/projects/Insurance/platforms/android/CordovaLib/ant-build/res
[crunch] Crunched 0 PNG files to update cache
-package-resources:
[echo] Library project: do not package resources...
-package:
[echo] Library project: do not package apk...
-post-package:
-do-debug:
[echo] Library project: do not create apk...
[propertyfile] Updating property file: /Users/newaccount/projects/Insurance/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /Users/newaccount/projects/Insurance/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /Users/newaccount/projects/Insurance/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /Users/newaccount/projects/Insurance/platforms/android/CordovaLib/ant-build/build.prop
-post-build:
debug:
-code-gen:
[mergemanifest] Found modified input file
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Found modified input file
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.
-pre-compile:
[echo] Set jars path to: /Users/newaccount/projects/Insurance/platforms/android/CordovaLib/ant- build/classes.jar:/Users/newaccount/projects/Insurance/platforms/android/libs/gcm.jar:/Users/n ewaccount/projects/Insurance/platforms/android/libs/android-support- v13.jar:/Users/newaccount/projects/Insurance/platforms/android/libs/Pushwoosh.jar
-compile:
[javac] Compiling 3 source files to /Users/newaccount/projects/Insurance/platforms/android/ant-build/classes
-post-compile:
-obfuscate:
-dex:
[dex] input: /Users/newaccount/projects/Insurance/platforms/android/ant-build/classes
[dex] input: /Users/newaccount/projects/Insurance/platforms/android/CordovaLib/ant- build/classes.jar
[dex] input: /Users/newaccount/projects/Insurance/platforms/android/libs/gcm.jar
[dex] input: /Users/newaccount/projects/Insurance/platforms/android/libs/android-support-v13.jar
[dex] input: /Users/newaccount/projects/Insurance/platforms/android/libs/Pushwoosh.jar
[dex] Using Pre-Dexed classes-e368cee6db5bb9478a5a486c3a854124.jar <- /Users/newaccount/projects/Insurance/platforms/android/CordovaLib/ant-build/classes.jar
[dex] Using Pre-Dexed gcm-e0369832eeefafff8956756cd54fc4fc.jar <- /Users/newaccount/projects/Insurance/platforms/android/libs/gcm.jar
[dex] Using Pre-Dexed android-support-v13-38130f7a5981a081f33db833ecedaa4f.jar <- /Users/newaccount/projects/Insurance/platforms/android/libs/android-support-v13.jar
[dex] Using Pre-Dexed Pushwoosh-1f9e6f24e222422f2432a7f4365495c2.jar <- /Users/newaccount/projects/Insurance/platforms/android/libs/Pushwoosh.jar
[dex] Found modified input file
[dex] Converting compiled files and external libraries into /Users/newaccount/projects/Insurance/platforms/android/ant-build/classes.dex...
[dx] Merged dex A (124 defs/201.5KiB) with dex B (205 defs/312.8KiB). Result is 329 defs/628.5KiB. Took 0.5s
[dx] Merged dex A (329 defs/628.5KiB) with dex B (4 defs/18.7KiB). Result is 333 defs/826.4KiB. Took 0.2s
[dx] Merged dex A (333 defs/826.4KiB) with dex B (324 defs/359.0KiB). Result is 657 defs/1582.4KiB. Took 0.2s
[dx]
[dx] UNEXPECTED TOP-LEVEL EXCEPTION:
[dx] com.android.dex.DexException: Multiple dex files define Lcom/google/android/gcm/GCMBaseIntentService;
[dx] at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
[dx] at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
[dx] at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
[dx] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
[dx] at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
[dx] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
[dx] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
[dx] at com.android.dx.command.dexer.Main.run(Main.java:230)
[dx] at com.android.dx.command.dexer.Main.main(Main.java:199)
[dx] at com.android.dx.command.Main.main(Main.java:103)
[dx]
BUILD FAILED
/Users/newaccount/opt/android-sdk/tools/ant/build.xml:892: The following error occurred while executing this line:
/Users/newaccount/opt/android-sdk/tools/ant/build.xml:894: The following error occurred while executing this line:
/Users/newaccount/opt/android-sdk/tools/ant/build.xml:906: The following error occurred while executing this line:
/Users/newaccount/opt/android-sdk/tools/ant/build.xml:284: null returned: 2
Total time: 17 seconds
Error code 1 for command: ant with args: debug,- f,/Users/newaccount/projects/Insurance/platforms/android/build.xml,-Dout.dir=ant-build,- Dgen.absolute.dir=ant-gen
Command finished with error code 2: /Users/newaccount/projects/Insurance/platforms/android/cordova/build
Error: /Users/newaccount/projects/Insurance/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/src/superspawn.js:126:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
第二个问题:使用 Cordova 或 PHP,如何将通知推送到安装了此应用程序但未广播的特定设备?
最佳答案
首先你不需要:com.phonegap.plugins.PushPlugin
。是的,这也是上述错误的原因。
如果您没有收到通知,请执行以下简单检查:
免责声明:我是 Pushwoosh 团队的一员。
关于php - 使用 cordova 3.4 和 pushwoosh 构建 android 应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23766773/
This question already has an answer here: Character constant too long for it's type (1个答案) 1年前关闭。 我是
每次我执行 Scala 程序时,Eclipse 都会创建一个新的“运行配置”。这样做的问题是我需要自定义默认的运行配置(需要更改工作路径)。因此,我第一次创建和自定义运行配置时一切正常,但任何后续尝试
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 5 年前。 Improv
基本上我正在做的是创建一个充当启动器的 swing 应用程序。它所做的只是为用户提供了 3 个选项,他们可以从中选择打开一个新的 java 应用程序。 3 个不同的 java 应用程序都有不同的主题,
这个问题已经有答案了: Make a py2exe exe run without a console? (2 个回答) 已关闭 9 年前。 我不希望在打开 python 应用程序时在后台打开 cmd
我曾经尝试编译一个我为国际象棋游戏编写的 C 程序(感谢 YouTube 的 Bluefever Software 提供的教程),但是当我去编译该程序时,我执行了这行代码: C:\TDM-GCC-64
这是一段代码,通过从一个文件获取输入并在另一个文件中给出输出来执行数字的平方。 #include #include void main() { FILE *fp1, *fp2; char
#include using namespace std; class foo { private: static int cnt; // number in memory stat
我做了一个简单的 hello world 程序。我单击“开始调试”,窗口显示“项目已过期。您要构建它吗?”当我单击"is"时,下一个窗口显示“存在构建错误。您要继续并运行上次成功的构建吗?”。我再次选
这是一个程序,有人在其中输入密码并尝试三次猜密码。当我编译它时,我遇到了多个错误,其中一个包括第 13 行,它基本上说它找不到包含在 Password_Program 类中的类似函数。 #includ
我想将我的游戏导出到 .jar 文件中。它导出;当我运行它时,框架出现了,但面板没有加载。我的框架和面板位于两个不同的类文件中,但我认为这没有什么区别。而且,它在 Eclipse 中完全可以工作。我在
我粘贴了程序以从 codenameone 开发人员指南中创建一个按钮,并且我在 netbeans 中使用了该代码,但是当我单击“运行”时,它在模拟器中没有显示任何内容 最佳答案 您删除了 hi.sho
当我执行这个程序时,它并没有终止。 例如,如果我给它输入 A,输出将是: 65 7 1000001 0 65 7 1000001 ... 我的代码: #include #include void
考虑下面的基本客户端和服务器程序(只是骨架/说明我的问题)。客户端启动与服务器的连接,提示用户输入消息,然后发送到服务器并打印到屏幕。 如果我在循环中间突然退出客户端程序(例如通过关闭终端窗口),有时
我运行一个非常简单的单线程 Java 程序。当我在 Ubuntu 下使用命令检查线程时 ps -eLf 它显示操作系统级别有 14 个线程。我希望当程序有一个线程时只有一个线程,如果程序有 x 个线程
当我从命令行运行类似以下内容的代码时,真正发生了什么? > scala hello.scala 是否有hello.class生成,执行然后丢弃?还是在这种情况下Scala表现得像翻译一样?我只是在想,
程序正在从网络摄像机接收以字节为单位的图像数据,然后处理图像。程序第一次启动时使用470Mb RAM,每1秒增加到15Mb,一直持续到没有足够的空间而计算机挂起。 方法 getImage() 每 10
当我运行我的 selenium 程序时,它显示错误,如何解决这个问题? import org.openqa.selenium.By; public class sss { public sta
我写了一个简单的程序,试图查看内存中的变化,但没有任何变化。无论我是否运行代码,总是会出现大约 20% 左右的直线水平线。 #include using namespace std; int main
我是 c/c++ 领域的新手,我已经在虚拟机上沉迷太久了。 我正在修改我们在整个公司使用的现有 C++ 工具。该工具正在所有主要操作系统(Windows、Mac、Ubuntu、Solaris 等)上使
我是一名优秀的程序员,十分优秀!