1.import 项目,sdk目录:sdk\samples\android-21\legacy\ApiDemos,import时一直下一步就ok了。
2.Error:Error: The file name must end with .xml,重命名添加.xml
3.Run app,这时可能碰到3个问题:
此问题需要导入supportv4包
出现新问题:
Error:Execution failed for task ‘:app:processDebugManifest‘.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 9 declared in library [com.android.support:support-v4:25.1.0] D:\androidProject\ApiDemos\app\build\intermediates\exploded-aar\com.android.support\support-v4\25.1.0\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v4" to force usage
解决办法是在 build.gradle (Module)
中增加 mindSdkVersion
:
defaultConfig {
minSdkVersion 21
}
此时异常:dependencies { compile ‘com.android.support:support-v4:25.1.0‘}
修改 support-v4 的版本号为 22.2.1即可。
异常:找不到FloatMath.sqrt(0.125f)
FloatMath.sqrt(0.125f)
等方法已经从 6.0 SDK 中移除了:All methods were removed from the public API in version 23.
修改 compileSdkVersion
为22(原来是23),同时修改 support-v4 的版本号为 22.2.1
4.重新运行后异常:
这两个类的引用需要系统类,对其内容全部注掉
重新run,就跑起来了