0

Iam trying to automatically switch between two sets of app icons based on the buildTypes i defined here at build.gradle:

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        applicationIdSuffix ".release"
    }
    debug {
        applicationIdSuffix ".debug"

    }
}

I have already looked at this post, however my files structure is different and the offered solution does not work for my case. How to provide different Android app icons for different gradle buildTypes?

Here is my files structure where there are two sets of icons stored at res-debug and res-release. How can I automatically switch between the two?

\app\src\main:
├───assets
├───java
│   └───com
│       └───myproj
│           └───videoplayer
│               ├───dialog
│               ├───dto
│               ├───entity
│               └───utils
├───res-debug
│   ├───layout
│   ├───mipmap-hdpi
│   ├───mipmap-mdpi
│   ├───mipmap-xhdpi
│   ├───mipmap-xxhdpi
│   ├───mipmap-xxxhdpi
│   └───values
└───res-release
    ├───layout
    ├───mipmap-hdpi
    ├───mipmap-mdpi
    ├───mipmap-xhdpi
    ├───mipmap-xxhdpi
    ├───mipmap-xxxhdpi
    └───values
Waterfr Villa
  • 1,217
  • 1
  • 10
  • 33

1 Answers1

0

The correct folder structure should be:

└─src                            
    ├─debug                      
    │  └─res                     
    │      ├─layout              
    │      ├─mipmap-*         
    │      └─values              
    ├─main                       
    │  ├─java                    
    │  │  └─com.any.package                    
    │  └─res                     
    │      ├─drawable            
    │      ├─layout              
    │      ├─mipmap-mdpi         
    │      ├─mipmap-xhdpi        
    │      ├─mipmap-xxhdpi       
    │      ├─mipmap-xxxhdpi      
    │      └─values              
    └─release
       └─res                     
           ├─layout              
           ├─mipmap-*         
           └─values              
Northern Poet
  • 1,955
  • 1
  • 12
  • 17
  • It should work by default, with no any additional actions. You might have flavors defined in build.gradle file, it may break default behavior. – Northern Poet Nov 15 '17 at 01:46
  • Tried again. Did not work. Also your answer is not complete, you did not mention anything about setting icons debug! – Waterfr Villa Nov 15 '17 at 01:55
  • The debug icons are the default - the ones in the main directory structure. – ianhanniballake Nov 15 '17 at 02:03
  • You may create `debug` same way as `release`. But I cant identify why it's not working for you without error message at least. If no error message, problem might be in `build.gradle` or files. – Northern Poet Nov 15 '17 at 02:07
  • Error:(27) error: resource mipmap/ic_launcher (aka ir.teleboard.device.release:mipmap/ic_launcher) not found. – Waterfr Villa Nov 15 '17 at 02:53
  • `ic_launcher` file not found neither in `main` nor in current (`debbug` or `release`) `res\...` folder. It should located in `main` **OR** in `debug` **AND** `release` source sets. – Northern Poet Nov 15 '17 at 03:17