Android BUILD SUCCESSFUL 但提示有两个错误

:app:validateSigningProductionRelease
:app:packageProductionRelease
:app:crashlyticsStoreDeobsProductionRelease
:app:crashlyticsUploadDeobsProductionRelease
/Users/wangliang/BMW/bmw-sfm-android-master@c2be1242fcc/app/src/main/res/values/strings.xml:138: Error: "date_error_future" is not translated in "zh" (Chinese) [MissingTranslation]
    <string name="date_error_future">Date cannot be in the future.</string>
            ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/wangliang/BMW/bmw-sfm-android-master@c2be1242fcc/app/src/main/res/values/strings.xml:266: Error: "test_drive_route" is not translated in "zh" (Chinese) [MissingTranslation]
    <string name="test_drive_route">Test Drive Route:</string>
            ~~~~~~~~~~~~~~~~~~~~~~~

   Explanation for issues of type "MissingTranslation":
   If an application has more than one locale, then all the strings declared
   in one language should also be translated in all other languages.

   If the string should not be translated, you can add the attribute
   translatable="false" on the <string> element, or you can define all your
   non-translatable strings in a resource file called donottranslate.xml. Or,
   you can ignore the issue with a tools:ignore="MissingTranslation"
   attribute.

   By default this detector allows regions of a language to just provide a
   subset of the strings and fall back to the standard language strings. You
   can require all regions to provide a full translation by setting the
   environment variable ANDROID_LINT_COMPLETE_REGIONS.

   You can tell lint (and other tools) which language is the default language
   in your res/values/ folder by specifying tools:locale="languageCode" for
   the root <resources> element in your resource file. (The tools prefix
   refers to the namespace declaration http://schemas.android.com/tools.)

2 errors, 0 warnings
:app:lintVitalProductionRelease
:app:assembleProductionRelease
:app:assembleRelease

BUILD SUCCESSFUL in 7m 28s

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的Android登录注册页面示例,使用SQLite数据库来存储和验证用户信息。 首先,在Android Studio创建一个新项目。然后添加SQLite依赖项,可以在app/build.gradle文件添加以下代码: ```gradle dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.sqlite:sqlite:2.1.0' } ``` 接下来,我们需要创建一个SQLiteOpenHelper类来管理我们的数据库,可以在MainActivity.java文件添加以下代码: ```java import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; public class DBHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; private static final String DATABASE_NAME = "user.db"; public static final String TABLE_NAME = "users"; public static final String COLUMN_ID = "id"; public static final String COLUMN_USERNAME = "username"; public static final String COLUMN_PASSWORD = "password"; public DBHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { String CREATE_USERS_TABLE = "CREATE TABLE " + TABLE_NAME + "(" + COLUMN_ID + " INTEGER PRIMARY KEY," + COLUMN_USERNAME + " TEXT," + COLUMN_PASSWORD + " TEXT" + ")"; db.execSQL(CREATE_USERS_TABLE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); onCreate(db); } } ``` 上面的代码创建了一个名为"user.db"的数据库,并且定义了一个名为"users"的表,包含id、username和password三个列。 接下来,我们需要在MainActivity.java添加以下代码来处理用户注册: ```java import androidx.appcompat.app.AppCompatActivity; import android.content.ContentValues; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity { private EditText usernameEditText, passwordEditText, confirmPasswordEditText; private Button registerButton; private DBHelper dbHelper; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); dbHelper = new DBHelper(this); usernameEditText = findViewById(R.id.usernameEditText); passwordEditText = findViewById(R.id.passwordEditText); confirmPasswordEditText = findViewById(R.id.confirmPasswordEditText); registerButton = findViewById(R.id.registerButton); registerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String username = usernameEditText.getText().toString(); String password = passwordEditText.getText().toString(); String confirmPassword = confirmPasswordEditText.getText().toString(); if (username.isEmpty() || password.isEmpty() || confirmPassword.isEmpty()) { Toast.makeText(MainActivity.this, "Please fill all fields!", Toast.LENGTH_SHORT).show(); } else if (!password.equals(confirmPassword)) { Toast.makeText(MainActivity.this, "Passwords do not match!", Toast.LENGTH_SHORT).show(); } else { SQLiteDatabase db = dbHelper.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(DBHelper.COLUMN_USERNAME, username); values.put(DBHelper.COLUMN_PASSWORD, password); long id = db.insert(DBHelper.TABLE_NAME, null, values); if (id != -1) { Toast.makeText(MainActivity.this, "Registration successful!", Toast.LENGTH_SHORT).show(); usernameEditText.setText(""); passwordEditText.setText(""); confirmPasswordEditText.setText(""); } else { Toast.makeText(MainActivity.this, "Registration failed!", Toast.LENGTH_SHORT).show(); } } } }); } } ``` 上面的代码处理了用户的注册,首先检查输入的表单是否为空,然后检查两次输入的密码是否匹配。如果输入正确,将新用户的信息插入到数据库,并显示成功或失败的消息。 最后,我们需要在MainActivity.java添加以下代码来处理用户登录: ```java import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity { private EditText usernameEditText, passwordEditText; private Button loginButton, registerButton; private DBHelper dbHelper; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); dbHelper = new DBHelper(this); usernameEditText = findViewById(R.id.usernameEditText); passwordEditText = findViewById(R.id.passwordEditText); loginButton = findViewById(R.id.loginButton); registerButton = findViewById(R.id.registerButton); loginButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String username = usernameEditText.getText().toString(); String password = passwordEditText.getText().toString(); if (username.isEmpty() || password.isEmpty()) { Toast.makeText(MainActivity.this, "Please fill all fields!", Toast.LENGTH_SHORT).show(); } else { SQLiteDatabase db = dbHelper.getReadableDatabase(); String[] projection = {DBHelper.COLUMN_ID}; String selection = DBHelper.COLUMN_USERNAME + " = ? AND " + DBHelper.COLUMN_PASSWORD + " = ?"; String[] selectionArgs = {username, password}; Cursor cursor = db.query(DBHelper.TABLE_NAME, projection, selection, selectionArgs, null, null, null); if (cursor.moveToFirst()) { Toast.makeText(MainActivity.this, "Login successful!", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(MainActivity.this, HomeActivity.class); startActivity(intent); } else { Toast.makeText(MainActivity.this, "Invalid username or password!", Toast.LENGTH_SHORT).show(); } cursor.close(); } } }); registerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, RegisterActivity.class); startActivity(intent); } }); } } ``` 上面的代码处理了用户的登录,首先检查输入的表单是否为空,然后在数据库查找匹配的用户名和密码。如果找到了匹配项,则显示成功的消息并跳转到主页Activity。否则,会显示无效的用户名或密码的消息。 最后,我们需要创建一个名为"HomeActivity.java"的新Activity来显示用户登录后的主页视图。 这就是一个简单的Android登录注册页面,使用SQLite数据库来存储和验证用户信息的实现方法。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值