conditional compilation of code and resources in android - resources

I have a problem regarding conditional compilation.
I want to conditionally selected resources and build seperate apk for that in android.
How do I achieve this in android.
I am using Eclipse.
Thanks,

Related

is it possibile to use unity project as an android studio activity?

I am trying to create an android application, of which its components are build partly on android studio and partly on unity. i can't do everything with android studio or everything with unity, so i would like a way to merge the two parts. my plan is to integrate the part built in unity as the main activity on androids studio and then create the other activities(screens) of my app on android studio and create a way to slide scroll between those screens(activities). i would like this configuration to work as a single 'precess'.
is this posible to do ?
I am still a beginner, so if I didn't explain well please tell me.
I tried to search for information that would be useful to me but on found nothing.
Yes, it's possible. You have to make an Android Export and add it to your main project. then call unity's activity which is registered on AndroidManifest and Unity part will be run.

KMM Project Build for iOS Without Running

Maybe I'm just missing something but is there a way to trigger the iOS build in Android Studio for a KMM project that doesn't launch the simulator once the build is done?
When looking at the iosApp run configuration I see it has "Build iOS application" listed under "Before Launch" which makes me suspect this is possible but I didn't see it listed as a gradle task or anywhere else I could think of.
I've been doing the iOS work in Xcode and when I make changes to the shared code I want to rebuild it without running the app (which I've been doing from inside Xcode).
Not exactly a solution, but I found that when you hit build in Xcode it builds the Kotlin code so any changes to the shared module are included automatically. No need to do iOS builds from Android Studio.

How to get Android Studio to recognize my plain Gradle Java project?

I have a simple multi-module Gradle project with Java code. When I import it in IntelliJ Community, it asks me to select the build tool from among Maven and Gradle, and will properly recognize the Gradle modules and show me a Gradle tool window.
When I do the same in Android Studio, I don't get the build tool question, and it won't recognize the projects or show me the Gradle tool window.
How do I get this to work in Android Studio?
Simply Try This,
Go to File -> Project Structure -> Sdk Location
This You will get a option menu like this (the given image)
there you can update your gradle settings.
The answer, as far as I've been able to find out, is: Don't even try. Use IntelliJ instead. Installing it is most certainly quicker than trying to get Android Studio to do this.
How do you open the project in Intellij? Do you open the folder? Or do you open the build.gradle?
Just like a maven project (where you should open the pom.xml, not the folder) you should open the project using the build.gradle, not the folder.
Intellij will then do what you expect and import your gradle project
The least required to make it recognize the project is to add AGP, the Android Gradle Plugin:
buildscript {
repositories {
google()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
}
}
Then one can define Android modules with:
apply plugin: "com.android.application"
apply plugin: "com.android.library"
apply plugin: "com.android.dynamic-feature"
Then it will recognize the android {} configuration block (without this Gradle DSL configuration block it would not know what or how to build for Android - as it isn't a sane Android project). Just see the documentation linked, this has little to do with the default Java tooling.
Gradle 7.2 is currently required to build. Even if one cannot mix the plugins per module, one can have different plugins per module - or use different IDE, depending on the tooling of the module. How compatible this really is, is being determined by the dependencies used in the Java module. The fact that one can only use either tooling per single module dictates the layout to be applied.
I suspect that you will have to manually move some code from the successful build files in intellij to the android build files.

Use customized lint check on the fly in Android Studio

I want to write a lint check which can detect issues in resource file on the fly. For example, I want my Android Studio to highlight my <TextView> and give warning when it does not have android:padding.
I read this and found that we can write custom lint but only can we use it through command line but not on the fly. I also found that there is plugin like SonarLint which provides on-the-fly custom lint check.
So my question is:
Is it true that creating an Android Studio plugin is the only way to make custom lint check work on the fly?
I do not accurately answer your question because I don't have own custom lint checks. However, I'm using rxLint library which is not part of Android build tools and Android Studio highlights issues in code that are reported.
So if you will make your custom lint checks as a separate module and put your main project depend on it then Android Studio will highlight it.

How to add Google Play APK Expansion Library to android studio project?

I have so apps that use APK Expansion Files. I usually have build these apps with ant. But I want to add AdMob code to these apps and apparently there is no way to build an AdMob app from the command-line so I have to use Android Studio. I looked at these docs: http://developer.android.com/google/play/expansion-files.html and they do not tell me what magic incantation I need to use in my gradle file. Does anyone know?
Apparently there is no way to use APK Expansion Files if you are using Android Studio. (see https://code.google.com/p/android/issues/detail?id=173235) That kind of sucks. So I guess I go back to using Eclipse.

Resources