![](/img/trans.png)
[英]Android Studio - Error running MainActivity: Unknown run configuration type AndroidRunConfigurationType
[英]Android Studio: Session 'MainActivity': error, but there is no error
嗨,我已經絞盡腦汁待了幾個小時,在網上進行研究,但似乎沒有人有答案。 我的模擬器運行我的代碼沒有問題,然后我再次運行它,我得到“Session'MainActivity':錯誤”。 我查看了這個主要活動大約10次但是在任何地方都沒有錯誤標志,看起來它應該工作正常,我的意思是它在沒有問題之前工作。 所以我不確定是否確實存在問題我沒有看到Android Studio沒有正確指出或者這是一個不同的問題。
任何幫助將不勝感激。 謝謝。
package tekvision.codedecrypter;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;
import gameInfo.GameDatabase;
public class MainActivity extends ActionBarActivity {
//Runs before the application is created
private Button mCampaignButton;
private final Context context = this;
//When the application is created
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Instantiate a GameDatabase object (this activity)
final GameDatabase gDB = new GameDatabase(context);
gDB.fillGameDatabase();
//Keeps screen on so it doesn't fall asleep
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//Finding button by button id after application is created
mCampaignButton = (Button)findViewById(R.id.campaignButtonID);
//Checks if the campaign button is clicked
mCampaignButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String ans = gDB.getAnswer("Ancient",1);
//Toast pop up message
Toast toast = Toast.makeText(getApplicationContext(),
ans ,
Toast.LENGTH_SHORT);
toast.show();
//Intent to go from main activity to campaign Level Select Activity
final Intent intent = new Intent(MainActivity.this, CampaignSelectLevel.class);
startActivity(intent);
}
});
}
}
嘗試重建和清理項目。 構建>重建項目和構建>清理項目
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.