Problem compiling new Fdroid Flavour

Not sure if this is an issue, so i am requesting guidence since i am not an Adroid Dev and maybe i am missing something.

I am trying to create a new flavor from F-Droid Client, change the icon, Spanish as default language and other tweaks but mainly resources, no code at all.

I read Whitelabel Builds | F-Droid - Free and Open Source Android App Repository, but when create my flavor, the compiler star complaining about a missing org.fdroid.fdroid.net.bluetooth.BluetoothClient which is defined in basic and full but not in main. But well i jump the error by coping the class from full into my new flavor, and i have to do this with a lot(all) of classes.
Then those classes need lot of resources that are only in full and i have to copy them in order to compile, so at the end i am coping and pasting the entire full into my new flavor, which i think is not the idea.

i am selecting the build variant before building.

I am missing something? or this is the right procedure to create a new f-droid based flavor?

thanks

Hello,
Maybe you can use initWith in order to base your variant on full?

Can you post your app/build.gradle? You’ll need to understand gradle flavors and flavorDimension to do anything beyond a simple config here: Configure build variants  |  Android Studio  |  Android Developers

My guess is that you need to run something like ./gradlew assembleFullMycompanyDebug to build. You’ll need to choose the build flavor in Android Studio also.

I don’t know initWith, sounds worth trying.

I have made some progress after reading a little deeply the build-variants, now i get the new flavor compiled with no error, which is awesome.
I don´t get the compiled flavor with the new icon or app id, but for example i made some overrides in xml/preferences.xml and did get the change.

here is my app/build.gradle

apply plugin: ‘com.android.application’
apply plugin: ‘checkstyle’
apply plugin: ‘pmd’

/ gets the version name from the latest Git tag, stripping the leading v off /
def getVersionName = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine ‘git’, ‘describe’, ‘–tags’, ‘–always’
standardOutput = stdout
}
return stdout.toString().trim()
}

def isCi = “true”.equals(System.getenv(“CI”))
def preDexEnabled = “true”.equals(System.getProperty(“pre-dex”, “true”))

def cubapkApplicationId = “com.cubapk.app”
def fullApplicationId = “org.fdroid.fdroid”
def basicApplicationId = “org.fdroid.basic”
// yes, this actually needs both quotes Android Studio: Gradle: error: cannot find symbol variable - Stack Overflow
def privilegedExtensionApplicationId = ‘“org.fdroid.fdroid.privileged”’

android {
compileSdkVersion 27
buildToolsVersion ‘27.0.3’

defaultConfig {
versionCode 1004050
versionName getVersionName()

testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
/*
The Android Testing Support Library collects analytics to continuously improve the testing
experience. More specifically, it uploads a hash of the package name of the application
under test for each invocation. If you do not wish to upload this data, you can opt-out by
passing the following argument to the test runner: disableAnalytics “true”.
*/
testInstrumentationRunnerArguments disableAnalytics: ‘true’
}

buildTypes {
// use proguard on debug too since we have unknowingly broken
// release builds before.
all {
minifyEnabled true
useProguard true
shrinkResources true
buildConfigField “String”, “PRIVILEGED_EXTENSION_PACKAGE_NAME”, privilegedExtensionApplicationId
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
testProguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’, ‘src/androidTest/proguard-rules.pro’
}
debug {
applicationIdSuffix “.debug”
resValue “string”, “applicationId”, fullApplicationId + applicationIdSuffix
versionNameSuffix “-debug”
println 'buildTypes.debug defaultConfig.versionCode ’ + defaultConfig.versionCode
}
}

flavorDimensions “base”, “cubapk”
productFlavors {
cubapk {
dimension “cubapk”
applicationId cubapkApplicationId
resValue “string”, “applicationId”, cubapkApplicationId

}
full {
dimension “base”
applicationId fullApplicationId
resValue “string”, “applicationId”, fullApplicationId
}
basic {
dimension “base”
applicationId basicApplicationId
resValue “string”, “applicationId”, basicApplicationId
}
}

compileOptions {
compileOptions.encoding = “UTF-8”
}

aaptOptions {
cruncherEnabled = false
}

dexOptions {
// Improve build server performance by allowing disabling of pre-dexing
// see Tips - Android Studio Project Site
// Skip pre-dexing when running on CI or when disabled via -Dpre-dex=false.
preDexLibraries = preDexEnabled && !isCi
}

testOptions {
unitTests {
includeAndroidResources = true
// prevent tests from dying on android.util.Log calls
returnDefaultValues = true
all {
// All the usual Gradle options.
testLogging {
events “skipped”, “failed”, “standardOut”, “standardError”
showStandardStreams = true
}
}
}
}

sourceSets {
test {
java.srcDirs += “$projectDir/src/testShared/java”
}

androidTest {
java.srcDirs += “$projectDir/src/testShared/java”
}
}

lintOptions {
checkReleaseBuilds false
abortOnError true

htmlReport true
xmlReport false
textReport false

lintConfig file(“lint.xml”)
}

packagingOptions {
exclude ‘META-INF/LICENSE’
exclude ‘META-INF/LICENSE.txt’
exclude ‘META-INF/NOTICE’
exclude ‘META-INF/NOTICE.txt’
exclude ‘META-INF/INDEX.LIST’
exclude ‘.readme’
}
}

dependencies {
implementation ‘com.android.support:support-v4:27.1.1’
implementation ‘com.android.support:appcompat-v7:27.1.1’
implementation ‘com.android.support:gridlayout-v7:27.1.1’
implementation ‘com.android.support:support-annotations:27.1.1’
implementation ‘com.android.support:recyclerview-v7:27.1.1’
implementation ‘com.android.support:cardview-v7:27.1.1’
implementation ‘com.android.support:design:27.1.1’
implementation ‘com.android.support:support-vector-drawable:27.1.1’
implementation ‘com.android.support.constraint:constraint-layout:1.1.2’
implementation ‘com.android.support:palette-v7:27.1.1’
implementation ‘com.android.support:preference-v14:27.1.1’

implementation ‘com.nostra13.universalimageloader:universal-image-loader:1.9.5’
implementation ‘com.google.zxing:core:3.3.2’
implementation ‘info.guardianproject.netcipher:netcipher:2.0.0-beta1’
implementation ‘info.guardianproject.panic:panic:0.5’
implementation ‘commons-io:commons-io:2.5’
implementation ‘commons-net:commons-net:3.5’
implementation ‘ch.acra:acra:4.9.1’
implementation ‘io.reactivex:rxjava:1.1.0’
implementation ‘io.reactivex:rxandroid:0.23.0’
implementation ‘com.hannesdorfmann:adapterdelegates3:3.0.1’
implementation ‘com.ashokvarma.android:bottom-navigation-bar:2.0.5’

implementation ‘com.fasterxml.jackson.core:jackson-core:2.8.7’
implementation ‘com.fasterxml.jackson.core:jackson-annotations:2.8.7’
implementation ‘com.fasterxml.jackson.core:jackson-databind:2.8.7’

implementation ‘org.bouncycastle:bcprov-jdk15on:1.60’
fullImplementation ‘org.bouncycastle:bcpkix-jdk15on:1.60’
fullImplementation ‘cc.mvdan.accesspoint:library:0.2.0’
fullImplementation ‘org.jmdns:jmdns:3.5.3’
fullImplementation ‘org.nanohttpd:nanohttpd:2.3.1’

cubapkImplementation ‘org.bouncycastle:bcpkix-jdk15on:1.60’
cubapkImplementation ‘cc.mvdan.accesspoint:library:0.2.0’
cubapkImplementation ‘org.jmdns:jmdns:3.5.3’
cubapkImplementation ‘org.nanohttpd:nanohttpd:2.3.1’

testImplementation ‘org.robolectric:robolectric:3.8’
testImplementation “com.android.support.test:monitor:1.0.2”
testImplementation ‘org.bouncycastle:bcprov-jdk15on:1.60’
testImplementation ‘junit:junit:4.12’
testImplementation ‘org.mockito:mockito-core:2.7.22’

androidTestImplementation ‘com.android.support:support-annotations:27.1.1’
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2’
androidTestImplementation ‘com.android.support.test:runner:1.0.2’
androidTestImplementation ‘com.android.support.test:rules:1.0.2’
androidTestImplementation ‘com.android.support.test.uiautomator:uiautomator-v18:2.1.3’
}

checkstyle {
toolVersion = ‘7.2’
}

task checkstyle(type: Checkstyle) {
configFile file(“${project.rootDir}/config/checkstyle/checkstyle.xml”)
source ‘src/main/java’, ‘src/test/java’, ‘src/androidTest/java’
include ‘**/*.java’

classpath = files()
}

pmd {
toolVersion = ‘5.5.1’
consoleOutput = true
}

task pmdMain(type: Pmd) {
dependsOn ‘assembleDebug’
ruleSetFiles = files(“${project.rootDir}/config/pmd/rules.xml”, “${project.rootDir}/config/pmd/rules-main.xml”)
ruleSets = // otherwise defaults clash with the list in rules.xml
source ‘src/main/java’
include ‘/*.java’
exclude '
/kellinwood/**/*.java’
}

task pmdTest(type: Pmd) {
dependsOn ‘assembleDebug’
ruleSetFiles = files(“${project.rootDir}/config/pmd/rules.xml”, “${project.rootDir}/config/pmd/rules-test.xml”)
ruleSets = // otherwise defaults clash with the list in rules.xml
source ‘src/test/java’, ‘src/androidTest/java’
include ‘**/*.java’
}

task pmd(dependsOn: [pmdMain, pmdTest]) {}

What worked for me is exactly how it is documented in Whitelabel Builds | F-Droid - Free and Open Source Android App Repository. That means not adding applicationId and resValue to your flavor, and editing the fullApplicationId and basicApplicationId.

Hello, the exact documented snipped did not work, since gradle sync complains with

No flavor is associated with flavor dimension 'base'.

in the link there is no flavor using base dimension, so my guess is that something is missing, if you could please paste the app/build.gradle that worked for you, would be great.

thanks

Try putting dimension 'base' in both the full {} and basic {} blocks

Unfortunately, what worked for me is what is already included in F-Droid
client. I have found that the gradle build flavor stuff can be painful
to setup, but works reliably once you get it. Perhaps try posting some
Android forum where people know more about gradle build flavors.

Yes, since like a little tricky, thanks for your help, ill do that.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.