赞
踩
最近将自己以前记录的AndroidStudio 使用过程中遇到的问题整理了下,里面是我开发中遇到的问题和收集的已经验证过的方法,记录下来,方便以后查找,欢迎补充
1、AS导第三方项目一直在Building的解决方法
有时候当我们导入开源项目的时候 会卡顿甚至死机 这是因为我们本地已有的配置和开源项目的不一样 这时候Android studio就会去下载 而且下载是要翻墙的 所以会出现这种情况 那么我们怎么避免下载没用的资源呢 请看:
原因:
解决方法:去掉红色箭头指向的勾
- compileSdkVersion 23
- buildToolsVersion "23.0.3"
minSdkVersion 16 targetSdkVersion 23
compile 'com.android.support:appcompat-v7:23.2.0'
错误行为:
Error:Unable to start the daemon process: could not reserve enough space for object heap.
Please assign more memory to Gradle in the project's gradle.properties file.
For example, the following line, in the gradle.properties file, sets the maximum Java heap size to 1,024 MB:
Error org.gradle.jvmargs=-Xmx1024m
Read Gradle's configuration guide
Read about Java's heap size
解决方案一:
修改项目gradle.properties文件,添加下面一行代码:
org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m
解决方案二:推荐,一次解决新建项目 jvm 问题
在个人文件夹( (C:/Users/username/.gradle 或 ~/.gradle))下创建 gradle.properties 文件,添加
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=256m,或则拷贝之前正常运行的项目的
gradle.properties 文件
主要是因为 AS 的 buildToolsVersion 版本与Java JDK的版本不同所致,这样的错误而有两个解决办法,第一个是重装Java JDK,降到 JDK 1.7
第二种方法是,降低 buildToolsVersion 的版本 比如 buildToolsVersion"24.0.1" 降到 buildToolsVersion"23.0.3" 重新编译就OK了
8、Android Studio Gradle project “Unable to start the daemon process /initialization of VM”
法一:
当在AndroidManifest.xml文件的application的节点设置了属性:
android:theme="@android:style/Theme.NoTitleBar
而Activity继承了ActionBarActivity就回出现上述错误,解决的办法就是让Activity去继承Activity而不是ActionBarActivity
改完之后删掉报错的部分,然后别忘了导入Activity包
法二:
在AndroidMenifest.xml中加入一句:
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
例子:
- <activity
- android:name="com.vmoksha.BaseActivity"
- android:label="@string/app_name"
- android:theme="@style/Theme.AppCompat.Light.NoActionBar"
- >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
然后在styles.xml中加入主题资源:
- <style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light">
- <item name="android:windowNoTitle">true</item>
- </style>
9、处理Gradle中的文件下载慢的问题的?
- buildscript {
- repositories {
- maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
- }
- }
-
- allprojects {
- repositories {
- maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
- }
- }
然后选择重新构建项目就可以了Java.lang.RuntimeException: Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication: java.lang.ClassNotFoundException: Didn't find class "com.android.tools.fd.runtime.BootstrapApplication" on path: DexPathList[[zip file "/data/app/com.dlcoder.test.apk"],nativeLibraryDirectories=[/data/app-lib/com.dlcoder.test.apk, /vendor/lib, /system/lib]]
原因:Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> compileSdkVersion 'android-25' requires JDK 1.8 or later to compile.
原因:builTool 版本和 SDK Tool 版本不一致,compileSdkVersion 25需要JDK1.8,
- compileSdkVersion 23
- buildToolsVersion "23.0.3"
- minSdkVersion 16
- targetSdkVersion 23
- compile 'com.android.support:appcompat-v7:23.2.0'
13、
cannot resolve corresponding JNI function
错误提示为:
Cannot resolve corresponding JNI function Java_com_keepassdroid_crypto native_AesCipherSPI_Update
Reports native method declaration in Java where no corresponding JNI function is found in the project.
解决办法:
1.File--->Settings--->Plugins,将Android NDK Support(如下图中第一项)后面的对勾去掉。
had easy steps & correct way also
1 - In Settings
-> Build, Execution, Deployment
option -> Instant Run
2 - Clear Enable instant run to hot swap code
3 - Clean project
17、
Error:Failed to complete Gradle execution. Cause: 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: -----------------------
- buildscript {
- repositories {
- maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
- }
- }
-
- allprojects {
- repositories {
- maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
- }
- }
然后选择重新构建项目就可以了
已验证
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。