【问题标题】:Package not installing on virtual device软件包未安装在虚拟设备上
【发布时间】:2011-01-10 05:22:58
【问题描述】:

对此我很陌生,无法让这段代码在我的虚拟设备上运行。我收到以下错误消息。任何输入都会非常有用。

Errors:
[2011-01-09 21:03:33 - Cat.Talker] Failed to install Cat.Talker.apk on device 'emulator-5554!
[2011-01-09 21:03:33 - Cat.Talker] (null)
[2011-01-09 21:03:33 - Cat.Talker] Launch canceled!

Cat.java:

package cat.talker;

import android.app.Activity;
import android.os.Bundle;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class Cat extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }

public void playSound(View view) {
 // First parameter defines the number of channels which should be played
 // in parallel, last one currently not used
 SoundPool soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
 int soundID = soundPool.load(this, R.raw.meow1, 1);

 // Getting the user sound settings
 AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
 float actualVolume = (float) audioManager
   .getStreamVolume(AudioManager.STREAM_MUSIC);
 float maxVolume = (float) audioManager
   .getStreamMaxVolume(AudioManager.STREAM_MUSIC);
 float volume = actualVolume / maxVolume;
 soundPool.play(soundID, volume, volume, 1, 0, 1f);
}
}

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ImageView
android:id="@+id/widget30"
android:layout_width="190px"
android:layout_height="136px"
android:layout_x="20px"
android:layout_y="12px"
>
</ImageView>
<Button
android:id="@+id/Meow1"
android:layout_width="197px"
android:layout_height="wrap_content"
android:text="Meow1"
android:layout_x="16px"
android:layout_y="161px"
android:onClick="playsound"
>
</Button>
<Button
android:id="@+id/Meow2"
android:layout_width="196px"
android:layout_height="40px"
android:text="Meow2"
android:layout_x="17px"
android:layout_y="221px"
>
</Button>
<Button
android:id="@+id/Meow3"
android:layout_width="195px"
android:layout_height="42px"
android:text="Meow3"
android:layout_x="17px"
android:layout_y="276px"
>
</Button>
<Button
android:id="@+id/Meow4"
android:layout_width="191px"
android:layout_height="40px"
android:text="Meow4"
android:layout_x="18px"
android:layout_y="337px"
>
</Button>
</AbsoluteLayout>

【问题讨论】:

  • 清单中有什么?

标签: android packages


【解决方案1】:

“您是否尝试再次打开和关闭它”可能有点过分,但我有时确实有这个,然后重新启动虚拟机通常会有所帮助。如果它不起作用,您甚至可能需要重新启动 Eclipse(如果您正在使用它)

【讨论】:

    猜你喜欢
    • 2022-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-08
    • 1970-01-01
    • 2016-08-16
    • 2020-02-27
    • 1970-01-01
    相关资源
    最近更新 更多