gpt4 book ai didi

android - 不幸的是应用程序已关闭..仅完成设计阶段

转载 作者:搜寻专家 更新时间:2023-11-01 07:53:13 26 4
gpt4 key购买 nike

我刚刚做了一个项目的设计部分,但它显示应用程序已关闭。我没有对 Activity main 做任何事情,所以我无法理解错误。我是新手,所以请帮忙。谢谢。

package com.example.calculator3;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

}

@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;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}

日志

  08-06 11:07:28.495: D/AndroidRuntime(1927): Shutting down VM
08-06 11:07:28.524: E/AndroidRuntime(1927): FATAL EXCEPTION: main
08-06 11:07:28.524: E/AndroidRuntime(1927): Process: com.example.calculator3, PID: 1927
08-06 11:07:28.524: E/AndroidRuntime(1927): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.calculator3/com.example.calculator3.MainActivity}: android.view.InflateException: Binary XML file line #39: Error inflating class Gradient
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.app.ActivityThread.access$800(ActivityThread.java:151)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.os.Handler.dispatchMessage(Handler.java:102)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.os.Looper.loop(Looper.java:135)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.app.ActivityThread.main(ActivityThread.java:5257)
08-06 11:07:28.524: E/AndroidRuntime(1927): at java.lang.reflect.Method.invoke(Native Method)
08-06 11:07:28.524: E/AndroidRuntime(1927): at java.lang.reflect.Method.invoke(Method.java:372)
08-06 11:07:28.524: E/AndroidRuntime(1927): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
08-06 11:07:28.524: E/AndroidRuntime(1927): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
08-06 11:07:28.524: E/AndroidRuntime(1927): Caused by: android.view.InflateException: Binary XML file line #39: Error inflating class Gradient
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
08-06 11:07:28.524: E/AndroidRuntime(1927): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.app.Activity.setContentView(Activity.java:2145)
08-06 11:07:28.524: E/AndroidRuntime(1927): at com.example.calculator3.MainActivity.onCreate(MainActivity.java:15)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.app.Activity.performCreate(Activity.java:5990)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
08-06 11:07:28.524: E/AndroidRuntime(1927): ... 10 more
08-06 11:07:28.524: E/AndroidRuntime(1927): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.Gradient" on path: DexPathList[[zip file "/data/app/com.example.calculator3- 1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
08-06 11:07:28.524: E/AndroidRuntime(1927): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-06 11:07:28.524: E/AndroidRuntime(1927): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-06 11:07:28.524: E/AndroidRuntime(1927): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.view.LayoutInflater.createView(LayoutInflater.java:571)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:665)
08-06 11:07:28.524: E/AndroidRuntime(1927): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:65)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
08-06 11:07:28.524: E/AndroidRuntime(1927): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
08-06 11:07:28.524: E/AndroidRuntime(1927): ... 20 more
08-06 11:07:28.524: E/AndroidRuntime(1927): Suppressed: java.lang.ClassNotFoundException: android.view.Gradient
08-06 11:07:28.524: E/AndroidRuntime(1927): at 0 java.lang.Class.classForName(Native Method)
08-06 11:07:28.524: E/AndroidRuntime(1927): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
08-06 11:07:28.524: E/AndroidRuntime(1927): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
08-06 11:07:28.524: E/AndroidRuntime(1927): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
08-06 11:07:28.524: E/AndroidRuntime(1927): ... 26 more
08-06 11:07:28.524: E/AndroidRuntime(1927): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

list ..

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.calculator3"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="22" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="AnotherActivity" android:name="com.example.calculator3" />
</application>

Activity 主体

    <RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#000000"
tools:context="com.example.calculator3.MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="@string/hello_world" />

<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="65dp"
android:layout_alignRight="@+id/buttondiv"
android:background="@android:color/transparent"
android:ems="10"
android:gravity="right"
android:inputType="text"
android:textColor="#FFFFFF"
android:width="275dp"
tools:ignore="LabelFor" >

<requestFocus />
</EditText>

<Gradient
android:angle="265"
android:endColor="#FFFFFF"
android:startColor="#000000"/>

<Button
android:id="@+id/button9"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button6"
android:layout_toRightOf="@+id/button5"
android:background="@drawable/btn_gradient"
android:text="@string/button9_fix"
android:textColor="#FFFFFF"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"/>

<Button
android:id="@+id/buttonAC"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignBaseline="@+id/button12"
android:layout_alignBottom="@+id/button12"
android:layout_toRightOf="@+id/button4"
android:background="@drawable/btn2_gradient"
android:text="@string/buttonAC_fix"
android:textColor="#FFFFFF"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
/>

<Button
android:id="@+id/button5"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button2"
android:layout_toRightOf="@+id/textView1"
android:background="@drawable/btn_gradient"
android:text="@string/button5_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/button4"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button1"
android:layout_alignLeft="@+id/button7"
android:background="@drawable/btn_gradient"
android:text="@string/button4_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/buttonplus"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/buttonOK"
android:layout_marginLeft="1dp"
android:layout_toRightOf="@+id/button13"
android:background="@drawable/btn2_gradient"
android:text="@string/buttonplus_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/button6"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button3"
android:layout_alignLeft="@+id/button9"
android:background="@drawable/btn_gradient"
android:text="@string/button6_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/buttondot"
android:layout_alignLeft="@+id/button6"
android:background="@drawable/btn_gradient"
android:text="@string/button3_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/buttondot"
android:layout_alignLeft="@+id/button5"
android:background="@drawable/btn_gradient"
android:text="@string/button2_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/buttonmul"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/buttonplus"
android:layout_toRightOf="@+id/buttonequal"
android:background="@drawable/btn2_gradient"
android:text="@string/buttonmul_fix"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/buttondot"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/buttonAC"
android:layout_toLeftOf="@+id/button9"
android:background="@drawable/btn_gradient"
android:text="@string/buttondot_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/button8"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button5"
android:layout_alignLeft="@+id/button5"
android:background="@drawable/btn_gradient"
android:text="@string/button8_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/button7"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button4"
android:layout_alignLeft="@+id/button1"
android:background="@drawable/btn_gradient"
android:text="@string/button7_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/button10"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button12"
android:layout_alignRight="@+id/textView1"
android:background="@drawable/btn_gradient"
android:text="@string/button0_fix"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button10"
android:layout_alignLeft="@+id/button10"
android:background="@drawable/btn_gradient"
android:text="@string/button1_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/button12"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:layout_toLeftOf="@+id/buttonAC"
android:background="@drawable/btn2_gradient"
android:text="@string/buttonpercent_fix"
android:textColor="#FFFFFF"
android:width="65dp" />

<Button
android:id="@+id/buttonequal"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button13"
android:layout_toRightOf="@+id/buttonAC"
android:background="@drawable/btn2_gradient"
android:text="@string/buttonequal_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/button13"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignBaseline="@+id/buttonAC"
android:layout_alignBottom="@+id/buttonAC"
android:layout_toRightOf="@+id/buttonAC"
android:background="@drawable/btn2_gradient"
android:text="@string/buttonC_fix"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/buttonOK"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignBaseline="@+id/button13"
android:layout_alignBottom="@+id/button13"
android:layout_toRightOf="@+id/button13"
android:background="@drawable/btn2_gradient"
android:text="@string/buttonOK_fix"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/buttonminus"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button3"
android:layout_toRightOf="@+id/button6"
android:background="@drawable/btn2_gradient"
android:text="@string/buttonminus_fix"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/buttondiv"
style="?android:attr/buttonStyleSmall"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_above="@+id/button6"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_toRightOf="@+id/button6"
android:background="@drawable/btn2_gradient"
android:text="\u00F7"
android:textColor="#FFFFFF"
tools:ignore="HardcodedText" />
</RelativeLayout>

最佳答案

渐变是您的应用崩溃的原因。在布局文件中是不允许的。

要获得更完整的答案,请参阅 answer below by Prokash Sarkar

关于android - 不幸的是应用程序已关闭..仅完成设计阶段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31847568/

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