簡體   English   中英

我在 Android 模擬器上運行我的應用程序時遇到問題

[英]I'm having an issue with running my app on the Android emulator

我在使用 android 工作室模擬器時遇到問題。 每次我點擊運行時都會彈出一條消息。 無法安裝應用程序:SKIPPED_INSTALL 無法終止 com.smstechnology.diceroller 重試。 這是 mainActivity.kt

package com.smstechnology.diceroller

import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

/**
 * This activity allows the user to roll a dice and view the result
 * on the screen.
 */
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val rollButton: Button = findViewById(R.id.bottom)
        rollButton.setOnClickListener {
            rollDice()
        }
    }
    /**
     * Roll the dice and update the screen with the result.
     */
    private fun rollDice() {
        // Create new Dice object with 6 sides and roll it
        val dice = Dice(6)
        val diceRoll = dice.roll()
        // Update the screen with the dice roll
        val resultTextView: TextView = findViewById(R.id.textView)
        resultTextView.text = diceRoll.toString()
    }
}

class Dice(private val numSides: Int) {

    fun roll(): Int {
        return (1..numSides).random()
    }
}

這些安裝失敗似乎有各種解決方案 - 希望有人知道該特定消息的含義!

就我個人而言,我會嘗試使用紅色停止按鈕從 Android Studio 中終止該應用程序。 如果這不起作用,請嘗試進入模擬器上的應用程序設置(您可以長按任務切換器上的圖標)並強制停止

有些人在禁用 Instant Run 方面取得了一些成功,但我再也看不到相應的選項了

對我來說,總是導致它的原因是虛擬設備沒有足夠的存儲空間——如果我將它增加 1GB 左右,一切都會正常安裝。 這不是一個很有幫助的信息!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM