【问题标题】:Layout preview don't show with android 3.0.1android 3.0.1 不显示布局预览
【发布时间】:2018-03-01 11:09:38
【问题描述】:

我的布局预览是 empty 并且不显示渲染问题我使用的是 android studio 3.0.1 这是我的:

build.gradle(app)

    apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'


android {
    signingConfigs {
        config {
        }
    }
    compileSdkVersion 27
    buildToolsVersion '27.0.2'
    defaultConfig {

        applicationId "com.example.epa.ouza_rebuild"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}
repositories {
    maven {
        url 'https://dl.bintray.com/spark/maven'
    }
    maven {
        url 'https://maven.google.com'
    }
    mavenCentral()
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile files('libs/android-query-full.0.26.7.jar')
    //new library from github
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'me.spark:submitbutton:1.0.1'
    compile "com.squareup.picasso:picasso:2.4.0"
    compile 'com.google.firebase:firebase-database:11.8.0'
    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-crash:11.8.0'
    compile 'com.google.firebase:firebase-auth:11.8.0'
    compile 'com.google.android.gms:play-services-auth:11.8.0'
    compile 'com.google.firebase:firebase-storage:11.8.0'
    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.android.support:design:27.0.2'
    compile 'com.firebaseui:firebase-ui-database:2.3.0'
    compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
    compile 'com.android.support:cardview-v7:27.0.2'
    compile 'com.github.medyo:fancybuttons:1.8.4'
    compile 'io.saeid:fab-loading:1.0.0'
    compile 'junit:junit:4.12'
    compile 'com.github.bumptech.glide:glide:4.6.1'
    testCompile 'junit:junit:4.12'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
android {
    // Fixed build error : Duplicate files copied in APK META-INF/xxx
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
    }
}
apply plugin: 'kotlin-android-extensions'

build.gradle(project)

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

buildscript {
    ext.kotlin_version = '1.2.21'
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }

        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

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

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://jitpack.io"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }

}

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

清单:

   <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.epa.ouza_rebuild">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:allowBackup="true"
        android:fullBackupContent="@xml/backup_descriptor"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Ajouter" />
        <activity
            android:name=".Home2"
            android:label="@string/title_activity_home2" />
        <activity android:name=".ItemDetails" />
        <activity android:name=".WishList" />
        <activity android:name="connexion_et_inscription.Log1" />
        <activity android:name="connexion_et_inscription.Log2" />
        <activity android:name="connexion_et_inscription.Inscris" />
        <activity android:name=".Profile"/>
    </application>

</manifest>

我尝试过:

  • 使缓存失效并重启android studio
  • 同步项目 gradle
  • 将 API 级别更改为 26、25、24、23、21
  • 将应用程序主题更改为 AppTheme 或 Holo
  • 创建新活动,新项目,但同样的问题继续存在

请帮帮我,我是不是搞错了?

【问题讨论】:

  • 你想将 compile 更改为 implementation 并且你的 gradle 中还缺少一行
  • 在哪一行?
  • implementation 'com.android.support:appcompat-v7:26.1.0' build.gradle(app) 中缺少这一行
  • @MohammadAli 有 implementation 'com.android.support:appcompat-v7:27.0.2' 我应该添加吗?

标签: android layout preview


【解决方案1】:

自从我导入并添加了一些材料组件后,我遇到了同样的问题。如果您在项目中添加任何材料组件,我认为这就是问题所在。

对于是否是材质组件问题的测试,首先使缓存无效并重新启动,然后当android studio重新启动时,不要再次打开受感染的布局,因为它会破坏所有显示的android布局预览和然后测试其他没有任何材料成分的东西:)

不过不用担心,下个版本会修复的。

注意:感谢 Johnny Zen 的报告here。

【讨论】:

    猜你喜欢
    • 2016-04-02
    • 1970-01-01
    • 1970-01-01
    • 2018-11-20
    • 1970-01-01
    • 2022-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多