我有这个奇怪的错误,我的应用程序退出时没有错误消息或强制关闭,除此之外:"致命信号11(SIGSEGV)在0x00000000(代码= 1)"
它突然发生,我无法找到问题...... 我的代码
MainActivity
package com.example.newyorkfinal;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
TextView navTitle;
Button aboutButton,themeNightButton;
Intent startIntent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
aboutButton = (Button) findViewById(R.id.buttonAbout);
themeNightButton = (Button) findViewById(R.id.buttonThemeNights);
Typeface orangeTypeFace = Typeface.createFromAsset(getAssets(), "fonts/ORANGE JUICE.TTF");
navTitle = (TextView) findViewById(R.id.navigationTitle);
navTitle.setTypeface(orangeTypeFace);
aboutButton.setOnClickListener(this);
themeNightButton.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void onClick(View v){
switch (v.getId()) {
case R.id.buttonAbout :{
startIntent = new Intent(this,About.class);
startActivity(startIntent);
break;
}
case R.id.buttonThemeNights :{
startIntent = new Intent(this,themesActivity.class);
startActivity(startIntent);
break;
}
}
}
}
About.java
package com.example.newyorkfinal;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ScrollView;
import android.widget.TextView;
public class About extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about_layout);
}
}
答案 0 :(得分:0)
问题在于从资源加载字体
请按照以下步骤解决此问题
使用try / catch
包围此行 try{
Typeface orangeTypeFace = Typeface.createFromAsset(getAssets(), "fonts/ORANGE_JUICE.TTF");
}catch(Exception e){
}
重命名你的ttf,因为你的ttf文件包含空格
将 ORANGE JUICE.TTF 重命名为 ORANGE_JUICE.TTF