繁体   English   中英

Android应用程序可以在AVD上运行但不能在电话上运行吗?

[英]Android app working on AVD but not on the phone?

我创建了一个仅包含三个按钮(物理,数学,aboutus)的简单应用。 在物理和数学按钮的后面,我插入了许多公式的图像。 在aboutus按钮中,只有文字。 当我在AVD 2.3.3上运行我的应用程序时,它运行良好。 但是,当我尝试在各种不同的Android手机上运行它时,它会启动,但是当我单击任何物理或数学按钮时,该应用程序都会关闭,并显示“不幸的是Formulafinder已停止运行”(其中Formulafinder是我的应用程序名称)。 我将代码放在下面:

  1. 我的physics.xml文件如下所示

     <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/imageView1" android:layout_width="match_parent" android:layout_height="140dp" android:contentDescription="@string/imageView1" android:src="@drawable/one1" /> <ImageView android:id="@+id/imageView2" android:layout_width="match_parent" android:layout_height="200dp" android:layout_below="@+id/imageView1" android:contentDescription="@string/imageView2" android:src="@drawable/one2" /> <ImageView android:id="@+id/imageView3" android:layout_width="match_parent" android:layout_height="140dp" android:layout_below="@+id/imageView2" android:contentDescription="@string/imageView3" android:src="@drawable/one3" /> <ImageView android:id="@+id/imageView4" android:layout_width="match_parent" android:layout_height="140dp" android:layout_below="@+id/imageView3" android:contentDescription="@string/imageView4" android:src="@drawable/one4" /> <ImageView android:id="@+id/imageView5" android:layout_width="match_parent" android:layout_height="180dp" android:layout_below="@+id/imageView4" android:contentDescription="@string/imageView5" android:src="@drawable/one5" /> <ImageView android:id="@+id/imageView6" android:layout_width="match_parent" android:layout_height="200dp" android:layout_below="@+id/imageView5" android:contentDescription="@string/imageView6" android:src="@drawable/one6" /> <ImageView android:id="@+id/imageView7" android:layout_width="match_parent" android:layout_height="180dp" android:layout_below="@+id/imageView6" android:contentDescription="@string/imageView7" android:src="@drawable/one7" /> <ImageView android:id="@+id/imageView8" android:layout_width="match_parent" android:layout_height="180dp" android:layout_below="@+id/imageView7" android:contentDescription="@string/imageView8" android:src="@drawable/one8" /> <ImageView android:id="@+id/imageView9" android:layout_width="match_parent" android:layout_height="300dp" android:layout_below="@+id/imageView8" android:contentDescription="@string/imageView9" android:src="@drawable/one9" /> <ImageView android:id="@+id/imageView10" android:layout_width="match_parent" android:layout_height="180dp" android:layout_below="@+id/imageView9" android:contentDescription="@string/imageView10" android:src="@drawable/one10" /> <ImageView android:id="@+id/imageView11" android:layout_width="match_parent" android:layout_height="180dp" android:layout_below="@+id/imageView10" android:contentDescription="@string/imageView11" android:src="@drawable/one11" /> <ImageView android:id="@+id/imageView12" android:layout_width="match_parent" android:layout_height="180dp" android:layout_below="@+id/imageView11" android:contentDescription="@string/imageView12" android:src="@drawable/one12" /> <ImageView android:id="@+id/imageView13" android:layout_width="match_parent" android:layout_height="180dp" android:layout_below="@+id/imageView12" android:contentDescription="@string/imageView13" android:src="@drawable/one13" /> </RelativeLayout> 

  2. 我的maths.xml看起来像这样

      android:layout_width="match_parent" android:layout_height="wrap_content" > <ImageView android:id="@+id/imageViewm1" android:layout_width="match_parent" android:layout_height="350dp" android:contentDescription="@string/imageViewm1" android:src="@drawable/math1" /> <ImageView android:id="@+id/imageViewm2" android:layout_width="match_parent" android:layout_height="290dp" android:layout_below="@+id/imageViewm1" android:contentDescription="@string/imageViewm2" android:src="@drawable/math2" /> <ImageView android:id="@+id/imageViewm3" android:layout_width="match_parent" android:layout_height="140dp" android:layout_below="@+id/imageViewm2" android:contentDescription="@string/imageViewm3" android:src="@drawable/math3" /> <ImageView android:id="@+id/imageViewm4" android:layout_width="match_parent" android:layout_height="300dp" android:layout_below="@+id/imageViewm3" android:contentDescription="@string/imageViewm4" android:src="@drawable/math4" /> <ImageView android:id="@+id/imageViewm5" android:layout_width="match_parent" android:layout_height="220dp" android:layout_below="@+id/imageViewm4" android:contentDescription="@string/imageViewm5" android:src="@drawable/math5" /> <ImageView android:id="@+id/imageViewm6" android:layout_width="match_parent" android:layout_height="300dp" android:layout_below="@+id/imageViewm5" android:contentDescription="@string/imageViewm6" android:src="@drawable/math6" /> </RelativeLayout> 

  3. 我的activity_main.xml看起来像这样

     <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="@string/button_physics_text" /> <Button android:id="@+id/button2" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="@string/button_maths_text" /> <Button android:id="@+id/button3" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="@string/about_us" /> 

  4. 我的android_manifest.xml看起来像这样:

     <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcherfinal" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.test2.MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.example.test2.Physics" android:label="@string/title_activity_sub" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name="com.example.test2.Maths" android:label="@string/title_activity_maths" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name="com.example.test2.Aboutus" android:label="@string/title_activity_aboutus" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> 

我忘记提及的另一件事是,当我添加图像时,它给了我类似“未处理的事件循环异常”和“头大小超过”的错误。 对不起,您没有提起

更改清单文件-

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcherfinal"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.test2.MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.test2.Physics"
        android:label="@string/title_activity_sub" >
    </activity>
    <activity
        android:name="com.example.test2.Maths"
        android:label="@string/title_activity_maths" >
    </activity>
    <activity
        android:name="com.example.test2.Aboutus"
        android:label="@string/title_activity_aboutus" >
    </activity>
</application>

希望能有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM