AndroidStudio常见问题

目录

一.Error:null value in entry: destinationDir=null


一.Error:null value in entry: destinationDir=null

         删掉根目录下的.gradle文件夹 然后重启as.

二.AS使用svg图标

         右击drawable -->new->Vector asset-->选择路径了 取好名字就行

三.Error:(134, 0) Gradle DSL method not found: 'compile()'

Error:(134, 0) Gradle DSL method not found: 'compile()'

Possible causes:<ul><li>The project 'Anzer4' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).

<a href="fixGradleElements">Upgrade plugin to version 2.3.3 and sync project</a></li><li>The project 'Anzer4' may be using a version of Gradle that does not contain the method.

<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.

<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

出现这种情况,就看看app/build.gradle文件里  是不是有两个compile语句在同一行的情况。

四.如果一个应用as安装没问题,但是单独安装apk就会闪退。

      这个时候可以把instance run选项先去掉试下。

 

五.解决adb连不上的问题

https://blog.csdn.net/lei___2011/article/details/79426455

http://adbdriver.com/downloads/

https://blog.csdn.net/ibaymin/article/details/72823239

六.Cmd adb locate 乱码的问题

 

 

七.清空logcat 缓存

adb logcat –c

八.全局File search ----文件名

Ctrl+shift +N

九.获取手机当前最上层的activity和包名

adb shell dumpsys activity | findstr "mFocusedActivity"

十.Ctrl+H 整个方法的继承树

 

十一.寻找文件的几个快捷键

十二.全局查找文本 Ctrl+Shift+F

在当前工程内查找文本【Ctrl+Shift+F】

可全部展开 以及缩小

十三.导入类文件

Alt+enter

十四.AndroidStudio-快捷键-格式化代码

Ctrl + Alt +L

十五.SHIFT+F6 ---> 改变名称

十六.Android studio实现Serializable自动生成serialVersionUID

点击类名

Alt+enter 生成UUID

十七.全局替换 Ctrl+shift+R



十八.单文件替换 Ctrl+R

十九.提取全局变量 Ctrl+alt+f

二十.显示红叉 phone或者app 解决办法


二十一.查看手机界面实时布局

Tools /android/android device monitor


二十二.NDK出现如下error info

Error:Execution failed for task ':speech:transformNativeLibsWithStripDebugSymbolForRelease'.> A problem occurred starting process 'command 'E:\assdk\ndk-bundle\toolchains\mips64el-linux-android-4.9\prebuilt\windows-x86_64\bin\mips64el-linux-android-strip''


二十三.Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user]

面对MI设备相同的问题,并通过以下步骤来解决问题:

小米手机:
1)去设置
2)点击更多设置
3)点击开发者选项
4)点击"USB安装(允许通过USB安装应用)"

魅族手机:

1)去手机管家
2)点击权限管理
3)点击USB安装管理
4)取消"USB安装管理(监控电脑通过USB安装应用的请求)"


二十四.cannot save settings unable to apply changes :plugins "App Links Assistant"


二十五.AS使用svg图标

右击drawable -->new->Vector asset-->选择路径了 取好名字就行


二十六.cannot load settings from file


二十七.提升Android Studio编译速度

1.项目gradle.properties 
文件里面加
android.enableD8=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx8192m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

2.gradle/gradle-wrapper.properties
配置成本地:
distributionUrl=http\://127.0.0.1/gradle-3.3-all.zip

二十五.Error:(134, 0) Gradle DSL method not found: 'compile()'

Error:(134, 0) Gradle DSL method not found: 'compile()'

Possible causes:<ul><li>The project 'Anzer4' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).

<a href="fixGradleElements">Upgrade plugin to version 2.3.3 and sync project</a></li><li>The project 'Anzer4' may be using a version of Gradle that does not contain the method.

<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.

<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

出现这种情况,就看看app/build.gradle文件里  是不是有两个compile语句在同一行的情况。

 

二十六.如果一个应用as安装没问题,但是单独安装apk就会闪退。

这个时候可以把instance run选项先去掉试下。

 

二十七.如果从服务器pull下来的代码造成大片引用出错。

可以按sync project with gradle file 这个图标

 


二十八.Android Studio中Make Project,Clean Project,Rebuild Project区别


二十九.adb logcat -s System  或者adb logcat -s TAG 一样都可以


三十.在Android studio把git本地分支push到服务器上。

右击工程,git ->repository->push->看界面情况。


三十一.添加导入新module

 File-->new ->import module


三十二.删除module

分两个步骤

  1. 右击相应的module,->open module settings ->视图 有个红色减
  2. 然后再右击相应的module,点击删除。

三十三.使用cherry-pick获取另外分支的commit

首先切换到目标分支,然后点击另外分支的commit,右击选择cherry-pick


三十四.打开最近打开过的文件

Ctrl+e


三十五.快速完成一行代码

Ctrl+shift+enter


三十六.memory monitor内存监视器

可以查看某一进程从系统获取的内存数量以及空闲数量


三十七.重构

1.重命名

 shift+F6

2.摘取

refactor-->this..

extract 部分代码形成一个方法


三十八.//TODO的用法

通过TODO窗口,可以看到哪些地方是没有做完的


三十九.jar包的添加使用或引用

1.直接放在libs目录

2.添加成一个module

3.远程引用,其实也已经下载到本地了-->file->project structure->添加远程library->输入字符串搜寻就行了 jcenter.bintray.org


四十.断点使用

  1. 设置断点
  2. 运行应用debug模式
  3. 把需要查看的变量加到watcher
  4. 填写判断条件 比如a==10;

 

四十一.Android studio无法解析kotlin类,但是编译又能通过,为毛呢?  

把下面勾上,试试。

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值