gpt4 book ai didi

java - 每次我向应用程序添加图像时,它都会崩溃

转载 作者:太空宇宙 更新时间:2023-11-04 10:51:38 25 4
gpt4 key购买 nike

每当我向应用程序添加图像时,它就会开始崩溃,但如果没有图像,它就可以正常工作。这是我的日志猫

12-12 17:38:15.616 1301-1301/com.govinddixit.govindscurrencyconverter E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.govinddixit.govindscurrencyconverter/com.govinddixit.govindscurrencyconverter.MainActivity}: android.view.InflateException: Binary XML file line #0: Error inflating class ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class ImageView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.govinddixit.govindscurrencyconverter.MainActivity.onCreate(MainActivity.java:28)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
at android.app.ActivityThread.access$600(ActivityThread.java:141) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:5041) 
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:793) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f060001
at android.content.res.Resources.getValue(Resources.java:1014)
at android.support.v7.widget.ResourcesWrapper.getValue(ResourcesWrapper.java:208)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:330)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:58)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:78)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at com.govinddixit.govindscurrencyconverter.MainActivity.onCreate(MainActivity.java:28) 
at android.app.Activity.performCreate(Activity.java:5104) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
at android.app.ActivityThread.access$600(ActivityThread.java:141) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:5041) 
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:793) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
at dalvik.system.NativeStart.main(Native Method) 
12-12 17:38:15.820 437-688/system_process W/ActivityManager: Force finishing activity com.govinddixit.govindscurrencyconverter/.MainActivity
12-12 17:38:16.200 437-688/system_process D/dalvikvm: GC_FOR_ALLOC freed 102K, 19% free 5433K/6648K, paused 101ms, total 101ms
12-12 17:38:16.224 437-688/system_process I/dalvikvm-heap: Grow heap (frag case) to 5.778MB for 380492-byte allocation
12-12 17:38:16.532 437-491/system_process D/dalvikvm: GC_FOR_ALLOC freed 2K, 18% free 5802K/7020K, paused 306ms, total 306ms
12-12 17:38:16.636 437-453/system_process D/dalvikvm: GC_FOR_ALLOC freed 7K, 16% free 5918K/7020K, paused 23ms, total 23ms
12-12 17:38:16.656 437-453/system_process I/dalvikvm-heap: Grow heap (frag case) to 6.965MB for 1127532-byte allocation
12-12 17:38:16.696 437-445/system_process D/dalvikvm: GC_FOR_ALLOC freed <1K, 14% free 7019K/8124K, paused 39ms, total 39ms
12-12 17:38:16.768 437-439/system_process D/dalvikvm: GC_CONCURRENT freed 6K, 13% free 7111K/8124K, paused 49ms+3ms, total 69ms

[ 12-12 17:38:16.860 409: 946 D/ ]
HostConnection::get() New Host Connection established 0xb80a6870, tid 946


[ 12-12 17:38:16.892 437: 453 D/ ]
HostConnection::get() New Host Connection established 0xb7c43788, tid 453
12-12 17:38:17.104 437-450/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{5321514c u0 com.govinddixit.govindscurrencyconverter/.MainActivity}
12-12 17:38:17.528 662-662/com.android.launcher W/EGL_genymotion: eglSurfaceAttrib not implemented
12-12 17:38:19.044 437-453/system_process I/Choreographer: Skipped 44 frames! The application may be doing too much work on its main thread.
12-12 17:38:20.536 437-452/system_process I/Choreographer: Skipped 49 frames! The application may be doing too much work on its main thread.
12-12 17:38:21.504 437-452/system_process I/Choreographer: Skipped 57 frames! The application may be doing too much work on its main thread.
12-12 17:38:22.496 437-437/system_process I/ActivityManager: No longer want com.android.email (pid 1074): empty #17
12-12 17:38:22.648 437-518/system_process I/qtaguid: Failed write_ctrl(s 0 10052) res=-1 errno=1
12-12 17:38:22.648 437-518/system_process W/NetworkManagementSocketTagger: setKernelCountSet(10052, 0) failed with errno -1

Java Activity

package com.govinddixit.govindscurrencyconverter;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.Toast;


public class MainActivity extends AppCompatActivity
{
public void convert (View view)
{
EditText dollarField=(EditText) findViewById(R.id.dollarField);
Double dollarAmount =Double.parseDouble(dollarField.getText().toString());

Double rupee=dollarAmount*64.50;
Toast.makeText(getApplicationContext(),"Rs " + rupee.toString(),Toast.LENGTH_LONG).show();

}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

这是 .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.govinddixit.govindscurrencyconverter.MainActivity">

<TextView
android:id="@+id/textView2"
android:layout_width="347dp"
android:layout_height="33dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Enter The Amount In Dollar"
android:textSize="25sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.52" />

<EditText
android:id="@+id/dollarField"
android:layout_width="335dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:inputType="numberDecimal"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.63" />

<Button
android:id="@+id/button"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:onClick="convert"
android:text="Convert"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.8" />

<EditText
android:id="@+id/textView1"
android:layout_width="347dp"
android:layout_height="55dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:inputType="textPersonName"
android:text=" Dollar To Ruppes"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.37" />

<ImageView
android:id="@+id/imageView8"
android:layout_width="67dp"
android:layout_height="74dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.097"
app:srcCompat="@drawable/a" />

</android.support.constraint.ConstraintLayout>

最佳答案

你的堆栈跟踪显示Resources$NotFoundException。确保任何名为 a 的图像都包含在可绘制文件夹中。

如果存在,请尝试使用 android:src="@drawable/a"

希望这有帮助!

关于java - 每次我向应用程序添加图像时,它都会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47778609/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com