前提・実現したいこと
Android Studioを始めたばかりでボタンを押すとテキストが変わるサンプルプログラムを入力したがビルド失敗してしまう.
原因も解決方法も分からないので教えていただけると助かります.
発生している問題・エラーメッセージ
\AndroidStudioProjects\MyApplication1\app\build\intermediates\signing_config\debug\out\signing-config.json (アクセスが拒否されました。)
該当のソースコード
MainActivity.java
1package com.example.myapplication1; 2 3import android.support.v7.app.AppCompatActivity; 4import android.os.Bundle; 5import android.view.View; 6import android.widget.Button; 7import android.widget.TextView; 8 9public class MainActivity extends AppCompatActivity { 10 11 private TextView textView; 12 private boolean flag = false; 13 14 @Override 15 protected void onCreate(Bundle savedInstanceState) { 16 super.onCreate(savedInstanceState); 17 setContentView(R.layout.activity_main); 18 19 // ボタンを設定 20 Button button = findViewById(R.id.button); 21 22 // TextView の設定 23 textView = findViewById(R.id.text_view); 24 25 button.setOnClickListener(new View.OnClickListener() { 26 @Override 27 public void onClick(View view) { 28 // flagがtrueの時 29 if (flag) { 30 //textView.setText(R.string.hello); 31 textView.setText("Hello"); 32 33 flag = false; 34 } 35 // flagがfalseの時 36 else { 37 //textView.setText(R.string.world); 38 textView.setText("World"); 39 flag = true; 40 } 41 } 42 }); 43 } 44
activity_main.xml
1<?xml version="1.0" encoding="utf-8"?> 2<android.support.constraint.ConstraintLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 xmlns:app="http://schemas.android.com/apk/res-auto" 5 xmlns:tools="http://schemas.android.com/tools" 6 android:layout_width="match_parent" 7 android:layout_height="match_parent" 8 tools:context=".MainActivity"> 9 10 <TextView 11 android:id="@+id/text_view" 12 android:layout_width="wrap_content" 13 android:layout_height="wrap_content" 14 android:text="Hello" 15 app:layout_constraintBottom_toBottomOf="parent" 16 app:layout_constraintLeft_toLeftOf="parent" 17 app:layout_constraintRight_toRightOf="parent" 18 app:layout_constraintTop_toTopOf="parent" 19 app:layout_constraintVertical_bias="0.4" /> 20 21 <Button 22 android:id="@+id/button" 23 android:layout_width="wrap_content" 24 android:layout_height="wrap_content" 25 android:text="Button" 26 app:layout_constraintBottom_toBottomOf="parent" 27 app:layout_constraintLeft_toLeftOf="parent" 28 app:layout_constraintRight_toRightOf="parent" 29 app:layout_constraintTop_toTopOf="parent" 30 app:layout_constraintVertical_bias="0.6" /> 31 32</android.support.constraint.ConstraintLayout>
試したこと
Android Studio をインストールしたときの初期のHeloo Worldを表示させるだけのプログラムはビルドできました.
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/08 09:11