android studio 初探

将以前的项目转成Android studio,导入后,遇到一堆问题,真有点(ˇˍˇ) 想~放弃as了,编译要3到四分钟,跟eclipse性能比起来真得是差太多了。是不是as的语法检测等限制的太多了,build完后就崩溃了,在eclipse跑的好好的项目,在as上跑出来几百个error!瞬间蒙逼!

这里写图片描述

这里写图片描述


1、build tool 和 sdk 版本不一致,as自动识别并下载

2、drawable-hdpi的图片资源不是标准的.9的,看下面报的错误,找到相关图片,改成合法的。

Error:Execution failed for task ':yr_library:mergeDebugAndroidTestResources'.
> Error: java.lang.RuntimeException: Crunching Cruncher imcc_from_server.9.png failed, see logs

3、 AS的Gradle插件默认会启用Manifest Merger Tool,若Library项目中也定义了与主项目相同的属性(例如默认生成的android:icon和android:theme),则此时会合并失败,并报下面的错误。

解决办法:

方法1:在Manifest.xml的application标签下添加tools:replace=”android:icon, android:theme”(多个属性用,隔开,并且记住在manifest根标签上加入xmlns:tools=”http://schemas.android.com/tools”,否则会找不到namespace哦)

方法2:在build.gradle根标签上加上useOldManifestMerger true (懒人方法)

参考官方介绍:

http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger

Error:(26, 9) Attribute application@icon value=(@drawable/logo) from AndroidManifest.xml:26:9

Error:(28, 9) Attribute application@theme value=(@style/ThemeActionBar) from AndroidManifest.xml:28:9
is also present at XXXX-trunk:XXXXLib:unspecified:15:9 value=(@style/AppTheme)
Suggestion: add ‘tools:replace=”android:theme”‘ to  element at AndroidManifest.xml:24:5 to override
Error:Execution failed for task ‘:XXXX:processDebugManifest’.

> Manifest merger failed with multiple errors, see logs

4、当Android Studio中编译java方面的代码,出现类似的警告:

有关详细信息, 请使用 -Xlint:deprecation 重新编译。
有关详细信息, 请使用 -Xlint:unchecked 重新编译。
时,去项目对应的build.gradle中添加配置:

allprojects {
    repositories {
        jcenter()
    }
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }

    }
}

即可消除警告。

为什么这么麻烦!!!还有无数问题。。。

AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027android:TextAppearance.Material.Widget.Button.Inverse\u0027.","sources":[{"file":"O:\\AndroidStudioProjects\\NF9530L\\lTE_DW_FOR_PAD\\build\\intermediates\\res\\merged\\debug\\values-v23\\values-v23.xml","position":{"startLine":3}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027android:Widget.Material.Button.Colored\u0027.","sources":[{"file":"O:\\AndroidStudioProjects\\NF9530L\\lTE_DW_FOR_PAD\\build\\intermediates\\res\\merged\\debug\\values-v23\\values-v23.xml","position":{"startLine":33}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027android:TextAppearance.Material.Widget.Button.Borderless.Colored\u0027.","sources":[{"file":"O:\\AndroidStudioProjects\\NF9530L\\lTE_DW_FOR_PAD\\build\\intermediates\\res\\merged\\debug\\values-v24\\values-v24.xml","position":{"startLine":2}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027android:TextAppearance.Material.Widget.Button.Colored\u0027.","sources":[{"file":"O:\\AndroidStudioProjects\\NF9530L\\lTE_DW_FOR_PAD\\build\\intermediates\\res\\merged\\debug\\values-v24\\values-v24.xml","position":{"startLine":3}}],"original":"","tool":"AAPT"}

你可能感兴趣的:(android studio 初探)