【问题标题】:Upgrading to Android Studio 3.0 render error升级到 Android Studio 3.0 渲染错误
【发布时间】:2018-04-07 03:08:15
【问题描述】:

今天我将 Android Studio 更新到了版本。 3.0 之后我在布局编辑器中出现错误:

这是我的 gradle 文件:

    apply plugin: 'com.android.application'

android {
    def version = "2.4"
    def milestone = "1"
    def build = "5"
    def name = "WOMS" + "v" + version

    compileSdkVersion 23
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "hr.aprox_it.womsmobile"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.5"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            applicationVariants.all { variant ->
                appendVersionName(variant, defaultConfig)
            }
        }
    }
    sourceSets { main { java.srcDirs = ['src/main/java', 'src/main/java/2'] } }
}

def appendVersionName(variant, defaultConfig) {
    variant.outputs.each { output ->
        if (output.zipAlign) {
            //def file = output.outputFile
            //def fileName = file.name.replace("app-debug.apk", "WomsMobile-" + defaultConfig.versionName + "v.apk")
            //output.outputFile = new File(file.parent, fileName)
        }

        //def file = output.packageApplication.outputFile
        //def fileName = file.name.replace("app-debug.apk", "WomsMobile-" + defaultConfig.versionName + "v.apk")
        //output.packageApplication.outputFile = new File(file.parent, fileName)
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:23.4.0'
    testCompile 'junit:junit:4.12'
}

有人遇到过这个问题吗? 似乎每次更新 Android Studio 和 SDK 旧项目都有问题。

更新

在styles.xml中我改变了:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

问题解决了……我猜……没有更多的渲染错误了。如果有的话,我想听听其他人如何解决这个问题。

【问题讨论】:

  • 所以你没有任何带有 alignParent 东西的线性布局?

标签: android android-studio android-gradle-plugin render


【解决方案1】:

android:layout_alignParentLeft 属性仅在 View 的父级是 RelativeLayout 时有效。在 Android Studio 2.3 中,这只是一个警告:

Android Studio 3.0 似乎已将此升级为错误(至少在预览窗口方面)。继续删除此属性;反正它什么也没做。

【讨论】:

  • 我已经这样做了,但没有帮助。查看我更新的帖子有什么解决方案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-23
  • 2017-09-18
  • 1970-01-01
  • 1970-01-01
  • 2018-04-07
相关资源
最近更新 更多