Answer the question
In order to leave comments, you need to log in
How to compile 1 of multiple projects on android?
Hello. There is an Android project for working with different APIs (vk, ok, fb...). Now there is 1 class, which contains all the functions for working with the API. For example: vkPost(), vkDeletePost(), okPost(), fbPost() etc. I want to create separate classes for each social. networks (VKConfig, OKConfig, FBConfig...). All other code, except resources, is the same. Resources for each social. networks are in the folder app/src/appForVk/res, app/src/appForOk/res, app/src/appForFb/res. Everything is ok with them. When compiling, I choose which project I want to build. Question: how to add these 3+ .java classes in a similar way. So that not everyone pulls up, but only the one that requested. Now in gragle:
productFlavors {
appForVk {
applicationId 'com.social.myapp.vk'
}
appForOk {
applicationId 'com.social.myapp.ok'
}
}
. Answer the question
In order to leave comments, you need to log in
Try this option:
1) create an interface to work with different APIs
public interface SocialApi {
void post(Post post);
void deletePost();
}
public class VkApi implements SocialApi {
@Override
void post(Post post){}
@Override
void deletePost(){}
}
productFlavors {
appForVk {
buildConfigField("com.social.myapp.SocialApi", 'api', "new com.social.myapp.vk.VkApi()")
applicationId 'com.social.myapp.vk'
}
appForOk {
buildConfigField("com.social.myapp.SocialApi", 'api', "new com.social.myapp.ok.OkApi()")
applicationId 'com.social.myapp.ok'
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question