编译报错

1、Error:Could not find com.android.support:recyclerview-v7:23.4.0.
解决方法:

update from android studio: Help -> Check for Update... And Installed API level 23

参考:stackoverflow

2、有时候从github Clone的项目在本地运行会报如下错误:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
>com.android.build.api.transform.TransformException: java.lang.RuntimeException:
 com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException:
 com.android.ide.common.process.ProcessException:
 org.gradle.process.internal.ExecException: Process 'command '
D:\ProgramTools\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

解决方法:
检查自己原有(可运行)项目build.gradletargetSdkVersion是否与该项目的一致(Ctrl + shift + f :快速定位到项目的targetSdkVersion位置)。如果不一致的话改为原有项目的targetSdkVersion
参考:stackoverflow

3、Error:Gradle DSL method not found: ‘android()’

Paste_Image.png

解决方法:
删掉最外层的build.gradle中的

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
}

感谢:黄龙
参考:stackoverflow

4、
Error: Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features:{
windowActionBar: false,
windowActionBarOverlay: false,
android:windowIsFloating: false,
windowActionModeOverlay: false,
windowNoTitle: false
}

原因:style文件编写错误

<style name="AppTheme.Base" parent="Theme.AppCompat">
    <item name="windowActionBar">false</item>
    <!-- 使用 API Level 22 編譯的話,要拿掉前綴字 (android:): <item name=":windowNoTitle">true</item>-->
    <item name="android:windowNoTitle">true</item>//报如上错误应去掉前缀android
</style>

参考:android:ToolBar详解(手把手教程)

5、Error: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

本次bug的引入是因为添加了style.xml (value 19) ,其Parent Theme与app 中theme.xml中的不一致,故,该bug只在android 4.4 上重现。

<resources>
    <style name="AppTheme" parent="@style/AppBaseTheme"><!--<style name="AppBaseTheme" parent="android:Theme.Holo.Light">-->
        <item name="android:windowTranslucentNavigation">true</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>

6、Error: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
出现该错误时依赖版本:

    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:support-v13:23.3.0'
    compile 'com.android.support:design:24.1.1'
    compile 'com.android.support:recyclerview-v7:23.2.1'
ANDROID_BUILD_TOOLS_VERSION=23.0.2

解决方法:更新依赖版本至最新,均为24.2.0,ANDROID_BUILD_TOOLS_VERSION=23.0.3

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容