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