我在 Applicaion.onCreate 中的代码。应用程序在 UAirship.takeoff(this,options); 处崩溃 请帮忙。
public class LiveVideoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(this);
// Optionally, customize your config at runtime:
//
options.inProduction = false;
options.developmentAppKey = "key.. ";
options.developmentAppSecret = "secret..";
UAirship.takeOff(this, options);
PushManager.shared().setIntentReceiver(IntentReceiver.class);
Logger.logLevel = Log.VERBOSE;
//use CustomPushNotificationBuilder to specify a custom layout
CustomPushNotificationBuilder nb = new CustomPushNotificationBuilder();
nb.statusBarIconDrawableId = R.drawable.icon_small;//custom status bar icon
//
nb.layout = R.layout.notification;
nb.layoutIconDrawableId = R.drawable.icon;//custom layout icon
nb.layoutIconId = R.id.icon;
nb.layoutSubjectId = R.id.subject;
nb.layoutMessageId = R.id.message;
// customize the sound played when a push is received
nb.soundUri = Uri.parse("android.resource://"+this.getPackageName()+"/" +R.raw.cat);
PushManager.shared().setNotificationBuilder(nb);
PushManager.shared().setIntentReceiver(IntentReceiver.class);
}
}
异常日志:
03-15 00:25:37.106: E/AndroidRuntime(2920): FATAL EXCEPTION: main
03-15 00:25:37.106: E/AndroidRuntime(2920): java.lang.RuntimeException: Unable to create application com.LiveVideoApplication: java.lang.IllegalArgumentException: Application configuration is invalid.
03-15 00:25:37.106: E/AndroidRuntime(2920): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3275)
03-15 00:25:37.106: E/AndroidRuntime(2920): at android.app.ActivityThread.access$2200(ActivityThread.java:117)
03-15 00:25:37.106: E/AndroidRuntime(2920): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
03-15 00:25:37.106: E/AndroidRuntime(2920): at android.os.Handler.dispatchMessage(Handler.java:99)
03-15 00:25:37.106: E/AndroidRuntime(2920): at android.os.Looper.loop(Looper.java:123)
03-15 00:25:37.106: E/AndroidRuntime(2920): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-15 00:25:37.106: E/AndroidRuntime(2920): at java.lang.reflect.Method.invokeNative(Native Method)
03-15 00:25:37.106: E/AndroidRuntime(2920): at java.lang.reflect.Method.invoke(Method.java:507)
03-15 00:25:37.106: E/AndroidRuntime(2920): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-15 00:25:37.106: E/AndroidRuntime(2920): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-15 00:25:37.106: E/AndroidRuntime(2920): at dalvik.system.NativeStart.main(Native Method)
03-15 00:25:37.106: E/AndroidRuntime(2920): Caused by: java.lang.IllegalArgumentException: Application configuration is invalid.
03-15 00:25:37.106: E/AndroidRuntime(2920): at com.urbanairship.UAirship.takeOff(Unknown Source)
03-15 00:25:37.106: E/AndroidRuntime(2920): at com.LiveVideoApplication.onCreate(LiveVideoApplication.java:27)
03-15 00:25:37.106: E/AndroidRuntime(2920): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
03-15 00:25:37.106: E/AndroidRuntime(2920): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3272)
最佳答案
我也遇到过这个问题,我解决了。我会建议您确保您已经在 UrbanAirship 上创建了一个应用程序,其中包含与您的应用程序相同的应用程序包。还要确保您的 key 和 secret 是正确的。
IllegalArgumentException 当 developmentAppKey 和 developmentAppSecret 错误时抛出。或者 key 和密码正确但您的远程 Urban Airship 测试应用程序具有不同的应用程序包集。 p>
关于android - Urban Airship 在起飞时坠毁。非法参数异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9708885/
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
我有一些Ruby代码,如下所示:Something.createdo|x|x.foo=barend我想编写一个测试,它使用double代替block参数x,这样我就可以调用:x_double.should_receive(:foo).with("whatever").这可能吗? 最佳答案 specify'something'dox=doublex.should_receive(:foo=).with("whatever")Something.should_receive(:create).and_yield(x)#callthere
我正在为一个项目制作一个简单的shell,我希望像在Bash中一样解析参数字符串。foobar"helloworld"fooz应该变成:["foo","bar","helloworld","fooz"]等等。到目前为止,我一直在使用CSV::parse_line,将列分隔符设置为""和.compact输出。问题是我现在必须选择是要支持单引号还是双引号。CSV不支持超过一个分隔符。Python有一个名为shlex的模块:>>>shlex.split("Test'helloworld'foo")['Test','helloworld','foo']>>>shlex.split('Test"
我不确定传递给方法的对象的类型是否正确。我可能会将一个字符串传递给一个只能处理整数的函数。某种运行时保证怎么样?我看不到比以下更好的选择:defsomeFixNumMangler(input)raise"wrongtype:integerrequired"unlessinput.class==FixNumother_stuffend有更好的选择吗? 最佳答案 使用Kernel#Integer在使用之前转换输入的方法。当无法以任何合理的方式将输入转换为整数时,它将引发ArgumentError。defmy_method(number)
两者都可以defsetup(options={})options.reverse_merge:size=>25,:velocity=>10end和defsetup(options={}){:size=>25,:velocity=>10}.merge(options)end在方法的参数中分配默认值。问题是:哪个更好?您更愿意使用哪一个?在性能、代码可读性或其他方面有什么不同吗?编辑:我无意中添加了bang(!)...并不是要询问nobang方法与bang方法之间的区别 最佳答案 我倾向于使用reverse_merge方法:option
我正在学习Rails,并阅读了关于乐观锁的内容。我已将类型为integer的lock_version列添加到我的articles表中。但现在每当我第一次尝试更新记录时,我都会收到StaleObjectError异常。这是我的迁移:classAddLockVersionToArticle当我尝试通过Rails控制台更新文章时:article=Article.first=>#我这样做:article.title="newtitle"article.save我明白了:(0.3ms)begintransaction(0.3ms)UPDATE"articles"SET"title"='dwdwd
在Cooper的书BeginningRuby中,第166页有一个我无法重现的示例。classSongincludeComparableattr_accessor:lengthdef(other)@lengthother.lengthenddefinitialize(song_name,length)@song_name=song_name@length=lengthendenda=Song.new('Rockaroundtheclock',143)b=Song.new('BohemianRhapsody',544)c=Song.new('MinuteWaltz',60)a.betwee
我有一个只接受一个参数的方法:defmy_method(number)end如果使用number调用方法,我该如何引发错误??通常,我如何定义方法参数的条件?比如我想在调用的时候报错:my_method(1) 最佳答案 您可以添加guard在函数的开头,如果参数无效则引发异常。例如:defmy_method(number)failArgumentError,"Inputshouldbegreaterthanorequalto2"ifnumbereputse.messageend#=>Inputshouldbegreaterthano
我早就知道Ruby中的“常量”(即大写的变量名)不是真正常量。与其他编程语言一样,对对象的引用是唯一存储在变量/常量中的东西。(侧边栏:Ruby确实具有“卡住”引用对象不被修改的功能,据我所知,许多其他语言都没有提供这种功能。)所以这是我的问题:当您将一个值重新分配给常量时,您会收到如下警告:>>FOO='bar'=>"bar">>FOO='baz'(irb):2:warning:alreadyinitializedconstantFOO=>"baz"有没有办法强制Ruby抛出异常而不是打印警告?很难弄清楚为什么有时会发生重新分配。 最佳答案
我没有找到太多关于如何执行此操作的信息,尽管有很多关于如何使用像这样的redirect_to将参数传递给重定向的建议:action=>'something',:controller=>'something'在我的应用程序中,我在路由文件中有以下内容match'profile'=>'User#show'我的表演Action是这样的defshow@user=User.find(params[:user])@title=@user.first_nameend重定向发生在同一个用户Controller中,就像这样defregister@title="Registration"@user=Use