Android studio 开发环境搭建
Android studio 开发环境搭建
一、环境:
下载java jdk:http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html
下载Android Studio:http://developer.android.com/sdk/index.html
二、安装步骤
1、安装java jdk
按照提示一步步来就行 ,如果需要配置环境变量参考 http://www.cnblogs.com/lmh2072005/p/5083648.html
2、安装Android Studio和创建项目
双击安装文件一步步安装即可。
3、创建运行第一个Android apk hello world
三、常见问题
1、在运行app时提示未安装Intel HAXM错误信息:
Emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.
CPU acceleration status: HAX kernel module is not installed!
解决方案:
1) Open SDK Manager (In Android Studio, go to Tools > Android > SDK Manager) and Download Intel x86 Emulator Accelerator (HAXM installer) if you haven't.
2) Now go to your SDK directory (C:\users\username\AppData\Local\Android\sdk, generally). In this directory Go to extras > intel > Hardware_Accelerated_Execution_Manager and run the file named "intelhaxm-android.exe".
In case you get an error like "Intel virtualization technology (vt,vt-x) is not enabled". Go to your BIOS settings and enable Hardware Virtualization. //需要重启电脑设置bios
3) Restart Android Studio and then try to start the AVD again.
It might take a minute or 2 to show the emulator window.
2、模拟器RAM过大,电脑内存不足,错误信息:
emulator: The memory needed by this VM exceeds the driver limit.
HAX is not working and emulator runs in emulation mode
在android studio 打开tools->android->avd manager 找到对应的avd 编辑, 在弹出的配置文件点击'Show Advanced Setting' ,
在详细设置里面把滚动条拉下来(滚动条很不明显,是个坑),根据自己电脑内存分配下内存
配置好后重启android studio
Run 'app' 一切ok
最后导出apk文件,在android studio -> build->Generate Signed APK 即可。
3. 提示No Android SDK found.
没有安装android sdk , 在设置里面重新设置下android sdk Location
4. 创建项目后打开项目提示:“project sync failed” , 找了很久没找到原因,开始以为是设置代理的问题,后面在网上找了是要打开一个配置(参考https://blog.csdn.net/xuyankuanrong/article/details/80087980):
5. run app 报错 “Error while waiting for device: The emulator process for AVD Nexus_5X_API_24 was killed.”
解决方案:安装HAXM
参考文档:
http://stackoverflow.com/questions/29136173/emulator-error-x86-emulation-currently-requires-hardware-acceleration
http://stackoverflow.com/questions/21031903/how-to-fix-hax-is-not-working-and-emulator-runs-in-emulation-mode
http://www.cnblogs.com/rwxwsblog/p/4769785.html