我的视图中有一个文本字段,当文本字段在文本字段上发生变化时,我有一个if语句,所以当某个关键字在textview中时,会运行一些代码.这是我的if语句代码:
if (text1.equals("rotate")) {
red.setRotation(red.getRotation() + 5);
blue.setRotation(blue.getRotation() + 5);
}
Run Code Online (Sandbox Code Playgroud)
但是当text1等于'rotate'并运行此代码时,应用程序将崩溃.
这是日志猫:
我无法在任何iPhone和iPad上重现这个问题,所有构建在Debug,Release甚至与iTunes一起安装的ad-hoc构建的工作都很好.这是已有应用的更新.从以前版本添加的唯一内容是使用Azure通知中心的通知和版本检查.我正在使用最新版本的Xamarin iOS来创建应用程序
支持的体系结构是ARMv7 + ARM64
我试过了:
崩溃日志的一部分在这里,但我不能做任何事情
Incident Identifier: 533700FF-EE1C-4DFC-AFAD-60FE3600B66D
CrashReporter Key: 9cadde5ef1a33ebb1b6aeeaed6696a7ce8b4087d
Hardware Model: xxx
Process: TapNOrder [9390]
Path: /private/var/mobile/Containers/Bundle/Application/45780C57-DBB0-465C-872F-8A3BE6723261/TapNOrder.app/TapNOrder
Identifier: biz.innovative-ideas.tapnorder
Version: 0.1.7.2 (0.1.7)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2016-01-11 15:00:11.11 -0800
Launch Time: 2016-01-11 15:00:11.11 -0800
OS Version: iOS 9.2 (13C75)
Report Version: 105
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 …Run Code Online (Sandbox Code Playgroud) 当用户点击此聊天头时,我有一个服务就像一个带有聊天头的叠加层(如Facebook Messenger),我弹出一个MapView(v2)
它适用于我的大多数用户,但在错误报告中,所有小米小米Redmi Note 3用户均具有相同的崩溃
java.lang.RuntimeException:无法创建服务com.package.MyService:java.lang.NullPointerException:尝试在null上调用虚拟方法“ android.content.res.Configuration android.content.res.Resources.getConfiguration()” android.app.ActivityThread.handleCreateService(ActivityThread.java)上的对象引用android.app.ActivityThread $ H.handleMessage(ActivityThread.java)上的android.app.ActivityThread.access $ 1800(ActivityThread.java)上的对象Java上的.dispatchMessage(Handler.java)在android.os.Looper.loop(Looper.java)在android.app.ActivityThread.main(ActivityThread.java)在java.lang.reflect.Method.invoke(本机方法)在Java。 com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java)的com.android.internal.os.ZygoteInit的lang.reflect.Method.invoke(Method.java:372)。main(ZygoteInit.java)原因:java.lang.NullPointerException:尝试在android.view上的空对象引用上调用虚拟方法'android.content.res.Configuration android.content.res.Resources.getConfiguration()'。 android.view.SurfaceView。(SurfaceView.java)在maps.Vx(未知源)在maps.Vv(未知源)在maps.Dv(未知源)在maps.Dva(未知)来源)位于maps.ad.ae.a(未知来源),位于maps.ad.ua(未知来源),位于maps.ad.Ra(未知来源),位于wc.onTransact(:com.google.android.gms.DynamiteModulesB: 66),位于com.google.android.gms.maps.ae $ a $ aa(android.os.Binder.transact(Binder.java)),位于com.google.android.gms.maps.MapView $ aa(未知源) com.google.android.gms.dynamic.ea上的未知源)(com.google.android.gms上的未知源)。com.google.android.gms.maps.MapView $ bg上的dynamic.ca(未知源)com.google.android上com.google.android.gms.maps.MapView $ ba(未知源)上的bg(未知源)。 com.google.android.gms.dynamic.ba(未知源)的com.google.android.gms.maps.MapView.a(未知源)的gms.dynamic.ba(未知源)
似乎失败的代码在这里
this.setTheme(R.style.AppTheme);
this.myView = LayoutInflater.from(this).inflate(R.layout.my_map, null);
this.mapView = (MapView) myView.findViewById(R.id.map);
this.mapView.onCreate(null);
this.mapView.getMapAsync(this);
Run Code Online (Sandbox Code Playgroud)
引发此错误的行是
this.mapView.getMapAsync(this);
有人对此有解决方案吗?
没有文本时,应用程序崩溃!我没有什么可以解决的!谢谢
enter TextView TotalTextView;
EditText EnterPercentage;
EditText EnterPrice;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TotalTextView = (TextView) findViewById(R.id.TotalTextView);
EnterPercentage = (EditText) findViewById(R.id.EnterPercentage);
EnterPrice = (EditText) findViewById(R.id.EnterPrice);
Button CalcBtn = (Button) findViewById(R.id.CalcBtn);
CalcBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
float percentage = Float.parseFloat(EnterPercentage.getText().toString());
float prix = Float.parseFloat(EnterPrice.getText().toString());
float dec = percentage / 100;
float total = prix - dec * Float.parseFloat(EnterPrice.getText().toString());
TotalTextView.setText(String.format("%.2f", total));
}
});
Run Code Online (Sandbox Code Playgroud)
感谢您的回答,我是初学者,所以...谢谢!
if (EnterPercentage.getText().equals("")) {
float percentage = Float.parseFloat(EnterPercentage.getText().toString());
float prix = Float.parseFloat(EnterPrice.getText().toString()); …Run Code Online (Sandbox Code Playgroud) 如标题中所述,Logstash一旦启动便崩溃。
我正在通过Docker运行它。
这是我的输出:
logstash_1 | {:timestamp=>"2016-10-25T13:14:31.470000+0000", :message=>"Reading config file", :config_file=>"/etc/logstash/conf.d/logstash.conf", :level=>:debug, :file=>"logstash/config/loader.rb", :line=>"69", :method=>"local_config"}
logstash_1 | {:timestamp=>"2016-10-25T13:14:31.570000+0000", :message=>"Plugin not defined in namespace, checking for plugin file", :type=>"output", :name=>"stdout", :path=>"logstash/outputs/stdout", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"86", :method=>"lookup"}
logstash_1 | {:timestamp=>"2016-10-25T13:14:31.584000+0000", :message=>"starting agent", :level=>:info, :file=>"logstash/agent.rb", :line=>"213", :method=>"execute"}
logstash_1 | {:timestamp=>"2016-10-25T13:14:31.585000+0000", :message=>"starting pipeline", :id=>"main", :level=>:info, :file=>"logstash/agent.rb", :line=>"487", :method=>"start_pipeline"}
logstash_1 | {:timestamp=>"2016-10-25T13:14:31.606000+0000", :message=>"Plugin not defined in namespace, checking for plugin file", :type=>"codec", :name=>"rubydebug", :path=>"logstash/codecs/rubydebug", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"86", :method=>"lookup"}
logstash_1 | {:timestamp=>"2016-10-25T13:14:31.632000+0000", :message=>"config LogStash::Codecs::RubyDebug/@metadata = false", :level=>:debug, :file=>"logstash/config/mixin.rb", …Run Code Online (Sandbox Code Playgroud) package com.example.khatrimann.notification;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
NotificationCompat.Builder b = new NotificationCompat.Builder(this);
b.setTicker("khatrimann")
.setContentTitle("Default notification")
.setContentText("Hey There.")
.setContentIntent(contentIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, b.build());
}
}
Run Code Online (Sandbox Code Playgroud)
此代码在marshmallow上进行测试,它崩溃并且无法正常工作.
android.support.v4和v7,两个都是逐个尝试然后应用程序崩溃.
LOGCAT如下:
11-20 18:24:59.623 4146-4146/com.example.khatrimann.notification E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.khatrimann.notification, PID: 4146
Theme: …Run Code Online (Sandbox Code Playgroud) 这可能是一个愚蠢的问题,但为什么这个代码在调用delete时会崩溃?从阅读其他问题我知道这可能导致未定义的行为,但我不明白为什么.
#include <iostream>
using namespace std;
char* resize (char* result, int& size){
char * temp;
temp = new char [size*10];
for (int i=0;i<size;i++) temp[i]=result[i];
size*=10;
//delete[] result;
return temp;
}
void transform(char in[], const char p1[], const char p2[]){
int resultlength=100, inputindex=0, outputindex=0;
char* result = new char[resultlength];
while (in[inputindex]){
result[outputindex++]=in[inputindex++];
if (inputindex>=resultlength) result = resize (result,resultlength);
}
in[outputindex--]=0;
while(outputindex>=0) in[outputindex]=result[outputindex--];
//delete[] result;
}
int main(){
char t[200]="123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";
transform(t,"hfgh","dfsdfds");
int i=0;
while(t[i]) cout<<t[i++];
cout<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我做了一个名为的课程cell.在这个类中有一个cell指针数组.标题看起来像这样:
class cell
{
public:
cell();
cell *c[8];
void creatcells();
virtual ~cell();
..
}
Run Code Online (Sandbox Code Playgroud)
并且cpp文件看起来像这样:
cell::cell()
{
//ctor
for(int i=0;i<8;i++)
{
c[i]=NULL;
}
}
void cell::creatcells()
{
cell c1,c2,c3,c4,c5,c6,c7,c8;
c[0]=&c1;
c[1]=&c2;
c[2]=&c3;
c[3]=&c4;
c[4]=&c5;
c[5]=&c6;
c[6]=&c7;
c[7]=&c8;
}
cell::~cell()
{
for(int i=0; i<8; i++)
{
if (c[i]!=NULL)
{
delete c[i];
}
}
delete[] c;
}
Run Code Online (Sandbox Code Playgroud)
但每次程序结束时,都会崩溃,为什么?
我试过没有if (c[i]!=NULL),但这没有帮助.只有没有for循环,代码才能完美结束,但我知道这也必须删除.我想我正确地写了析构函数,不是吗?
当我使用大于12个元素的大向量测试程序时,它崩溃(我收到lldb错误)。但是,它适用于小的向量。我认为它正在尝试访问不应访问的内存空间,但是我不知道如何解决它。该程序应该打印出其元素之和等于“目标”的向量。此外,我可以表达另一种方式:if(i&(1 << j))吗?
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int c = 0;
/* find subsets of a given set */
void findSubsets(int *value, int n, int i) {
int j;
if (i < 0)
return;
for (j = 0; j < n; j++) {
/*
* checking jth bit is set in i. If
* it is set, then fetch the element at
* jth index in value array
*/
if (i & (1 << j)) {
suma = …Run Code Online (Sandbox Code Playgroud)