我正在开发一个应用程序,该应用程序对棒棒糖的Oreo效果很好,但在豆形软糖上却崩溃了,我不为什么?
我的目标sdk是16
sdk的最小值为
日志给我这个:
08-26 10:00:24.098 87-393 /? E / AudioFlinger:未知的哑剧类型08-26 10:00:25.278 11895-11895 / com.example.abanoub.angelsbook E / AndroidRuntime:致命异常:main java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.abanoub.angelsbook / com.example.abanoub.angelsbook.DataActivity}: java.lang.NullPointerException 在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121) 在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2146) 在android.app.ActivityThread.access $ 700(ActivityThread.java:140) 在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1238) 在android.os.Handler.dispatchMessage(Handler.java:99) 在android.os.Looper.loop(Looper.java:177) 在android.app.ActivityThread.main(ActivityThread.java:4944) 在java.lang.reflect.Method.invokeNative(本机方法) 在java.lang.reflect.Method.invoke(Method.java:511) 在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1038) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 在dalvik.system.NativeStart.main(本机方法) 造成原因:java.lang.NullPointerException 在com.example.abanoub.angelsbook.DataActivity.onCreate(DataActivity.java:83) 在android.app.Activity.performCreate(Activity.java:5188) 在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2085) 在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2146) 在android.app.ActivityThread.access $ 700(ActivityThread.java:140) 在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1238) 在android.os.Handler.dispatchMessage(Handler.java:99) 在android.os.Looper.loop(Looper.java:177) 在android.app.ActivityThread.main(ActivityThread.java:4944) 在java.lang.reflect.Method.invokeNative(本机方法) 在java.lang.reflect.Method.invoke(Method.java:511) 在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1038) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 在dalvik.system.NativeStart.main(本机方法)08-26 10:00:25.438 513-531 /? E / android.os.Debug:!@Dumpstate> dumpstate -k -t -z -d -o / data / log / dumpstate_app_error 08-26 10:00:32.018 782-782 /? E / Launcher:查找设置错误,未找到默认可访问性: accessibility_enabled
这是DataActivity
public class DataActivity extends AppCompatActivity {
MyTextView Headlineview;
MyTextView Rightview;
MyTextView Leftview;
MyTextView Endview;
String DataToDisplay ;
String Chosendate;
String you129 = "9/12";
String m29 = "9/2";
Typeface font;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data);
SharedPreferences sp = getSharedPreferences("saved", SettingsActivity.MODE_PRIVATE);
fontsize = sp.getInt("size", -1);
Calendar calendar = Calendar.getInstance();
int mnouth = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
Bundle bundle = getIntent().getExtras();
if (bundle == null) {
Chosendate = mnouth + 1 + "/" + day;
} else {
Chosendate = bundle.getString("chosen");
}
Headlineview = findViewById(R.id.headline);
Rightview = findViewById(R.id.rightdataView);
Leftview = findViewById(R.id.leftdataView);
Endview = findViewById(R.id.enddataView);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
if (fontsize == -1 ) {
Headlineview.setTextSize(17);
Leftview.setTextSize(17);
Rightview.setTextSize(17);
Endview.setTextSize(17);
}
else { Headlineview.setTextSize(fontsize);
Leftview.setTextSize(fontsize);
Rightview.setTextSize(fontsize);
Endview.setTextSize(fontsize);}
if (Chosendate.contentEquals(you129)) {
Headlineview.setText(R.string.y129head);
Leftview.setText(R.string.y129dataleft);
Rightview.setText(R.string.y129dataright);
Endview.setText(R.string.y129end);
} else if (Chosendate.contentEquals(m29)) {
Headlineview.setText(R.string.m29head);
Leftview.setText(R.string.m29dataleft);
Rightview.setText(R.string.m29dataright);
Endview.setText(R.string.m29end);
DataToDisplay= getText(R.string.m29share).toString();
}
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent shareintent = new Intent(Intent.ACTION_SEND);
shareintent.setAction(Intent.ACTION_SEND);
shareintent.putExtra(Intent.EXTRA_TEXT,
DataToDisplay + " \n \n \n \n \n تطبيق تماجيد يوميه" +
"\n\n" +
" https://play.google.com/store/apps/details?id=com.example.abanoub.angelsbook" +
"\n\n");
shareintent.setType("text/plain");
startActivity(shareintent);
}
});
}}
@Override
protected void onStop() {
super.onStop();
}
}
在mainActivity给出
**08-26 17:22:03.568 16368-16368/com.example.abanoub.angelsbook E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoSuchMethodError: com.example.abanoub.angelsbook.MainActivity.releaseInstance
at com.example.abanoub.angelsbook.MainActivity.onStop(MainActivity.java:176)
at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1219)
at android.app.Activity.performStop(Activity.java:5326)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3039)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3088)
at android.app.ActivityThread.access$1000(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:177)
at android.app.ActivityThread.main(ActivityThread.java:4944)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)**
答案 0 :(得分:0)
在 onCreate()方法中,类 DataActivity 的第83行具有NullPointerException。
请参阅stacktrace:
java.lang.NullPointerException at com.example.abanoub.angelsbook.DataActivity.onCreate(DataActivity.java:83)
能否请您共享DataActivity类的代码?