搜尋此網誌

顯示具有 Android Studio 標籤的文章。 顯示所有文章
顯示具有 Android Studio 標籤的文章。 顯示所有文章

2017年12月31日 星期日

【Android Studio】Instant Run is disabled for non-debug variants


If you have manually set it in the manifest, then remove it and let the IDE automatically assign it. 
If you are using Gradle, make sure that your current variant is debuggable.

buildTypes {
    release {
        debuggable true  //發佈時 記得改為false
    }

2017年9月10日 星期日

【Android Studio】在使用hot key 找某些類別的reference時 出現"cannot find declaration to go to"

ref:
https://stackoverflow.com/a/35455980

好像每次出現這種狀況,印象中,都是出現在update之後,才發生。
所以記錄一下。

  1. close the project in intellij.
  2. close intellij.
  3. go to the project folder and delete the .idea folder
  4. restart intellij and open the project (wait for the indexing to finish) and it would work.
步驟中的intellij -->換成 Android Studio也是可行的。 

2016年8月20日 星期六

【Android Studio】ddms: 'adb.exe,start-server' failed — run manually if necessary

ref :
http://stackoverflow.com/a/38310713

每次都是Android Studio更新後,就出現一對問題

一下子是Grandle有錯誤,弄了好久,之後又出現

ddms: 'adb.exe,start-server' failed — run manually if necessary

連不上Genymotion

所以沒事不要更新。

解決辦法:

Sometimes there are conflicts between ADB Genymotion and ADB SDK because both of them use the same port. So I recommend always set up ADB Genymotion to use the ADB SDK, in that way to avoid incompatible issues.
Genymotion-> Settings -> ADB -> Use custom Android SDK tools (here your set up your sdk android location).

2016年5月29日 星期日

【Android Studio】幫apk檔自動加上version code和version name

ref:
http://www.2cto.com/kf/201601/487405.html

在build.gradle檔打開

android block 中,新增

android.applicationVariants.all {
    variant ->
        variant.outputs.each {
            output ->
                output.outputFile = new File(output.outputFile.parent, "名稱_" +
                        defaultConfig.versionCode + "_v" +
                        defaultConfig.versionName + "_" +
                        buildType.name + ".apk");
        }
}

2016年4月9日 星期六

【Android Studio】SDK 更新至Android N後,在xml預覽視窗出現Rendering Problem



"Failed to load the LayoutLib: com/android/layoutlib/bridge/Bridge : Unsupported major.minor version 52.0"

解決:
Usually you get error: Unsupported major.minor version 52.0
If you have installed Android N, change Android rendering version with older one and the problem will disappear.

ref:
http://stackoverflow.com/a/35917202

2015年9月1日 星期二

【Android Studio】如何開啟logcat

建立時間:2015-09-01
更新時間:2016-03-04
ref:

  1. ref: http://stackoverflow.com/a/16817720
    按 Alt + 6
  2. 記錄一下

    1. 首先開啟Android Studio(廢話...)
    2. Tools  >  Android  > Enable ADB Integration選項有勾起,沒有的話就點一下。
    3. 再次確認Enable ADB Integration選項有勾起。
    4. Tools  >  Android  > Android Device Monitor 點一下,需要等一下。
    5. Android Device Monitor 打開後,可以double check 要模擬的device或app name,log會在右下方出現。
    6. 點選綠色+號(左下角),設定新的過濾器規則。

      橘黃色的log可以不用太在意,只是警告;但紅色的log就要特別注意了,是屬於嚴重錯誤。
ref:影片支援



2015年8月14日 星期五

【Android Studio】auto import all of the shortcut


心得:
從Eclipse轉到Android Studio實在太累了,一堆功能又不太一樣,一直卡在Debug要如在AS上操作比較順利,常常知道Eclipse的功能,但轉到AS不知道要去哪裡設定?再加上英文關鍵字也不知道要如何下?

比如說:
URL url = new URL();
使用eclipse時(Shift+Ctrl+O)會自動說明需要加上try ... catch ...exception 或 throws ...exception,並自動產生出來。
但在AS只會和你說 Unhandled exception: ...之類的,但是要如何解決,需要自己去查api要如何使用,沒有直接提示。

其實是有的,只是這個功能被關閉哩 (= =|||)

StackOverflower類似的問題:
Is there any way of auto importing (like in Eclipse Shift+Ctrl+O) in Android Studio?
I have found only Ctrl+Alt+O which ask for each thing, and I have to press Alt+Enter to accept it.
No way to do it faster?

For Windows/Linux, you can go to File -> Settings -> Editor -> General -> Auto Import -> Java and make the following changes:
  • change Insert imports on paste value to All
  • markAdd unambigious imports on the fly option as checked
On a Mac, do the same thing in Android Studio -> Preferences






【Android Studio】 導入外部library 教學

ref:
http://chris0903.blogspot.tw/2013/07/android-studiolibrary.html

【Android Studio】ActionBarActivity is deprecated

ref:
http://developer.android.com/tools/support-library/index.html
http://android-developers.blogspot.tw/2015/04/android-support-library-221.html

Since the version 22.1.0, the class ActionBarActivity is deprecated. You should use AppCompatActivity.

解決方法:
https://www.youtube.com/watch?t=49&v=5Be2mJzP-Uw

需修改以下兩處:

  • AndroidManifest.xml
    • <application android:theme="@style/Theme.AppCompat">
  • MainActivity.xml
    • public class MainActivity extends AppCompatActivity

2015年8月7日 星期五

2015年7月5日 星期日

【Android Studio】快捷鍵(Hot Key) /快速設置為Eclipse的快捷鍵


  • 快捷鍵
    • Ctrl + Alt + Space  show template proposals





  • 還是不習慣AS的快捷鍵,直接將Android Studio的快捷鍵快速設置為Eclipse的快捷鍵。
    • File > Settings > 輸入 keymap > 在keymaps選項中,選擇Eclipse,即可。




  • 顯示行數(line number)
    • File > Settings > Editor > General > Appearance > Show line number打勾即可。

2015年5月31日 星期日

【Android】Hax kernel module is not installed

最近想改用Android Studio作為Android 的開發(之前使用Eclipse),可是要執行ADT時,卻出現Hax kernel module is not installed.的錯誤訊息,按字面翻譯應該就是Hax kernel module 沒有安裝。
經過辜狗後(使用intel cpu 才有支援此技術),其實疑難排解如下:

  • Intel CPU:先確認有支援Virtualization technology(虛擬化技術),可透過官網查詢。
  • BIOS設定:不知從哪一版CPU開始,Virtualization technology選項預設是關閉的,所以需要到BIOS把設定打開。
  • 下載HAX,有以下兩種方式:


但是實際測試,使用ADT沒有比使用Genymotion模擬器來的快。另外使用amd CPU的coder,因為amd沒有支援虛擬化技術,所以也可改用Genymotiony開發。

ref:https://www.youtube.com/watch?v=Ar9_FUFJhDU