码迷,mamicode.com
首页 > 移动开发 > 详细

如何将ADT项目导入Android studio及常見問題

时间:2016-04-10 12:45:32      阅读:371      评论:0      收藏:0      [点我收藏+]

标签:

  • ADT导出Android studio项目

 

右键-->ExportAndroid/Generate Gradle build files-->

 

  技术分享

  技术分享

  技术分享

  • Android studio导入项目

File-->Open File Or Project选择相应的项目即可

 

  技术分享

  • 常见问题

  Error:Configuration with name ‘default‘ not found.

settings.gradle中include的库找不到

  解决Gradle DSL method not found: ‘android()’

  技术分享

删掉最外层的build.gradle中的
android {
    compileSdkVersion 19
    buildToolsVersion '21.1.1'
}
然后重新刷新就ok了

  参考:http://www.hloong.com/?p=100

  技术分享

  解决png图片libpng warning: iCCP: Not recognizing known sRGB profile that has been edited

  技术分享

AAPT err(Facade for 702915749): E:\AndroidStudioProjects\testApp\XXXX\build\intermediates\exploded-aar\testApp.Android-PullToRefresh\library\unspecified\res\drawable-mdpi-v4\default_ptr_flip.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT err(Facade for 702915749): E:\AndroidStudioProjects\testApp\XXXX\build\intermediates\exploded-aar\testApp.Android-PullToRefresh\library\unspecified\res\drawable-xhdpi-v4\default_ptr_flip.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT err(Facade for 702915749): ERROR: 9-patch image E:\AndroidStudioProjects\testApp\XXXX\res\drawable-hdpi\mini_btn_cancel_bg.9.png malformed.
AAPT err(Facade for 702915749):        Frame pixels must be either solid or transparent (not intermediate alphas).
AAPT err(Facade for 702915749):        Found at pixel #4 along top edge.
AAPT err(Facade for 121617349): E:\AndroidStudioProjects\testApp\XXXX\res\drawable-hdpi\title_bar_menu_on.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT err(Facade for 121617349): ERROR: 9-patch image E:\AndroidStudioProjects\testApp\XXXX\res\drawable-hdpi\mini_btn_confirm_bg.9.png malformed.
AAPT err(Facade for 121617349):        Frame pixels must be either solid or transparent (not intermediate alphas).
AAPT err(Facade for 121617349):        Found at pixel #4 along top edge.
AAPT err(Facade for 121617349): E:\AndroidStudioProjects\testApp\XXXX\res\drawable-hdpi\title_bar_menu.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT err(Facade for 1675937883): E:\AndroidStudioProjects\testApp\XXXX\build\intermediates\exploded-aar\testApp.Android-PullToRefresh\library\unspecified\res\drawable-hdpi-v4\default_ptr_flip.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT err(Facade for 1675937883): E:\AndroidStudioProjects\testApp\XXXX\res\drawable-hdpi\loading.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
Error:Execution failed for task ‘:XXXX:mergeDebugResources‘.
> Some file crunching failed, see logs for details

  解决办法:下载imagemagick并安装,执行如下语句

set fn=E:\Program Files\ImageMagick-6.9.0-Q16\convert.exe
for /f "tokens=*" %%i in (dir/s/b *.png) do "%fn%" "%%i" -strip "%%i"

 解决Error:Execution failed for task ‘:XXXX:clean‘.

Error:Execution failed for task ‘:XXXX:clean‘.
> Unable to delete directory: E:\AndroidStudioProjects\testApp\XXXX\build\intermediates\exploded-aar\testApp.Android-PullToRefresh\library\unspecified\res\drawable-mdpi-v4

  解决办法:关闭编辑器重启即可

 AAPT err(Facade for 1984292802): ERROR: 9-patch image xxxxx.9.png malformed.

  .9图片没有指定大小。

  android studio中编辑并保存即可。

 

 编译器版本不对

Error:(401, 25) 错误: 找不到符号
符号:   方法 sqrt(float)
位置: 类 FloatMath

Error:(12, 23) 错误: 程序包org.apache.http不存在
Error:(13, 23) 错误: 程序包org.apache.http不存在
Error:(14, 30) 错误: 程序包org.apache.http.client不存在
Error:(15, 37) 错误: 程序包org.apache.http.client.entity不存在
Error:(16, 38) 错误: 程序包org.apache.http.client.methods不存在
Error:(17, 38) 错误: 程序包org.apache.http.client.methods不存在
Error:(18, 35) 错误: 程序包org.apache.http.impl.client不存在
Error:(19, 31) 错误: 程序包org.apache.http.message不存在
Error:(21, 28) 错误: 程序包org.apache.http.util不存在
Error:(38, 16) 错误: 找不到符号
符号:   类 HttpClient
位置: 类 HttpUtil
Error:(38, 44) 错误: 找不到符号
符号:   类 DefaultHttpClient
位置: 类 HttpUtil
Error:(67, 5) 错误: 找不到符号
符号: 类 HttpGet
Error:(67, 23) 错误: 找不到符号
符号: 类 HttpGet
Error:(69, 5) 错误: 找不到符号
符号: 类 HttpResponse
Error:(74, 22) 错误: 找不到符号
符号: 变量 EntityUtils
Error:(100, 5) 错误: 找不到符号
符号: 类 HttpPost
Error:(100, 25) 错误: 找不到符号
符号: 类 HttpPost
Error:(103, 10) 错误: 找不到符号
符号: 类 NameValuePair
Error:(103, 48) 错误: 找不到符号
符号: 类 NameValuePair
Error:(107, 21) 错误: 找不到符号
符号: 类 BasicNameValuePair
Error:(110, 24) 错误: 找不到符号
符号: 类 UrlEncodedFormEntity
Error:(113, 5) 错误: 找不到符号
符号: 类 HttpResponse
Error:(118, 22) 错误: 找不到符号
符号: 变量 EntityUtils
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。

  解决办法:项目-->右键-->Open Module Settings

  技术分享

  Suggestion: add ‘tools:replace="android:icon"‘ to <application> element at AndroidManifest.xml:22:5-83:19 to override.

  Suggestion: add ‘tools:replace="android:theme"‘ to <application> element at AndroidManifest.xml:22:5-83:19 to override.

  解决办法:

原因:
AS的Gradle插件默认会启用Manifest Merger Tool,若Library项目中也定义了与主项目相同的属性(例如默认生成的android:icon和android:theme),则此时会合并失败,并报上面的错误。
解决方法有以下2种:
方法1:在Manifest.xml的application标签下添加tools:replace=”android:icon, android:theme”(多个属性用,隔开,并且记住在manifest根标签上加入xmlns:tools=”http://schemas.android.com/tools”,否则会找不到namespace哦)
方法2:在build.gradle根标签上加上useOldManifestMerger true (懒人方法)
参考官方介绍:
http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger

  java.lang.IllegalArgumentException: already added: Landroid/support/v4/hardware/display/DisplayManagerCompat;

去掉lib下的support-v4.jar
dependencies下添加依赖:
compile ‘com.android.support:support-v4:13.0.0‘

  com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/NOTICE.txt

  File1: E:\AndroidStudioProjects\YHSoftEbook\YHSoftEbook\libs\commons-net-3.1.jar
    File2: E:\AndroidStudioProjects\YHSoftEbook\YHSoftEbook\libs\commons-httpclient-3.1.jar
    File3: E:\AndroidStudioProjects\YHSoftEbook\YHSoftEbook\libs\commons-io-2.4.jar
    File4: E:\AndroidStudioProjects\YHSoftEbook\YHSoftEbook\libs\commons-codec-1.6.jar
    File5: E:\AndroidStudioProjects\YHSoftEbook\YHSoftEbook\libs\commons-logging-1.1.3.jar
    File6: E:\AndroidStudioProjects\YHSoftEbook\YHSoftEbook\libs\fastjson-1.2.2.jar

  解决办法:在主工程下的添加packagingOptions

android { 
   packagingOptions {  
       exclude ‘META-INF/DEPENDENCIES.txt‘  
       exclude ‘META-INF/LICENSE.txt‘  
       exclude ‘META-INF/NOTICE.txt‘  
       exclude ‘META-INF/NOTICE‘  
       exclude ‘META-INF/LICENSE‘  
        exclude ‘META-INF/DEPENDENCIES‘  
        exclude ‘META-INF/notice.txt‘  
        exclude ‘META-INF/license.txt‘  
        exclude ‘META-INF/dependencies.txt‘  
        exclude ‘META-INF/LGPL2.1‘  
    }  
}  

 

如何将ADT项目导入Android studio及常見問題

标签:

原文地址:http://www.cnblogs.com/rwxwsblog/p/5361239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!