gpt4 book ai didi

android - Gradle同步失败,并出现错误:无法解析XML

转载 作者:行者123 更新时间:2023-12-03 04:11:10 25 4
gpt4 key购买 nike

我在Gradle中有一个错误。我试图重新启动计算机和程序,但没有任何改变。我在说ParseError at [row,col]:[17,9]
Message: expected start or end tag
时遇到了同样的错误

我试图在第17行找到不正常的东西,但对我来说一切正常。
在文件build.gradle中,当我单击某些行时,它提出了一些新版本,因此通常所有内容都是最新的。

我还查看了该站点,以查找它是否可以解决我的问题,但是对FAILURE: Gradle Build failed with an exception没有帮助

build.gradle应用程序

apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 18
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'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.ads.mediation:facebook:5.5.0.0'
implementation 'com.google.android.gms:play-services-ads:11.4.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
androidTestImplementation 'androidx.test:runner:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'


}

build.gradle信息
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'


}

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}


allprojects {
repositories {
google()
jcenter()
maven{
url "https://maven.google.com"
}

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

可以帮助您的xml代码
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">



<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:adSize="BANNER"
app:adUnitId="ca-app-pub-2945227826409900/1799805283"></com.google.android.gms.ads.AdView>

<TableRow
android:layout_width="match_parent"
android:layout_height="96dp">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="99dp"
android:ems="10"
android:inputType="textPersonName" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="search" />

<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="102dp"
android:layout_height="83dp" />

</TableRow>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="add some text" />

<Button
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Send" />
</LinearLayout>

</LinearLayout>

</LinearLayout>
</ScrollView>

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" />

</TableRow>


<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="586dp" />

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/textView4"
android:layout_width="432dp"
android:layout_height="531dp"
android:text="TextView" />

</LinearLayout>
</ScrollView>


</LinearLayout>


</androidx.constraintlayout.widget.ConstraintLayout>

android manifester
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.info">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

<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:launchMode="singleInstance"
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-2945227826409900~3138961208"/>
<activity android:name=".MainActivity">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

最佳答案

正如您在AndroidManifest.xml代码中看到的那样,以下行android:launchMode="singleInstance"不在任何标签中

删除它,然后错误将消失

您的AndroidManifest.xml应该像

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.info">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

<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">

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-2945227826409900~3138961208"/>
<activity android:name=".MainActivity">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

额外:-启动模式配置 android:launchMode="singleInstance"适用于 Activity

关于android - Gradle同步失败,并出现错误:无法解析XML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60015683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com