导入的项目在 android studio 1.2.1.1 中出错 [英] imported projects give error in android studio 1.2.1.1

查看:17
本文介绍了导入的项目在 android studio 1.2.1.1 中出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 android studio 1.2.1.1,它没有给我任何新项目的错误.但对于导入的项目,它会给我一个关于不匹配编码的警告(这个问题).我将项目和 IDE 编码更改为 UTF-8,此警告不再出现.
但是,在那之后,它给了我这个错误.

i use android studio 1.2.1.1 and it doesn't give me any error for new projects. but for imported projects it gives me an warning about mismatched Encoding (this issue). i changed project and IDE encoding to UTF-8 and this warning doesn't appear any more.
but , after that , it gives me this error.

F:\Work\workspace\NITask\app\build\intermediates\res\debug\drawable-hdpi-v4\ic_launcher.png: error: Duplicate file.
F:\Work\workspace\NITask\app\build\intermediates\res\debug\drawable-hdpi\ic_launcher.png: Original is here. The version qualifier may be implied.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\sdk\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1

在这些项目中,我的主模块中没有 R 类.
我阅读了许多问题,例如 finished with non zero exit value 但没有用

and in these projects , there isn't R class in my main module.
i read many questions like finished with non zero exit value but wasn't useful

更新:
在清理项目之后,它给了我很多关于我的资源的错误,如下所示:

update:
after clean project , it gives me many error about my resources like this:

AAPT err(1779619686): F:\Work\workspace\NITask\app\src\main\res\drawable-xhdpi\shadow.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited

推荐答案

FIRST :

libpng warning: iCCP: Not recognizing known sRGB profile that has been edited

iCCP 只是警告.它们不是错误,也不会使您的应用构建失败,因此请忽略它.

iCCP are just warnings. they are not errors and they dont failed your app build so ignore it.

第二个:

实际错误是

F:\Work\workspace\NITask\app\build\intermediates\res\debug\drawable-hdpi-v4\ic_launcher.png: error: Duplicate file.
F:\Work\workspace\NITask\app\build\intermediates\res\debug\drawable-hdpi\ic_launcher.png: Original is here. The version qualifier may be implied.

这个错误可能是因为 3rd 方库在 thr 库中使用了 ic_launcher.您可以通过以下方式解决此问题:

This error may occur because of 3rd party libraries uses ic_launcher in thr library. You can solve this by :

1) 清理您的项目并重建它.

1) clean your project and rebuild it.

2)创建文件夹mipmap-mdpi"、mipmap-hdpi"、mipmap-xhdpi"strong>","mipmap-xxhdpi" 并复制 ic_launcher 图标并根据大小将其放置在相应的文件夹中.

2) create a folder "mipmap-mdpi","mipmap-hdpi","mipmap-xhdpi","mipmap-xxhdpi" and copy the ic_launcher icons and place it in the respective folder based on the sizes.

res/
mipmap-mdpi/ic_launcher.png (48x48 pixels)
mipmap-hdpi/ic_launcher.png (72x72)
mipmap-xhdpi/ic_launcher.png (96x96)
mipmap-xxhdpi/ic_launcher.png (144x144)
mipmap-xxxhdpi/ic_launcher.png (192x192)

在您的 xml 文件中引用图标为

give reference to the icon in your xml file as

android:icon="@mipmap/ic_launcher"

mipmap文件夹的原因(根据谷歌):

The reason for the mipmap folder (According to Google) :

最好的做法是将你的应用程序图标放在 mipmap- 文件夹中(而不是drawable- 文件夹),因为它们的分辨率不同于器件的电流密度.

It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.

3) 如果上述解决方案没有解决,则将 drawable-* 文件夹重命名为 drawable-*-v4(其中 * 是 mdpi、hdpi、xhdpi 或 xxhdpi)并将所有可绘制对象放入其中.

3) If above solution doesn't solve, then rename the drawable-* folder as drawable-*-v4 (where * is mdpi, hdpi, xhdpi or xxhdpi) and place all your drawables in them.

res/ 
drawable-mdpi-v4/
drawable-hdpi-v4/
drawable-xhdpi-v4/
drawable-xxhdpi-v4/

在这之后做1)点并尝试

这篇关于导入的项目在 android studio 1.2.1.1 中出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆