android studio 无法预览 Layout 布局 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
doublemark
V2EX    Android

android studio 无法预览 Layout 布局

  •  
  •   doublemark 2019-02-26 11:31:02 +08:00 13786 次点击
    这是一个创建于 2494 天前的主题,其中的信息可能已经有所发展或是发生改变。

    没法贴图,之前还是没问题的,现在打开 Design 标签,预览图是空白,中间显示 android...DrawerLayout Build.gradle 如下: apply plugin: 'com.android.application'

    android { compileSdkVersion 28 efaultConfig { applicationId "com.example.nettywificomp" minSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } } buildToolsVersion '28.0.3' }

    dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support:design:28.0.0' implementation 'de.hdodenhof:circleimageview:2.1.0' implementation 'javolution:javolution:5.3.1' implementation 'com.contrarywind:Android-PickerView:4.1.7' implementation 'com.github.huangyanbin:SmartTable:2.2.0' implementation 'com.github.GrenderG:Toasty:1.4.0' implementation 'com.nbsp:library:1.8' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }

    看 StackOverflow 提示说降到 27,但是降到 27 还是一堆 Error 有遇到过这个问题的吗,求助。

    5 条回复    2019-02-27 00:15:25 +08:00
    xbigfat
        1
    xbigfat  
       2019-02-26 11:44:34 +08:00
    无法预览是因为 Gradle 没有 Fully Sync 所以资源有错误。
    高阶 compileSdkVersion 降级到低阶会出现资源错误,特别是 Theme 之类的 Resource 文件错误
    建议就用 28 降下来要删除很多东西的和依赖
    xbigfat
        2
    xbigfat  
       2019-02-26 11:48:48 +08:00
    还有就是代码贴的规范一点,帮你尝试格式化了不知道会不会成功。。。
    ```
    android {
    compileSdkVersion 28 defaultConfig {
    applicationId "com.example.nettywificomp" minSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    } buildTypes {
    release {
    minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release
    }
    } buildToolsVersion '28.0.3'
    }

    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'javolution:javolution:5.3.1'
    implementation 'com.contrarywind:Android-PickerView:4.1.7'
    implementation 'com.github.huangyanbin:SmartTable:2.2.0'
    implementation 'com.github.GrenderG:Toasty:1.4.0'
    implementation 'com.nbsp:library:1.8'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    }
    ```
    zoeyzhang
        3
    zoeyzhang  
       2019-02-26 15:00:25 +08:00
    预览不了的话 可以先看下 design 页的 issues 会有 warning 和 error 提示 可能是高版本 theme 不兼容的问题
    diy886
        4
    diy886  
       2019-02-26 16:37:06 +08:00
    项目能运行吗,不能的话先调通
    试试预览界面改 theme 和 invalidate cache/restart
    huruwo
        5
    huruwo  
       2019-02-27 00:15:25 +08:00
    theme 继承 base 试试 我就是预览不了说主题样式问题 改成 base 就行
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5293 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 43ms UTC 01:39 PVG 09:39 LAX 17:39 JFK 20:39
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86