[связанный код ошибки в MainActivity.kt] [2]
Я пробовал fn + option + return (Mac IOS) для целей импорта, но все еще не работает. То же самое, что пытаться сделать кэши недействительными и перезапустить. Они не работают!
Я просто следую лекции профессора шаг за шагом. Версия для студии Android на моем macbook - 3.5.1
. Требуется помощь.
Я также столкнулся с другой ошибкой. Вот код для AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.assignment3muyaozhang0882423" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:value="@integer/google_play_services_version" />
<activity android:name=".Floating_label" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" >
</activity>
</application>
</manifest>
Ошибка, с которой я столкнулся, это ошибка синхронизации: ОШИБКА: не удалось проанализировать XML в / Users / kitty / Downloads / Assignment2MuyaoZhang0882423 / app / src / main / AndroidManifest.xml org.xml.sax.SAXParseException;systemId: file: /Users/kitty/Downloads/Assignment2MuyaoZhang0882423/app/src/main/AndroidManifest.xml;номер строки: 23;номер столбца: 4;Manif 类型 "manifest" ffected 由 匹配 的 结束 "" "终止。 Затронутые модули: app
Код приложения:
применить плагин: 'com.android.application'
применить плагин: 'kotlin-android'
применить плагин: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.assignment3muyaozhang0882423"
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = kotlin_version
targetCompatibility = kotlin_version
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support:design:29.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
код для файла kt:
package com.example.assignment3muyaozhang0882423
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.R
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
import android.widget.Toast.makeText
class setion2 : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_setion2)
val usernamestring = text_Person_Name.text
val passwordstring = text_Password.text
val con_btn = (Button) findViewById(R.id.con_btn) as Button
con_btn.isAllCaps = false
con_btn.setOnClickListener {
if (this.usernamestring.isNotEmpty() && this.passwordstring.isNotEmpty())
{
val message =
"User Name: " + usernamestring + "\n" + "Password: " + this.passwordstring
Toast.makeText(this, message, LENGTH_LONG).show()
} else {
Toast.makeText(this, "Please enter valid input", LENGTH_LONG).show()
}
}
}
}