我试过搜索,但没有类似于我的结果。 所以我正在做我的第一个应用程序并遇到了这样的问题:应用程序在启动后立即关闭。测试是在6.0安卓版手机上完成的。我想尽快完成这个问题,所以我可以继续学习,所以感谢任何输入。 catlog没有显示任何异常,只有这个:
06-16 22:01:04.156 12236-12236/? I/art: Late-enabling -Xcheck:jni
06-16 22:01:04.633 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:04.870 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:04.933 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:05.004 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:05.072 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:05.139 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:05.201 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:05.263 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:05.327 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:05.389 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:05.454 12236-12236/com.ktu.sirius.percentcalculator W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.ktu.sirius.percentcalculator-2/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.ktu.sirius.percentcalculator-2@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
06-16 22:01:05.457 12236-12236/com.ktu.sirius.percentcalculator W/System: ClassLoader referenced unknown path: /data/app/com.ktu.sirius.percentcalculator-2/lib/arm64
06-16 22:01:05.491 12236-12236/com.ktu.sirius.percentcalculator I/InstantRun: starting instant run server: is main process
06-16 22:01:06.021 12236-12236/com.ktu.sirius.percentcalculator I/Process: Sending signal. PID: 12236 SIG: 9
所以,这是我唯一的一个类,Calculator.java:
package com.ktu.sirius.percentcalculator;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Calculator extends AppCompatActivity {
Button buttonCalculate = (Button) findViewById(R.id.buttonCalculate);
TextView Answer = (TextView) findViewById(R.id.answerTextView);
EditText Percentage = (EditText) findViewById(R.id.percentEditText);
EditText Number = (EditText) findViewById(R.id.numberEditText);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calculator);
buttonCalculate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (!isStringEmpty(Percentage.getText().toString()) && !isStringEmpty(Number.getText().toString())) {
double answer = Double.parseDouble(Number.getText().toString()) / 100 * Double.parseDouble(Percentage.getText().toString());
Answer.setText(String.valueOf(answer));
}
}
});
}
boolean isStringEmpty(String toCheck){
return toCheck.length() == 0;
}
}
activity_calculator.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ktu.sirius.percentcalculator.Calculator">
<EditText
android:id="@+id/percentEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:hint="Enter percentage"
android:textAlignment="center"
android:paddingTop="40dp"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintHorizontal_bias="0.503"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/ofTextView"
app:layout_constraintTop_toBottomOf="@+id/answerTextView"
app:layout_constraintVertical_bias="1.0" />
<TextView
android:id="@+id/percentTextView"
android:layout_width="18dp"
android:layout_height="40dp"
android:text="%"
android:textSize="30sp"
app:layout_constraintLeft_toRightOf="@+id/percentEditText"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="@+id/percentEditText"
android:layout_marginBottom="8dp"
app:layout_constraintVertical_bias="0.503"
app:layout_constraintBottom_toTopOf="@+id/ofTextView" />
<TextView
android:id="@+id/answerTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="50sp"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp" />
<TextView
android:id="@+id/ofTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="of"
android:textSize="30sp"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="@+id/buttonCalculate"
app:layout_constraintHorizontal_bias="0.501"
android:layout_marginBottom="8dp" />
<EditText
android:id="@+id/numberEditText"
android:hint="Enter number"
android:textAlignment="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/ofTextView" />
<Button
android:id="@+id/buttonCalculate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="Calculate"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/numberEditText" />
</android.support.constraint.ConstraintLayout>
和android_manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ktu.sirius.percentcalculator">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Calculator">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>