当我尝试 运行 我的旧 android 项目时,android studio 中显示安装构建工具 25.0.3 错误
Install build tools 25.0.3 error showing in android studio when i tried to run my old android project
我卸载并重新安装了 android 工作室,因为在构建我已经创建的 gradle.The 项目时出现一些错误并且 运行 成功,现在无法使用我当前安装的 studio.It 红色标记了 AppCompatActivity、findViewById、startActivity 等行
完整的java文件如下
package com.example.mfk.simpleloginapp;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class Login extends AppCompatActivity {
private static EditText username;
private static EditText password;
private static TextView attempts;
private static Button login_btn;
int attempt_counter = 5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
LoginButton();
}
public void LoginButton()
{
username = (EditText)findViewById(R.id.editText4_Enter_UN_Here);
password = (EditText)findViewById(R.id.editText3_Enter_PW_Here);
attempts = (TextView) findViewById(R.id.editText5_Attmpts_see_here);
login_btn = (Button)findViewById(R.id.button2_Login);
attempts.setText(Integer.toString(attempt_counter));
login_btn.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
if(username.getText().toString().equals("mohammedfarisk")&&password.getText().toString().equals("farisk321@android"))
{
Toast.makeText(Login.this,"Username and Password are correct",Toast.LENGTH_SHORT).show();
Intent intent = new Intent("com.example.mfk.user.User");
startActivity(intent);
}
else
{
Toast.makeText(Login.this,"Username or Password is NOT correct",Toast.LENGTH_SHORT).show();
attempt_counter--;
attempts.setText(Integer.toString(attempt_counter));
if(attempt_counter == 0)
{
login_btn.setEnabled(false);
}
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
//inflates the menu ; this adds items to the acion bar if it is present.
getMenuInflater().inflate(R.menu.menu_login, menu);
return true;
}
}
如果没有自动安装选项,请查找此按钮:
(SDK 管理器)。
我卸载并重新安装了 android 工作室,因为在构建我已经创建的 gradle.The 项目时出现一些错误并且 运行 成功,现在无法使用我当前安装的 studio.It 红色标记了 AppCompatActivity、findViewById、startActivity 等行
完整的java文件如下
package com.example.mfk.simpleloginapp;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class Login extends AppCompatActivity {
private static EditText username;
private static EditText password;
private static TextView attempts;
private static Button login_btn;
int attempt_counter = 5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
LoginButton();
}
public void LoginButton()
{
username = (EditText)findViewById(R.id.editText4_Enter_UN_Here);
password = (EditText)findViewById(R.id.editText3_Enter_PW_Here);
attempts = (TextView) findViewById(R.id.editText5_Attmpts_see_here);
login_btn = (Button)findViewById(R.id.button2_Login);
attempts.setText(Integer.toString(attempt_counter));
login_btn.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
if(username.getText().toString().equals("mohammedfarisk")&&password.getText().toString().equals("farisk321@android"))
{
Toast.makeText(Login.this,"Username and Password are correct",Toast.LENGTH_SHORT).show();
Intent intent = new Intent("com.example.mfk.user.User");
startActivity(intent);
}
else
{
Toast.makeText(Login.this,"Username or Password is NOT correct",Toast.LENGTH_SHORT).show();
attempt_counter--;
attempts.setText(Integer.toString(attempt_counter));
if(attempt_counter == 0)
{
login_btn.setEnabled(false);
}
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
//inflates the menu ; this adds items to the acion bar if it is present.
getMenuInflater().inflate(R.menu.menu_login, menu);
return true;
}
}
如果没有自动安装选项,请查找此按钮: