最近Android应用开发中碰到的几个问题

Posted scruffybear

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了最近Android应用开发中碰到的几个问题相关的知识,希望对你有一定的参考价值。

文章目录

小结

最近android应用开发中碰到的几个问题,进行了解决。

问题及解决

One or more layouts are missing the layout_width or layout_height attributes

渲染问题: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts.

参考Stackoverflow: Rendering Problems NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts,此种问题有建议是清除缓存。
最终的解决办法是加上缺少的属性。

导入库(Library)

首先导入库,File ->Project Structure -> App-> dependencies -> + ->add library,接下来在build.gradle里添加dependencies

dependencies 

    // Internal application-level dependencies
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    // Internal application library/module dependencies
    implementation project(':libPrinter')

    // Internal application pre-built library/module dependencies
    implementation project(':libraries:libInquiry')

...
以下省略

Task ‘wrapper’ not found in project ‘:app’

报错: Task 'wrapper' not found in project ':app'

解决办法,在相应的build.gradle里添加:

task wrapper(type: Wrapper)
    gradleVersion = '7.2'

Task ‘prepareKotlinBuildScriptModel’ not found in project ‘:app’

报错:Task 'prepareKotlinBuildScriptModel' not found in project ':app'

解决办法,在相应的build.gradle里添加:

task prepareKotlinBuildScriptModel 


error: resource color类型错误

报错: error: resource color/purple_500 not found

解决办法,在color.xml中把颜色类型添加上:

    <color name="purple_200">#FFBB86FC</color>
    <color name="purple_500">#FF6200EE</color>
    <color name="purple_700">#FF3700B3</color>
    <color name="teal_200">#FF03DAC5</color>
    <color name="teal_700">#FF018786</color>

参考

Stackoverflow: Rendering Problems NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts
Stackoverflow: access jar in project from imported library - gradle / android studio
Stackoverflow: How do I fix this error: Task ‘wrapper’ not found in project ‘:app’
Stackoverflow: Task ‘prepareKotlinBuildScriptModel’ not found in project ‘:app’
CSDN: AAPT: error: resource color类型错误

以上是关于最近Android应用开发中碰到的几个问题的主要内容,如果未能解决你的问题,请参考以下文章

从 Android 中最近的应用程序中刷出应用程序时服务停止

在android中获取最近的街道/道路坐标

常见的Android编译优化问题

Android开发中碰到的一个ANR问题。

Android开发新手常见的10个误区

最近碰到的几个问题