PS:寝室收到一个eclipse写的安卓项目,叫我在AS调试出来,emmmm…然后一堆坑
首先选择【Import project(Gradle,Eclipse ADT,etc.)】导入eclipse的安卓项目
坑一
ERROR: Could not find com.android.tools.build:gradle:3.5.2.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar
Required by:
project :
Add Google Maven repository and sync project
Open File
解决方法:打开build.gradle在repositories{}内添加google(),它会去更换为https://dl.google.com/ 下载,最后在重新编译
坑二
ERROR: Minimum supported Gradle version is 5.4.1. Current version is 4.8.
Please fix the project's Gradle settings.
Fix Gradle wrapper and re-import project
Open Gradle wrapper properties
Gradle settings
解决方法:点击Please fix the project’s Gradle settings.可自动修复
坑三
ERROR: The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
Remove minSdkVersion and sync project
Affected Modules: app
解决方法:点击Remove minSdkVersion and sync project,删除android:minSdkVersion;在选择【Do Refactor】重构一下。
导入报错已经纠正,接下来开始在虚拟机运行
坑四
D:\Android\AndroidStudioProjects\memory1\app\src\main\res\drawable\disbtnbg.9.png: AAPT: error: file failed to compile.
解决方法:
网上提供的解决方法是在build.gradle里添加
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
然后并没什么用
。。。。。。。。。。。。。。。
最后我一脸懵逼的找到图片disbtnbg.9.png将.9删除,改为disbtnbg.png成功运行
坑五
閿欒: 缂栫爜UTF-8鐨勪笉鍙槧灏勫瓧绗?
解决方法:打开build.gradle,添加compileOptions.encoding='gbk'
坑六
More than one file was found with OS independent path 'META-INF/DEPENDENCIES'
解决方法:打开build.gradle,添加
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
最终填坑完毕。。。。