#Android错误总结
博客撰写人:It一zhai男
转载请标明地址:http://blog.csdn.net/u013293125/article/details/52636929
最近一直想将自己编写程序时遇到的错误总结一下,但因为诸多原因一直都没付诸行动。这个错误总结本人将会不断更新,以下错误是本人遇到并解决了,编程工具Android studio 2.0。
**错误提示一**:
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Administrator\AppData\Local\Android\sdk1\build-tools\23.0.3\aapt.exe'' finished with non-zero exit value 1
**问题描述及解决办法**:如果你只改动了程序的某个小的部分,但是报这个错,只要点击Build->clear project就可以解决。
**错误提示二:**
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
> Could not find com.android.support:appcompat-v7:23.4.0.
Required by:
xcmg:app:unspecified
> Could not find com.google.android.gms:play-services-appindexing:8.1.0.
Required by:
xcmg:app:unspecified
> Could not find com.android.support:support-v4:23.4.0.
Required by:
xcmg:app:unspecified
**问题描述及解决办法**:如果你是导入新的已存在的代码,按如下步骤可解决问题(这是本人遇到的问题,不一定适合所有此类问题) **步骤1** 点击SDK Manager——>SDK Tools 勾选google respository——>apply然后跟着提示走即可。 ![这里写图片描述](https://img-blog.csdn.net/20161103094750341)
**步骤2**:上述步骤完成后,再点击Build——>clean project即可
**错误提示三:**
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
> Could not find com.android.support:appcompat-v7:23.4.0.
Required by:
xcmg:app:unspecified
> Could not find com.android.support:support-v4:23.4.0.
Required by:
xcmg:app:unspecified
> Could not find com.android.support:support-v4:23.4.0.
Required by:
xcmg:app:unspecified > com.google.android.gms:play-services-appindexing:8.1.0 > com.google.android.gms:play-services-basement:8.1.0
**问题描述及解决办法**:如果你是导入新的已存在的代码,按如下步骤可解决问题(这是本人遇到的问题,不一定适合所有此类问题)
**步骤1** 点击SDK Manager——>SDK Tools 勾选android support respository——>apply然后跟着提示走即可。 ![这里写图片描述](https://img-blog.csdn.net/20161103095412194)
**步骤2** 上述步骤完成后,再点击Build——>clean project即可
**错误提示四**
Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "e0a7992f192675817297767391b8206ce7252324"
<a href="fixGradleElements">Fix plugin version and sync project</a><br><a href="openFile:F:\Androidstudio\ListViewDemo\app\build.gradle">Open File</a>
**问题描述及解决办法**:如果你是在导入一个包时出现这个问题,那么按以下步骤来修改。
**步骤一**:打开build.gradle,找到classpath,如图
是这里的classpath值不对,那么,怎么设置这里的值呢?
**步骤二**:File——>project structure ![这里写图片描述](https://img-blog.csdn.net/20161103101421597)
**步骤三**:project——>将android plugin version里的内容写入步骤一的classpath里。
**步骤四**:上述步骤完成后,再点击Build——>clean project即可 (未完待续......)
**错误提示五**
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
**解决方案**:在工程的混淆配置文件 proguard-rules.pro 中加入下面这句代码即可: -keepattributes EnclosingMethod
**错误提示六**
All packages are not available for download!The following packages are not available:-Package id platforms;android-1
**解决方案**:抽出数据线然后重新插上。嗯,不要问我为什么,我就是这样解决的。
**错误提示七**
Error:(16, 0) Could not find method android() for arguments
**解决方案**:在工程的最外层的build.gradle文件里删除android{}
**问题提示八**
Could not find method compile() for arguments
**解决方案**:在工程的最外层的build.gradle文件里的dependencies删除complie内容。然后rebuild project和clean project.
**问题提示九**:
Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/3.3/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
**解决方案一**:在gradle.properties里添加
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
**解决方案二**:在C:\Users\yds(当前电脑用户名)\.gradle(如果没有新建)gradle.properties 文件里写下:
org.gradle.jvmargs=-Xmx1024m
**错误提示十**
android.view.InflateException: Binary XML file line #243: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
**解决方案**:布局文件中写了个view(布局文件中我写的v为小写,应该大写),改为View就行了。
**错误提示十一**:Failed to create jvm:error code -6
**解决方案**:在C:\Users\xxx(这里是电脑用户名,没有就是Admination)\.AndroidStudioxx.xx目录下删除studio.exe.vmoptions
**错误提示十二**:
android.content.res.Resources$NotFoundException: String resource ID #0x2
解决方案:当调用setText()方法时如果传入int型是不会被当成内容而是resourceID来使用!所以把int转成字符串类型
**错误提示十三**:
当使用NagivationView时报错:java.lang.reflect.InvocationTargetException
解决方案:(1)将Activity(入口Activity)写成CompatActivity;(2)将Manifest里将该Activity的theme改为@style/Theme.AppCompat的主题。
**错误提示十四**:
Error:(1, 1) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Could not create plugin of type 'AppPlugin'.
解决方案:是build.grade文件出问题,问题如下:
替换成如下所示
然后clear project