Android issues
1. Android studio 2.0
Error:Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
解決辦法:http://stackoverflow.com/questions/35990995/com-android-dx-command-main-unsupported-major-minor-version-52-0
// buildToolsVersion "24.0.0 rc3"
buildToolsVersion "23.0.2"
2. Manifests 權限已經設置,仍然有權限問題(Permission denied (missing INTERNET permission?) )
Permission denied (missing INTERNET permission?): But permission is given
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application ...> </application>
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
code:
try { String packageName="";//getPackageName(); SQLiteDatabase.openOrCreateDatabase("/data/data/"+packageName+"/databases/test1.db", null); Log.v("killed", "DB created"); } catch (Exception e) { Log.e("killed", "Create DB Error" + e.getMessage()); }
permission:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
出現這個問題,首先檢查一下讀寫權限,發現權限沒問題,一直這樣的問題,在網上也查了許多,沒有一個靠譜的。
最后才發現該db文件,只有在/data/data/packagename/目錄下才有權限, 如果你出現這樣的問題,只需要吧路徑設置到相應app package下面
Details:
Order of defining tabs in Manifest:
- Permissions
- Applications
- Receiver, Service, Metadata
3.AS 2.0 開啟Instant Run出現的問題:Error:Access to the dex task is now impossible, starting with 1.4.0
Error:Access to the dex task is now impossible, starting with 1.4.0
1.4.0 introduces a new Transform API allowing manipulation of the .class files.
See more information: http://tools.android.com/tech-docs/new-build-system/transform-api
android老項目倒入后,android studio 2.0 自動更新gradle到2.0.0
http://blog.csdn.net/yzpbright/article/details/51231826
4. Android Fragment
The method add(Fragment,String ) in the type FragmentTransaction is not applicable for the arguments (int, MyFragment)
import issue,
今天遇到這樣一個很奇葩的錯誤信息,后來查到我導入的包有問題 import android.app.Fragment;
import android.app.FragmentManager; 其實我應該使用的是 import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; 然后自己查看了一下API二者差別還是蠻大的 import android.app.Fragment 只能在API版本大于11的時候使用 而不包含getFragmentManager() 和 getSupportFragmentManager() 兩個方法的 雖然在代碼這樣寫不會報錯的 但是 replace(int, Fragment, String)執行的時候會一直出現錯誤 提示上面那個錯誤信息
5. Error:(100, 43) error: package R does not exist
import yourpackage.R
6. android.content.res.Resources$NotFoundException: String resource ID #0x1
今天使用TextView的setText方法遇到這個錯誤,原來是傳入text的是int類型的,android不能自動轉換成string類型,直接跑出這樣的異常,我也是醉了
7. Android listview set on click item listener doesn't work
Item Layout的根控件設置其Android:descendantFocusability=”blocksDescendants”即可
8 include exception
You must specifiy a layout in the include tag: <include layout="@layout/layoutID" />
layout.xml
android:layout=" xxx"
remove android

浙公網安備 33010602011771號