赞
踩
41、双击shift键进行查找
非常实用,可以找到文件,设置等,但是好像不能全局搜索文件内容,如果想要全局搜索文件内容,可以ctrl+h
42、让android studio显示黑色主题
进入Settings,搜索 Appearance ,选择主题 Theme:Darcula
替换完成后发现字体变的好小,需要设置Font(创建模板后可以直接选择就行)
编辑区: Settings -- Editor -- Colors & Fonts -- Font (需要保存一个新的模板才可以编辑) //这个时候就设置完了,terminal重开一个就好了
控制台: Settings -- Editor -- Colors & Fonts -- Console Font
控制台的背景颜色修改File -> Settings -> Editor -> Colors and Fonts -> Console Colors
Console > Background ,确定之后新建一个terminal就可以看到效果了
备注,不愿意一个个找,可以直接搜索Font就行,非常方便。也可以双击shift,搜索Font,不过这个范围大点,要选择好。
切换只有修改2个地方,一个是主题,一个是字体就可以了
43、可以在android studio的终端中输入 gradlew -v 查看当前的gradle的版本:
它是根据gradle-wrapper.properties文件中的配置来的 例如我的配置: #Mon Dec 28 10:00:20 PST 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip 如果 C:\Users\gq.CHINA\.gradle\wrapper\dists 这个路径下没有这个版本,默认就会自动下载。 下载完成就可以查看到当前的gradle版本号: D:\workspace_android_studio\WiFi_Auto_Connect>gradlew -v ------------------------------------------------------------ Gradle 3.4.1 ------------------------------------------------------------ Build time: 2017-03-03 19:45:41 UTC Revision: 9eb76efdd3d034dc506c719dac2955efb5ff9a93 Groovy: 2.4.7 Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 JVM: 1.7.0_51 (Oracle Corporation 24.51-b03) OS: Windows 7 6.1 x86 D:\workspace_android_studio\WiFi_Auto_Connect> 备注:如果我们想下载某个版本的gradle也可以采用这种方式。
44、导入github下载的工程出现错误
Cause: org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection Possible causes for this unexpected error include: Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network) The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart) Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project. 网上找到类似的问题,说是库下载不完整导致,替换对应版本的zip文件就行 例如:C:\Users\gq.CHINA\.gradle\wrapper\dists\gradle-3.4.1-all\c3ib5obfnqr0no9szq6qc17do下的gradle-3.4.1-all.zip 我的解决方法: 在工程下的build.gradle文件中 把gradle插件的版本替换为已有的版本 dependencies { classpath 'com.android.tools.build:gradle:2.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } 我查看了下插件的版本C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\build\gradle 有【1.5.0、2.1.3、2.2.2、2.2.3】 把2.1.0替换为2.2.3,再Sync Now就可以了。试了下替换2.2.2也行。
45、继上面这个问题之后又出现类似的问题,用上面的方法解决不了。
Error:Unable to load class 'org.gradle.api.internal.component.Usage'. causes for this unexpected error include: Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network) The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart) Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes. 试了删除gradle版本,重新下载,问题还在 点击上面的Re-download也解决不了 关闭所有的java进程,重启IDE也不行 替换gradle插件的版本classpath 'com.android.tools.build:gradle:2.2.3' 也不行 后面在网上查资料发现是有个gradle插件兼容的问题 在工程目录下 lib--build.gradle,文件里面有段: buildscript { repositories { jcenter() } dependencies { classpath 'com.novoda:bintray-release:0.4.0' } } 网上说0.4.0版本不兼容(我的gradle插件版本设置的是2.2.3)。 解决方法: 将0.4.0版本替换为0.5.0,重新同步下,问题解决OK。
总结:目前发现的导入别人的工程出问题基本上都是gradle的配置的问题,主要是需要设置对应的版本,代码基本不用修改。
可以直接用替换的方法,替换当前工程的版本未自己本地已经安装的版本。(建议最好使用较新的版本)
46、在android studio的终端中输入 gradlew -v出现
错误: 找不到或无法加载主类 org.gradle.wrapper.GradleWrapperMain
原因:在项目的gradle--wrapper文件夹中没有gradle-wrapper.jar这个文件。
解决方法:在其他的项目中复制一个到这个目录,再输入命令就OK了
47、遇到一个运行app时的错误
gradle更新的时候没有问题,运行app的时候报错:
Error running app: This version of Android Studio is incompatible with the Gradle Plugin used. Try disabling Instant Run (or updating either the IDE or the Gradle plugin to the latest version
解决方法:
打开设置,搜索instant Run,默认前面三个是勾选的,取消掉就OK了。
48、查看一个引用dependencies的具体的文件路径:
例如,app下面的build.gradle
dependencies {
// 编译libs目录下的所有jar包
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
testCompile 'junit:junit:4.12'
}
看junit:4.12这个jar包路径
在工程下的External Libraries -- 找到这个包,右击,点击Library Properties ...就可以看到
50、查看android studio,gradle的插件的版本
a.打开工程下的build.gradle文件 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } 里面的2.2.3就是插件的版本号。 b.File -- Project Structrue ... -- Project -- Android Plugin Version 修改了这个界面上的版本号,文件也会自动修改。 我们想要一个新的插件版本直接修改
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。