【问题标题】:Each time when I start new Android studio project this error occurred每次我启动新的 Android Studio 项目时都会发生此错误
【发布时间】:2017-04-21 19:21:51
【问题描述】:

每次我开始一个新项目时都会出现这个错误 请任何人帮助我...... android studio中是否缺少某些东西

content_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.shareque.myapplication.MainActivity"
    tools:showIn="@layout/app_bar_main">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

信息:Gradle 任务 [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources] E:\myapps\BetaApps\Digitalworldapp\app\src\main\res\layout\content_main.xml 错误:(15, 49) 不允许使用字符串类型(在 'layout_constraintBottom_toBottomOf' 处,值为 'parent')。 错误:(16, 45) 不允许使用字符串类型(在 'layout_constraintLeft_toLeftOf' 处,值为 'parent')。 错误:(17, 47) 不允许使用字符串类型(在 'layout_constraintRight_toRightOf' 处,值为 'parent')。 错误:(18, 43) 不允许使用字符串类型(在 'layout_constraintTop_toTopOf' 处,值为 'parent')。 E:\myapps\BetaApps\Digitalworldapp\app\build\intermediates\res\merged\debug\layout\content_main.xml 错误:(15, 49) 不允许使用字符串类型(在 'layout_constraintBottom_toBottomOf' 处,值为 'parent')。 错误:(16, 45) 不允许使用字符串类型(在 'layout_constraintLeft_toLeftOf' 处,值为 'parent')。 错误:(17, 47) 不允许使用字符串类型(在 'layout_constraintRight_toRightOf' 处,值为 'parent')。 错误:(18, 43) 不允许使用字符串类型(在 'layout_constraintTop_toTopOf' 处,值为 'parent')。 错误:任务 ':app:processDebugResources' 执行失败。

com.android.ide.common.process.ProcessException:无法执行 aapt 信息:构建失败 信息:总时间:7.672 秒 信息:9 个错误 信息:0 个警告 信息:在控制台中查看完整的输出

【问题讨论】:

  • 你是否包含了 ConstraintLayout 的依赖关系?
  • 我也有同样的问题。您是否使用现有的 SDK 更改安装?

标签: android android-layout android-studio


【解决方案1】:

更改约束布局依赖后问题解决
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'

 compile 'com.android.support.constraint:constraint-layout:1.0.1'

在应用级 Gradle 文件中

【讨论】:

    【解决方案2】:

    如果您安装了 Android Studio 并使用了现有且过时的 Android SDK 安装(就像我最近所做的那样),您可能必须从 Support Repository 安装新的 ConstraintLayout 库。之后,您可能需要在应用程序的 build.gradle 文件中调整使用的依赖项(就像您所做的那样)。

    从那时起,当您使用 Android Studio 启动一个新项目时,正确的依赖项将包含在 build.gradle 中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      • 2017-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多