2017-12-18 328 views
1

我想将我的Android Android插件从2.3.3升级到3.0.1。我可以修复Migration Guide之后的所有错误。我现在的问题是,Android Nougat(24)和Android Marshmallow(23)应用程序图标被替换为默认的机器人图标。将Gradle插件更新至3.0后未显示应用程序图标

你能帮我找出问题的原因吗?以前的图标显示,我不明白为什么现在不合逻辑的原因。

我试过所有建议here没有成功。

这里是我的清单文件:

<!-- Permissions --> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
... 

<application 
    android:name="...Application" 
    android:allowBackup="false" 
    android:allowTaskReparenting="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/application" 
    android:largeHeap="true" 
    android:roundIcon="@mipmap/ic_launcher_round" 
    android:theme="@style/Theme.MyTheme" 
    tools:replace="android:icon,theme,label,allowBackup"> 

<uses-library android:name="com.google.android.maps" /> 

    <activity 
     android:name="...SplashActivity" 
     android:label="@string/application" 
     android:theme="@style/Theme.Splash"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

    </activity> 

... 


</application> 

这里是项目摇篮文件:

buildscript { 
ext.kotlinVersion = '1.2.10' 
repositories { 
    jcenter() 
    google() 
} 

dependencies { 
    classpath 'com.android.tools.build:gradle:3.0.1' 
    classpath 'com.google.gms:google-services:3.1.0' 
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 
} 
} 

allprojects { 
ext { 
    androidApplicationId = 'myapp.android' 
    androidVersionCode = 1 
    androidVersionName = "1.0" 
    testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" 
} 

repositories { 
    maven { url "https://maven.google.com" } 
} 
} 
+0

你检查了什么是可用的资源对这个值'ic_launcher_round' –

+0

我更新了我的android studio没有你的问题,我认为你应该清理你的项目。 – salman

+0

@AbdulWaheed我检查了图标,他们是我的应用程序图标按预期。 –

回答

1

Android系统绝不会显示应用程序,直到图标你做。

使用tools:replace="attr"就像您在此处所做的那样 - >tools:replace="android:icon,..."将替换优先级较高的清单中的图标,并将图标保留在优先级较低的清单中。

+0

在清单合并期间需要使用“替换”来解决冲突。这里是解释问题:https://stackoverflow.com/questions/24506800/android-studio-gradle-icon-error-manifest-merger –

+0

@MarioKutlev也许如果你有一个子项目中的子资源相同的名称( ic_launcher)在你的依赖中实现将会发生这个问题。 随机的解决方案是重命名启动器图标。 – Ibrahim

+0

我试过重命名ic_launcher,但没有帮助。 :( –

0

我在这Twitter post发现问题。 “在Android插件3.0.0默认情况下启用AAPT2”,如Migration guide中所述。看起来这个改变会导致资源问题。

要修复应用程序的图标,我必须通过在gradle.properties文件中添加android.enableAapt2=false来禁用Aapt2。

注意:当我使用相同的gradle设置创建新的应用程序时,我无法重现该问题。

相关问题