-4

该应用程序成功下载到模拟器上,但是当我尝试运行它时,它会强制关闭。

这是日志猫:

05-29 16:28:10.601: D/AndroidRuntime(590): Shutting down VM
05-29 16:28:10.601: W/dalvikvm(590): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-29 16:28:10.632: E/AndroidRuntime(590): FATAL EXCEPTION: main
05-29 16:28:10.632: E/AndroidRuntime(590): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{App.picsofbrody/App.picsofbrody.picsofbrody}: java.lang.ClassNotFoundException: App.picsofbrody.picsofbrody in loader dalvik.system.PathClassLoader[/data/app/App.picsofbrody-1.apk]
05-29 16:28:10.632: E/AndroidRuntime(590):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
05-29 16:28:10.632: E/AndroidRuntime(590):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-29 16:28:10.632: E/AndroidRuntime(590):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-29 16:28:10.632: E/AndroidRuntime(590):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-29 16:28:10.632: E/AndroidRuntime(590):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-29 16:28:10.632: E/AndroidRuntime(590):  at android.os.Looper.loop(Looper.java:123)
05-29 16:28:10.632: E/AndroidRuntime(590):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-29 16:28:10.632: E/AndroidRuntime(590):  at java.lang.reflect.Method.invokeNative(Native Method)
05-29 16:28:10.632: E/AndroidRuntime(590):  at java.lang.reflect.Method.invoke(Method.java:521)
05-29 16:28:10.632: E/AndroidRuntime(590):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-29 16:28:10.632: E/AndroidRuntime(590):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-29 16:28:10.632: E/AndroidRuntime(590):  at dalvik.system.NativeStart.main(Native Method)
05-29 16:28:10.632: E/AndroidRuntime(590): Caused by: java.lang.ClassNotFoundException: App.picsofbrody.picsofbrody in loader dalvik.system.PathClassLoader[/data/app/App.picsofbrody-1.apk]
05-29 16:28:10.632: E/AndroidRuntime(590):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-29 16:28:10.632: E/AndroidRuntime(590):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-29 16:28:10.632: E/AndroidRuntime(590):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-29 16:28:10.632: E/AndroidRuntime(590):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-29 16:28:10.632: E/AndroidRuntime(590):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-29 16:28:10.632: E/AndroidRuntime(590):  ... 11 more

主菜:

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

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

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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

活动主:

<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"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="@string/pictures_of_brody"
        android:textSize="30sp" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="26dp"
        android:src="@drawable/pic1" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView1"
        android:layout_toRightOf="@+id/imageView1"
        android:src="@drawable/pic2" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView1"
        android:layout_toLeftOf="@+id/imageView2"
        android:src="@drawable/pic3" />

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/imageView2"
        android:layout_below="@+id/imageView2"
        android:src="@drawable/pic4" />


</RelativeLayout>

MainActivity.java:

package App.picsofbrody;

import App.picsofbrody.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

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

}

请让我知道我需要在此处发布哪些其他文件供大家查看,以便我解决此问题。这是我的第一篇文章,我不完全确定我应该附上什么。顺便说一句,这只是我制作的第二个测试应用程序,它应该做的就是显示四张图片和一段文字。请友好一点!

谢谢!

4

1 回答 1

2

您需要在清单中更改此行

  android:name=".picsofbrody"

   android:name=".MainActivity"

就目前而言,Dalvik 正在尝试查找类App.picsofbrody.picsofbrodypicsofbrody在包中App.picsofbrody

于 2013-05-29T17:07:15.003 回答