简体   繁体   English

应用程序图标不显示(Android Studio)

[英]App icon doesn't show (Android Studio)

This is my very first time to make an android application.这是我第一次制作 android 应用程序。 I've only made 3 designs for my very first app but every time I ran the Android Virtual Device, the icon of my app doesn't show up (the application itself :( ). Can someone help me about this? I am really new into this.我只为我的第一个应用程序做了 3 个设计,但是每次运行 Android 虚拟设备时,我的应用程序的图标都没有显示(应用程序本身 :( )。有人可以帮助我吗?我真的新进入这个。

Here's my Manifest file.这是我的清单文件。 Thank you!谢谢!

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.sti.myactivity">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".Mylove">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".RegisterActivity" />
    <activity android:name=".UserAreaActivity"></activity>
</application>

</manifest>

在此处输入图片说明

I suggest to import you Icon in the Android Project like this:我建议像这样在 Android 项目中导入你的 Icon:

Right click on your App folder and go to NEW -> Image Asset and upload the icon there.右键单击您的 App 文件夹并转到NEW -> Image Asset并在那里上传图标。 then it will show up.然后它会出现。

图像资源

You will be presented with this screen where you can simply select your icon.png您将看到此屏幕,您可以在其中简单地选择您的 icon.png

在此处输入图片说明

Furthermore it automatically scales the Icon in all the different screen densities!此外,它会在所有不同的屏幕密度下自动缩放图标!

Regarding the updated question:关于更新的问题:

Do the following things:做以下几件事:

  • Make sure your code compiles correctly确保您的代码正确编译
  • Make sure the image icon is in mipmap folder, you should look for a folder named AndroidStudioProjects (by default) -> yourProjectName -> App -> src -> main -> res -> mipmap .确保图像图标位于mipmap文件夹中,您应该查找名为AndroidStudioProjects (默认情况下)的文件夹 -> yourProjectName -> App -> src -> main -> res -> mipmap also make sure that the mipmap folder has the screen density you need (eg xhdpi)还要确保 mipmap 文件夹具有您需要的屏幕密度(例如 xhdpi)
  • Use the Run Button on the top in android studio (Command-R on Mac) and make sure you select the right emulator使用 android studio 顶部的运行按钮(Mac 上的 Command-R)并确保选择正确的模拟器

Anyway Importing the Icon as displayed above, avoids all this problems because it does everything for you.无论如何导入如上所示的图标,可以避免所有这些问题,因为它可以为您完成所有工作。

Hope this helps!希望这有帮助!

You should check on an android phone if you can download and play the app.如果您可以下载和播放该应用程序,您应该检查安卓手机。 If the problem is only with the emulator - it does get buggy, so the regular reinstalling the emulator/android studios, restarting your computer, trying to install a different emulator might work.如果问题仅出在模拟器上 - 它确实有问题,因此定期重新安装模拟器/android studios,重新启动计算机,尝试安装不同的模拟器可能会起作用。

Otherwise:否则:

The relevant line to look at is:要查看的相关行是:

android:icon="@mipmap/ic_launcher"

This means that the app is going to the 'mipmap' folder inside your directory, and looking for a file named 'ic_launcher' - to display it as the App icon.这意味着应用程序将转到您目录中的“mipmap”文件夹,并查找名为“ic_launcher”的文件 - 将其显示为应用程序图标。

You need to make sure this file name exists in the proper folder, and is in the correct format( this guide might help )您需要确保此文件名存在于正确的文件夹中,并且格式正确( 本指南可能会有所帮助

How to find the image location folder如何找到图像位置文件夹

If this doesn't help: remember that icons can be displayed at different qualities for different devices (hdpi, mdpi, xhdpi....) so sometimes if you want to make your own icon you need to make sure it fits the requirements (in the above guide)如果这没有帮助:请记住,图标可以针对不同设备(hdpi、mdpi、xhdpi...)以不同质量显示,因此有时如果您想制作自己的图标,您需要确保它符合要求(在上述指南中)

First of all check the logcat for if the application your are developing is even getting installed on the emulator or not.首先检查 logcat 是否正在开发的应用程序甚至安装在模拟器上。 Then if it says that "installing" and if still you don't see your app.然后,如果它说“正在安装”并且仍然看不到您的应用程序。 Then just build an apk and then try installing it on a mobile device via bluetooth.然后只需构建一个 apk,然后尝试通过蓝牙将其安装在移动设备上。 And for the Application icon just click res>imagge Asset > select your icon for your app to show on any mobile device and then just save/go/apply.对于应用程序图标,只需单击 res>image Asset > 选择您的应用程序图标以在任何移动设备上显示,然后只需保存/运行/应用即可。

I know the answer has already been found.我知道答案已经找到了。 But, I found a different solution that worked for me and I would like to share.但是,我找到了一个对我有用的不同解决方案,我想分享一下。

I have a custom launcher on my phone and I had set the app icon to a seperate image of the default android icon.我的手机上有一个自定义启动器,我已将应用程序图标设置为默认 android 图标的单独图像。 I had to switch this back to the default app icon.我不得不将其切换回默认的应用程序图标。

Just make sure that your launcher is not replacing the default app icon and is updated the icon with the updated app icon.只需确保您的启动器没有替换默认的应用程序图标,并使用更新的应用程序图标更新图标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM