Android Studio exclude package from build [duplicate] - android

I'm developing an android app using android studio as IDE.
My question is:
How to exclude certain files under certain directory during the process of building APK?
In my case, I want to exclude some images from building since the those files used in my project are designated to be downloaded from network in-app while during the development I hope to refer them in the layout.
After googling, I found some solutions:
Gradle 1.2: Exclude directory under resources sourceSets
How to exclude file from resources using Gradle and Android Studio?
And reference from gradle.org
Then I came up my solution in build.gradle:
sourceSets {
main {
resources.exclude '**/drawable/*'
res.exclude '**/drawable/*'
}
}
But it doesn't work, the image under res/drawable/ still shows up(before downloading).
The Android Studio version is currently 0.8.4.
Any idea would be appreciated.

Exclude paths aren't currently supported for Android sourceSets. You can track this at bug https://code.google.com/p/android/issues/detail?id=64957
This is happening because Android sourceSets aren't the same as Java sourceSets; they're a custom implementation in the Android plugin, and don't automatically pick up all the features of their cousins. This will need to be specially implemented for Android, and it hasn't been done yet.

Related

More than one file was found with OS independent path 'META-INFmodule_debug.kotlin_module' in Android studio 4.0

Recently I have updated android studio to 4.0. After updating I am seeing this error when trying to build the project.
It's not frequent but still showing time to time when change something and build again the project.
More than one file was found with OS independent path 'META-INF/module_debug.kotlin_module'
I also added below line in my project build.gradle file in packaging options as mentioned in some other questions but still its not working:
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/*.kotlin_module'
}
Anyone else is facing this issue if so how did you solve it?
The mentioned workaround should work. If not, then make sure you are applying it to the affected module gradle file.

Android API Level Inconsistencies

So I am trying to use this library in my android app to be able to show pdf files. However, when I add the install line to my build.gradle file, Android Studio says that all Android support libraries should use the same version. This happens because the library uses com.android.support:support-compat:26.1.0 while my project is using com.android.support:appcompat-v7:28.0.0.
I want to know if there is a way to get around this and use the library in my project, or if I would have to fork and update the library myself to make it work.
Any help is appreciated.
simply exclude it from the build:
api ("com.github.barteksc:android-pdf-viewer:2.8.2") {
exclude group: "com.android.support", module: "appcompat-v7"
}

How to exclude realm native files from library

Problem: How to remove Realm .so files in library (aar) published using jitpack (leave only realm java files)
We currently moved part of our functionality to sdk, we are creating. Because Realm adds .so libs for each architecture, our sdk becomes too large.
I wanted to leave our RealmObjects in sdk, but remove native files (we actually use realm in our app, not in sdk).
Clarification:
We share our model for realm and retrofit, so this is why it should stay in sdk
Realm doesn't support inheritance for not realm-object so model can't be extended in app.
So my solution was to add packeging options:
packagingOptions {
exclude 'lib/mips/librealm-jni.so'
exclude 'lib/x86_64/librealm-jni.so'
exclude 'lib/x86/librealm-jni.so'
exclude 'lib/arm64-v8a/librealm-jni.so'
exclude 'lib/armeabi-v7a/librealm-jni.so'
}
And it works well, but only when app using sdk adds it in build.grade. Using this in build.gradle for sdk doesn't work.
Questions
How can this be achived?
What are alternatives to solve this problem (having model in sdk, but having database for that model in app using sdk)?

How to remove 'io.card' from Cordova/payPal SDK

I am building Android app with cordova on windows PC and I have been trying to remove 'io.card' from my payPal cordova sdk in order to reduce the size of my apk; but to no avail.
I have read their manual about Disabling Direct Credit Card Payments by including
`dependencies {
compile('com.paypal.sdk:paypal-android-sdk:2.15.1') {
exclude group: 'io.card'
}
}`
in "MY" build.gradle file. They did not show the location of the build.gradle file that should be modified. However I managed to find a build.gradle file under "PROJECT_FOLDER/platforms/android/" However, when I add the
compile('com.paypal.sdk:paypal-android-sdk:2.15.1') {
exclude group: 'io.card'
}
But when I do a new build (cordova run) the dependencies gets removed and therefore the size of my application remains 33.6MB instead of 17.6MB.
I have also seen This Post But the answer is not clear to me.
I will be glad if someone can show me what I am doing wrong, or not doing right. Thank you
This is the link to my build.gradle file -> build.gradle

Android Studio: Exclude resource file under resources sourceSets

I'm developing an android app using android studio as IDE.
My question is:
How to exclude certain files under certain directory during the process of building APK?
In my case, I want to exclude some images from building since the those files used in my project are designated to be downloaded from network in-app while during the development I hope to refer them in the layout.
After googling, I found some solutions:
Gradle 1.2: Exclude directory under resources sourceSets
How to exclude file from resources using Gradle and Android Studio?
And reference from gradle.org
Then I came up my solution in build.gradle:
sourceSets {
main {
resources.exclude '**/drawable/*'
res.exclude '**/drawable/*'
}
}
But it doesn't work, the image under res/drawable/ still shows up(before downloading).
The Android Studio version is currently 0.8.4.
Any idea would be appreciated.
Exclude paths aren't currently supported for Android sourceSets. You can track this at bug https://code.google.com/p/android/issues/detail?id=64957
This is happening because Android sourceSets aren't the same as Java sourceSets; they're a custom implementation in the Android plugin, and don't automatically pick up all the features of their cousins. This will need to be specially implemented for Android, and it hasn't been done yet.

Categories

Resources