Android Studio 使用入门及问题汇总
聲明:轉載自http://blog.csdn.net/wei_chong_chong/article/details/56280383
?
之前一直用eclipse+adt做Android開發。曾經嘗試使用androidstudio發現內存占用很大,電腦太卡了。現在進入公司了,公司項目使用android studio開發的。現在著手androidstudio吧。
?
寫在前面:使用androidstudio 不要打開360殺毒軟件
有人安裝androidstudio會發現很卡,可以退出殺毒軟件或者直接卸載比如360什么的,或者添加為信任軟件,(但是我發現添加為信任軟件后提升不明顯,后來直接卸載了)
使用入門:
常用快捷鍵:http://www.cnblogs.com/zyw-205520/p/5231843.html
常用查找快捷鍵:http://blog.csdn.NET/huangxiaominglipeng/article/details/52525996
(1)字體及樣式設置
http://jingyan.baidu.com/article/d8072ac463c406ec95cefd23.html
? (2)刪除project或module
http://jingyan.baidu.com/article/359911f542736957fe030687.html
?
(3)新建項目gradle很慢
手動下載對于的gradle放在本地http://services.gradle.org/distributions
如果上面的網址下載比較慢可以使用下面的網址
國內鏡像:第二步,在https://dsx.bugly.qq.com/repository/1?下載Android SDK,這是國內的鏡像。速度快。
在https://dsx.bugly.qq.com/repository/8?下載Gradle的包。
?
然后配置:
http://anforen.com/wp/2016/08/dev_install_andorid_studio_gradle_eclipse/
http://anforen.com/wp/2015/11/android-studio-gradle-build-running-slowly/
(4)如何設置每次啟動as不自動打開項目
http://jingyan.baidu.com/article/03b2f78c1974d25ea237aef1.html
?
問題匯總
問題一:真機運行項目提示:
Installation failed with message INSTALL_FAILED_USER_RESTRICTED. It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
解決:發現是手機內存不足了,清理一下內存或者卸載幾個軟件就行了
問題二:布局樣式報錯
(ps我是接手的老項目,之前沒有用過androidstudio,導入后布局樣式出錯)
?
?
設計界面布局時顯示的錯誤:
Rendering Problems? Missing styles. Is the correct theme chosen for this layout? ? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references. ? Failed to find style 'buttonStyle' in current theme (8 similar errors not shown)
?
預覽時控件非常小,而且有些控件無法顯示
解決方法如下:
layout預覽界面(Graphic Layout),右上角有個Theme的選擇項,默認為notitle,根據喜好隨意設定值,我們這里設定為android以前默認的Theme.black.(有的同學這樣改了還是不行,可以試一下NOTitleBar主題,貌似這里設定的時候一定要和配置文件activity中的主題一致才行,或者這里設置了之后配置文件也要設置一下,不然重啟后還是會變回原來的主題,建議clean project一下)或者看一下配置文件中的主題。
配置文件Activity節點和application節點都要看看,我的application節點主題沒有設置,只是設置了Activity的主題
問題三:布局顯示問題Couldn't resolve resource @dimen/y35 ???
?
NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts.
Or: Automatically add all missing attributes
Couldn't resolve resource @dimen/y35 ? ??
這個跟你選擇的設備有關系
這里你應該選擇正確的設備,如果是android開發就選android設備,不然可能識別不了px單位的數據
?
問題4:真機調試run debug的時候 Gradle窗口出現下面的提示
android Gradle build finished with 800 error(s) in 3m 4s 218ms
有時候可能可以安裝成功,有時候會安裝失敗
?
解決:
大概原因:build-tool版本低了,比sdk版本低。于是升級了build-tool工具。那么如何升級了,打開sdkManager.exe工具,找到tool項下的build-tool,對其進行升級,試了一下好像沒效果。之后升級了as版本到2.3才行了。
?
問題5.rundebug真機調試提示
To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.
按照提示設置項目下gradle.properties.文件的jvmargs大小就行了。
解決:發現我項目下沒有gradle.properties文件。在其它工程下面拷貝一個過來就行了。
?
參考:http://blog.csdn.Net/asmcvc/article/details/30225365
http://blog.csdn.net/romaticxiaoyu/article/details/7241512
轉載于:https://www.cnblogs.com/mochaMM/p/6890834.html
總結
以上是生活随笔為你收集整理的Android Studio 使用入门及问题汇总的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 5月22日云栖精选夜读:PHP学习路线图
- 下一篇: JS实现转动随机数抽奖的特效代码