Ich habe einen Fehler, wenn ich eine Taste Formular Mainaktivität gedrückt, es wird zu einer Aktivität gehen, aber stattdessen stürzt es ab ..... Ich habe nie zuvor diesen Fehler aufgetreten, können Sie mir helfenkann nicht starten activeinfo
Process: com.sp.ez_mart, PID: 9514
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sp.ez_mart/com.sp.ez_mart.navigation_front}: android.content.res.Resources$NotFoundException: Resource ID #0x7f040031
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2787)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1504)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f040031
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:207)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2107)
at android.content.res.Resources.getLayout(Resources.java:1120)
at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.sp.ez_mart.navigation_front.onCreate(navigation_front.java:37)
at android.app.Activity.performCreate(Activity.java:6754)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2787)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1504)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Anwendung beendet.
hier ist die Java, wo der Fehler von
public class navigation_front extends AppCompatActivity {
Button scan_btn;
Spinner dest;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.navigation_front);
scan_btn = (Button) findViewById(R.id.scan_btn);
final Activity activity = this;
scan_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
IntentIntegrator integrator = new IntentIntegrator(activity);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
integrator.setPrompt("Please Scan");
integrator.setCameraId(0);
integrator.setBeepEnabled(false);
integrator.setBarcodeImageEnabled(false);
integrator.initiateScan();
}
});
dest = (Spinner) findViewById(R.id.edit_destination);
final ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.destination_array, R.layout.support_simple_spinner_dropdown_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
dest.setAdapter(adapter);
dest.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String[] dataArray = getResources().getStringArray(R.array.destination_array);
String type = dataArray[position];
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
final EditText edit = (EditText) findViewById(R.id.Edit_current);
final Spinner spin = (Spinner) findViewById(R.id.edit_destination);
final Button btn = (Button) findViewById(R.id.navigate);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(navigation_front.this, NavigateImage.class);
if (edit.getText().toString().trim().equals("Entrance") && spin.getSelectedItem().equals("Vegetables")) {
i.putExtra("image", R.drawable.entrance_vege);
startActivity(i);
} else if (edit.getText().toString().trim().equals("Entrance") && spin.getSelectedItem().equals("Canned-Food")) {
i.putExtra("image", R.drawable.entrance_can);
startActivity(i);
} else {
Toast.makeText(getApplicationContext(), "Please Enter Valid Value.",
Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if(result.getContents() != null) {
if (result.getContents() == null) {
Log.d("MainActivity", "Cancelled scan");
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
} else {
EditText editText = (EditText) findViewById(R.id.Edit_current);
editText.setText("" + result.getContents(), TextView.BufferType.EDITABLE);
}
hier die XML-
<?xml version="1.0" encoding="utf-8"?>
><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:orientation="vertical"
android:background="@color/zxing_custom_possible_result_points">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="24dp"></LinearLayout>
<TextView
android:text="Current Location :"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:fontFamily="cursive"
android:textSize="30sp"
android:textAlignment="viewStart"
android:typeface="serif"
android:textStyle="normal|bold"
android:textAllCaps="false" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/Edit_current"
android:selectAllOnFocus="true"
tools:backgroundTint="@color/common_action_bar_splitter"
android:background="@color/common_action_bar_splitter"
android:layout_weight="0.21"
android:hint="Scan/Type Location"
android:textStyle="normal|italic" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.14"></LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="115dp">
<Button
android:text="Scan Nearest Qr Code"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scan_btn"
android:background="@color/zxing_possible_result_points"
android:elevation="0dp"
android:typeface="monospace"
android:textSize="18sp"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="224dp"
android:elevation="1dp"
android:weightSum="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="35dp"></LinearLayout>
<TextView
android:text="Destination :"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Destination"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:fontFamily="cursive"
android:textSize="30sp"
android:textStyle="normal|bold" />
<Spinner
android:layout_width="match_parent"
android:layout_height="37dp"
android:id="@+id/edit_destination" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="174dp">
<Button
android:text="Navigate Me!"
android:id="@+id/navigate"
android:layout_width="120dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_height="55dp"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</RelativeLayout>
</LinearLayout>
</LinearLayout
neuer Fehler
Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Exception parsing classes
Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Exception parsing classes
Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Exception parsing classes
Error:3 errors; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
Scheint, wie Ihre navigation_front XML-Datei den Fehler verursacht. Überprüfen Sie, ob alle in der XML-Datei verwendeten Ressourcen in Ihrer Anwendung definiert sind oder nicht. –
'Ressourcen $ NotFoundException' show xml –
@Jason was passiert ist.? löste es oder nicht. –