我需要将一个工作项目从Eclipse导入到Android Studio 2.1,并从Gradle Console获得以下消息
执行任务:[:app:generateDebugSources,:app:mockableAndroidJar,:app:prepareDebugUnitTestDependencies,:app:generateDebugAndroidTestSources]
按需配置是一项孵化功能。 增量java编译是一个孵化功能。 :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :应用:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :应用:prepareComAndroidSupportAnimatedVectorDrawable2330Library :应用:prepareComAndroidSupportAppcompatV72330Library :应用:prepareComAndroidSupportSupportV42330Library :应用:prepareComAndroidSupportSupportVectorDrawable2330Library :应用:prepareDebugDependencies :应用:compileDebugAidl :应用:compileDebugRenderscript :app:generateDebugBuildConfig UP-TO-DATE :app:mergeDebugShaders UP-TO-DATE :应用:compileDebugShaders :应用:generateDebugAssets :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :应用:generateDebugResources :应用:mergeDebugResources :应用:processDebugManifest :应用:processDebugResources AGPBI:{“kind”:“error”,“text”:“解析XML时出错:格式不正确(无效令牌)”,“来源”:[{“file”:“C:\ Users \ advanchip \ StudioProjects \移动ControlledLighting \应用\ SRC \主\ RES \布局\ dialog_add_gateway.xml”, “位置”:{ “STARTLINE”:0}}], “原”: “”, “工具”: “AAPT”}
FAILED
失败:构建因异常而失败。
出了什么问题: 任务':app:processDebugResources'的执行失败。
com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'命令'C:\ Users \ advanchip \ AppData \ Local \ Android \ sdk \ build-tools \ 23.0。 3 \ aapt.exe''以非零退出值1结束
尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。
建立失败
总时间:12.676秒
The codes of the xml file is
<!DOCTYPE LinearLayout [<!ELEMENT LinearLayout (LinearLayout|Spinner|EditText|Button)*><!ATTLIST LinearLayoutandroid:background CDATA #IMPLIEDandroid:gravity CDATA #IMPLIEDandroid:id CDATA #IMPLIEDandroid:layout_height CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:orientation CDATA #REQUIREDandroid:paddingBottom CDATA #IMPLIEDandroid:paddingLeft CDATA #IMPLIEDandroid:paddingRight CDATA #IMPLIEDandroid:paddingTop CDATA #IMPLIEDxmlns:android CDATA #IMPLIEDxmlns:tools CDATA #IMPLIED><!ELEMENT Spinner (#PCDATA)><!ATTLIST Spinnerandroid:id CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:layout_height CDATA #REQUIREDandroid:layout_gravity CDATA #REQUIREDandroid:layout_marginTop CDATA #REQUIREDandroid:background CDATA #REQUIREDandroid:maxLines CDATA #REQUIREDandroid:paddingBottom CDATA #REQUIREDandroid:paddingTop CDATA #REQUIREDandroid:textStyle CDATA #REQUIRED><!ELEMENT EditText (#PCDATA)><!ATTLIST EditTextandroid:id CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:layout_height CDATA #REQUIREDandroid:layout_gravity CDATA #REQUIREDandroid:layout_marginTop CDATA #REQUIREDandroid:background CDATA #REQUIREDandroid:hint CDATA #REQUIREDandroid:maxLines CDATA #REQUIREDandroid:paddingBottom CDATA #REQUIREDandroid:paddingLeft CDATA #REQUIREDandroid:paddingRight CDATA #REQUIREDandroid:paddingTop CDATA #REQUIREDandroid:singleLine CDATA #REQUIREDandroid:textColor CDATA #REQUIREDandroid:textStyle CDATA #REQUIRED><!ELEMENT Button (#PCDATA)><!ATTLIST Buttonandroid:background CDATA #REQUIREDandroid:id CDATA #REQUIREDandroid:layout_gravity CDATA #REQUIREDandroid:layout_height CDATA #REQUIREDandroid:layout_marginTop CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:text CDATA #REQUIREDandroid:textSize CDATA #REQUIRED>]>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#011f4b"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<LinearLayout
android:id="@+id/add_gateway_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Spinner
android:id="@+id/gatewaySerial"
android:layout_width="match_parent"
android:layout_height="40sp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20sp"
android:background="@drawable/rect_text_edit"
android:maxLines="1"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:textStyle="bold"
/>
<EditText
android:id="@+id/gatewayName"
android:layout_width="match_parent"
android:layout_height="40sp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10sp"
android:background="@drawable/rect_text_edit"
android:hint="Gateway Name"
android:maxLines="1"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:singleLine="true"
android:textColor="#008bcb"
android:textStyle="bold" />
<Button
android:id="@+id/add_gateway_button"
android:layout_width="200sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:background="@drawable/submit_button_bg"
android:text="Create Gateway"
android:textSize="18sp" />
<Button
android:id="@+id/dialog_cancel"
android:layout_width="200sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:background="@drawable/submit_button_bg"
android:text="Cancel"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
应用程序build.gradle的代码是
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.advanchip.mobile_controlledlighting"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
//compile 'com.android.support:support-v4:22.2.0'
//compile 'com.android.support:appcompat-v7:22.2.0'
//compile "com.android.support:support-v4:18.0.+"
//compile "com.android.support:appcompat-v7:18.0.+"
compile files('libs/commons-lang-2.6.jar')
compile files('libs/commons-logging-1.1.2.jar')
compile files('libs/httpmime-4.0.1.jar')
compile files('libs/smartconfiglib.jar')
}
The image of Android SDK Manager
The codes of rect_text_edit.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffffff" />
</shape>
The codes of submit_button_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@color/button_pressed" />
<item android:state_enabled="true"
android:drawable="@color/button_normal" />
</selector>
Please advise, thanks.
答案 0 :(得分:-1)
您的XML中有一行无关紧要删除以下行
<!DOCTYPE LinearLayout [<!ELEMENT LinearLayout (LinearLayout|Spinner|EditText|Button)*><!ATTLIST LinearLayoutandroid:background CDATA #IMPLIEDandroid:gravity CDATA #IMPLIEDandroid:id CDATA #IMPLIEDandroid:layout_height CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:orientation CDATA #REQUIREDandroid:paddingBottom CDATA #IMPLIEDandroid:paddingLeft CDATA #IMPLIEDandroid:paddingRight CDATA #IMPLIEDandroid:paddingTop CDATA #IMPLIEDxmlns:android CDATA #IMPLIEDxmlns:tools CDATA #IMPLIED><!ELEMENT Spinner (#PCDATA)><!ATTLIST Spinnerandroid:id CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:layout_height CDATA #REQUIREDandroid:layout_gravity CDATA #REQUIREDandroid:layout_marginTop CDATA #REQUIREDandroid:background CDATA #REQUIREDandroid:maxLines CDATA #REQUIREDandroid:paddingBottom CDATA #REQUIREDandroid:paddingTop CDATA #REQUIREDandroid:textStyle CDATA #REQUIRED><!ELEMENT EditText (#PCDATA)><!ATTLIST EditTextandroid:id CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:layout_height CDATA #REQUIREDandroid:layout_gravity CDATA #REQUIREDandroid:layout_marginTop CDATA #REQUIREDandroid:background CDATA #REQUIREDandroid:hint CDATA #REQUIREDandroid:maxLines CDATA #REQUIREDandroid:paddingBottom CDATA #REQUIREDandroid:paddingLeft CDATA #REQUIREDandroid:paddingRight CDATA #REQUIREDandroid:paddingTop CDATA #REQUIREDandroid:singleLine CDATA #REQUIREDandroid:textColor CDATA #REQUIREDandroid:textStyle CDATA #REQUIRED><!ELEMENT Button (#PCDATA)><!ATTLIST Buttonandroid:background CDATA #REQUIREDandroid:id CDATA #REQUIREDandroid:layout_gravity CDATA #REQUIREDandroid:layout_height CDATA #REQUIREDandroid:layout_marginTop CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:text CDATA #REQUIREDandroid:textSize CDATA #REQUIRED>]>