Plugin with id 'com.onesignal.androidsdk.GradleProjectPlugin' not found - android

I'm trying to run my code in android studio
this is my error
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with
id 'com.onesignal.androidsdk.GradleProjectPlugin' not found.
This is my module code :
apply plugin: "com.android.application" apply from: "../utils.gradle"
apply plugin: "com.onesignal.androidsdk.GradleProjectPlugin"
android { compileSdkVersion 32 buildToolsVersion "30.0.3"
defaultConfig { applicationId "com.zakat" minSdkVersion 19
targetSdkVersion 32 versionCode getVersionCode(VERSION_MAJOR,
VERSION_MINOR, VERSION_PATCH, VERSION_BUILD) versionName
getVersionName(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
multiDexEnabled true vectorDrawables.useSupportLibrary = true }
signingConfigs { release { def keystoreProperties =
getKeystoreProperties
file("../${project.property('keystore.properties')}") storeFile
file("../${project.property('keystore.file')}") storePassword
keystoreProperties["keystore.store.password"] keyAlias
keystoreProperties["keystore.key.alias"] keyPassword
keystoreProperties["keystore.key.password"] } }
buildTypes { debug { buildConfigField "boolean", "LOGS", "true"
buildConfigField "boolean", "DEV_ENVIRONMENT", "true"
buildConfigField "boolean", "TEST_ADS", "false"
versionNameSuffix "-debug" }
release { buildConfigField "boolean", "LOGS", "false"
buildConfigField "boolean", "DEV_ENVIRONMENT", "false"
buildConfigField "boolean", "TEST_ADS", "false"
signingConfig signingConfigs.release zipAlignEnabled true
minifyEnabled false shrinkResources false proguardFiles
getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
} }
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 }
setProperty("archivesBaseName", getArtifactName(defaultConfig))
// workaround for https://issuetracker.google.com/issues/141132133
configurations.all { resolutionStrategy { force
"androidx.appcompat:appcompat:1.2.0-rc02" } } }
dependencies { implementation fileTree(dir: "libs", include:
["*.jar"]) implementation(name: "config", ext: "aar") implementation
"androidx.appcompat:appcompat:1.2.0-rc02" // workaround for
https://issuetracker.google.com/issues/141132133 implementation
"androidx.fragment:fragment:1.2.5" implementation
"androidx.multidex:multidex:2.0.1" implementation
"com.google.android.ads.consent:consent-library:1.0.8" implementation
"com.google.android.material:material:1.1.0" implementation
"com.google.firebase:firebase-ads:19.3.0" implementation
"com.google.firebase:firebase-analytics:17.4.4" implementation
"com.google.firebase:firebase-messaging:20.2.4" implementation
"com.onesignal:OneSignal:3.15.1" implementation
"org.alfonz:alfonz-utility:0.9.2" implementation
"org.alfonz:alfonz-view:0.9.2" classpath
"gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.11.0"
//classpath
"gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1,
0.99.99]" classpath "com.google.gms:google-services:4.2.0" }
apply plugin: "com.google.gms.google-services"
Can anyone help me? Thank you

Related

Getting error in build.gradle : No signature of method: build_2gzryvmsr2xvhzda2muxrnzeq.android() is applicable for argument types

I'm trying to define product flavors like this but getting error in the same:
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.test.test"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
dataBinding {
enabled = true
}
buildTypes {
release {
debuggable false
useProguard true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions 'default'
productFlavors {
uat {
applicationId "com.test.test"
versionCode 1
versionName "1.0.0"
buildConfigField "String", 'HOST', '""'
resValue 'string', 'app_name', "Test"
isDefault.set(true)
}
prod {
applicationId "com.test.test"
versionCode 1
versionName "1.0.0"
buildConfigField "String", 'HOST', '""'
resValue 'string', 'app_name', "Test"
}
}
aaptOptions {
cruncherEnabled = false
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//Resize library
implementation 'com.intuit.sdp:sdp-android:1.0.6'
//Spinkit
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
//Kotlin Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"
//Retrofit & GSON Parsing
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okio:okio:2.8.0'
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.4.1"))
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:okhttp-urlconnection")
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
implementation "com.squareup.moshi:moshi-adapters:1.5.0"
}
Here's the error
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
Caused by: groovy.lang.MissingMethodException: No signature of method: build_2gzryvmsr2xvhzda2muxrnzeq.android() is applicable for argument types: (build_2gzryvmsr2xvhzda2muxrnzeq$_run_closure1) values: [build_2gzryvmsr2xvhzda2muxrnzeq$_run_closure1#64cb0e38]
at build_2gzryvmsr2xvhzda2muxrnzeq.run
Can anyone help me with this?
Thanks in advance.
The problem is here:
buildTypes {
release {
debuggable false
useProguard true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
delete useProguard true the problem will be resolved

Google Play: Bundle was not signed

I'm creating app in Kotlin and I paid Google developer account. But there is some problem with upload .aab file: The Android App Bundle was not signed. I readed all topics at Stackoverflow about it and tried all solutions. Not works for me.
signingConfig signingConfigs.release in build.gradle ends with this error: Could not get unknown property 'release' for SigningConfig. It works only when I set signingConfig. I'm using also this: minifyEnabled false and debuggable = false. So what another I must to try? There exists some new solution for year 2021?!
My build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId '...'
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.00"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders["hostName"] = "..."
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig
debuggable = false
}
applicationVariants.all{
variant ->
variant.outputs.each{
output->
def name = "...apk"
output.outputFileName = name
}
}
}
buildFeatures{
dataBinding = true
viewBinding = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking:v1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
I had the same issue when I set "debuggable true" for release build type variant,
pls ensure "debuggable false" is set for release type.
buildTypes {
release {
minifyEnabled true
debuggable false
}
Step by step how to create signed aab file:
In the next window select Android App Bundle (aab)
Now you have to create your own signing key. If you want upload any update in the future, you must sign it with this signing key you created here.
Also every update you need to increment version in build.gradle(app).
Edit 1:
Change: signingConfig to: signingConfig signingConfigs.release and add this:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
The full code:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId '...'
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.00"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders["hostName"] = "..."
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
debuggable = false
}
applicationVariants.all{
variant ->
variant.outputs.each{
output->
def name = "...apk"
output.outputFileName = name
}
}
}
buildFeatures{
dataBinding = true
viewBinding = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking:v1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
Edit 2:
I just uploaded the project aab to Google Play with this build.gradle(app):
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 31
defaultConfig {
applicationId "pfhb.damian.uploadtest"
minSdk 28
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
You have to create signing config release, Hope this will work. Let me know if you want to know how to create this block will be more happy to help you.
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'com.google.gms.google-services'
}
//repositories { maven { url 'https://maven.cashfree.com/release' } }
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.xyz.medicine"
minSdkVersion 27
targetSdkVersion 30
versionCode 4
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
// Please check if you have this block or not
signingConfigs {
release {
storeFile file('../secrets/keystore.jks')
storePassword 'DUMMYPASSWORD'
keyAlias 'DUMMYALIAS'
keyPassword 'DUMMYPASSWORD'
}
}
buildTypes {
release {
resValue "string", "BASE_URL", "https://obhaiyya.com/proMaid/"
shrinkResources true
minifyEnabled true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
shrinkResources false
minifyEnabled false
debuggable true
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
buildFeatures {
dataBinding true
}
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-messaging-ktx:22.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "com.airbnb.android:lottie:3.7.1"
}

After update to Android 10 api version 29, SQLite database crashes

After updating my project to android 10 I got crash on database open.
Logcat report:
2020-11-16 09:27:52.091 20196-22102/? E/SQLiteDatabase: Failed to open database '/data/user/0/bezeq.gala.preprod/databases/bezeqlocator.db'.
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 1294 SQLITE_CANTOPEN_ENOENT[1294]): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:300)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:218)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:737)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:284)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:251)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1386)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1331)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:994)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:940)
at com.bezeq.locator.dao.db.DBHelper.checkDataBase(DBHelper.java:210)
at com.bezeq.locator.dao.db.DBHelper.create(DBHelper.java:154)
at com.bezeq.locator.service.services.OnStartService$CreateDbFromFile.doInBackground(OnStartService.java:113)
at com.bezeq.locator.service.services.OnStartService$CreateDbFromFile.doInBackground(OnStartService.java:101)
at android.os.AsyncTask$3.call(AsyncTask.java:378)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "bezeq.gala"
minSdkVersion 24
targetSdkVersion 29
versionCode 71
versionName "15.0.71"
multiDexEnabled true
project.ext.set("archivesBaseName", "bview-" + defaultConfig.versionName);
}
dexOptions {
javaMaxHeapSize "4096M"
}
signingConfigs {
release {
keyAlias 'gala'
storeFile file('\\\\amam\\root\\oss\\BVieW\\Keys\\gala_signature_key.jks')
keyPassword System.getenv("BviewKeystorePassword")
storePassword System.getenv("BviewKeystorePassword")
}
}
buildTypes {
def PERMISSIONS_SYSTEM_SYMBOL = "PERMISSIONS_SYSTEM_SYMBOL"
def REST_API_URL = "REST_API_URL"
localhost_emulator {
applicationIdSuffix ".dev"
debuggable true
signingConfig signingConfigs.release
buildConfigField 'String', PERMISSIONS_SYSTEM_SYMBOL, '"GALD"';
buildConfigField 'String', REST_API_URL, '"http://10.0.2.2:8080/gala"';
manifestPlaceholders = [appName: "BVieW Dev"]
}
localhost_device {
applicationIdSuffix ".dev"
debuggable true
signingConfig signingConfigs.release
buildConfigField 'String', PERMISSIONS_SYSTEM_SYMBOL, '"GALD"';
buildConfigField 'String', REST_API_URL, '"http://localhost:5000/gala"';
manifestPlaceholders = [appName: "BVieW Dev"]
}
debug {
applicationIdSuffix ".dev"
debuggable true
signingConfig signingConfigs.release
buildConfigField 'String', PERMISSIONS_SYSTEM_SYMBOL, '"GALD"';
buildConfigField 'String', REST_API_URL, '"http://vm-tbvwwebt1.bezeq.com:8180/gala"';
manifestPlaceholders = [appName: "BVieW Dev"]
}
tst { // Build types may not start with 'test'
applicationIdSuffix ".tst"
debuggable false
signingConfig signingConfigs.release
buildConfigField 'String', PERMISSIONS_SYSTEM_SYMBOL, '"GALT"';
buildConfigField 'String', REST_API_URL, '"http://vm-tbvwwebt1.bezeq.com:8180/gala"';
manifestPlaceholders = [appName: "BVieW Test"]
}
release {
debuggable false
// minifyEnabled true
signingConfig signingConfigs.release
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'String', PERMISSIONS_SYSTEM_SYMBOL, '"GALA"';
buildConfigField 'String', REST_API_URL, '"http://bview.bezeq.com/gala"';
manifestPlaceholders = [appName: "BVieW"]
}
preprod {
initWith release
applicationIdSuffix ".preprod"
manifestPlaceholders = [appName: "BVieW PreProd"]
}
}
flavorDimensions "version"
productFlavors {
regular {
dimension "version"
}
skip_login {
dimension "version"
}
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
}
repositories {
maven { url "https://mint.splunk.com/gradle/" }
maven { url "https://repo.spring.io/release" }
jcenter()
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//multidex suppport for android < 5.0
implementation 'androidx.multidex:multidex:2.0.1'
//design stuff
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
//google stuff
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.libraries.places:places-compat:2.2.0'
//mint (crash report & statistics)
implementation 'com.splunk.mint:mint:4.0.9'
//spring framework
implementation 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
implementation 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
//sliding panel
implementation 'com.sothree.slidinguppanel:library:3.3.1'
//circle image
implementation 'de.hdodenhof:circleimageview:2.1.0'
//usb serial connection
implementation 'com.github.felHR85:UsbSerial:4.5'
}

Why does adding product flavors to my libraries build.gradle file cause my local app to be unable to resolve imported dependencies from said library?

I'm developing an android application for my company. The project holds directories: our sdk (library in this case) and a sample app that imports the sdk. When I add product flavors to the sdk (library) the app breaks due to being unable to resolve the dependencies imported from the sdk.
The errors are:
error cannot find symbol class S
error cannot find symbol class SO
error package S does not exist
error method does not override or
implement a method from a supertype
Here is the top-level/project level build.gradle file
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.novoda:bintray-release:0.9'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is the SDK/Library build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.novoda.bintray-release'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName version
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultPublishConfig "nonlocationVersionRelease"
publishNonDefault true
flavorDimensions "version"
productFlavors {
nonlocation {
dimension "version"
}
location {
dimension "version"
}
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
lintOptions {
abortOnError false
}
}
configurations {
javadocDeps
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
}
publish {
userOrg = '*******'
groupId = 'com.*******.android'
artifactId = '*******'
publishVersion = '2.0.0'
desc = '******* sdk'
website = 'https://github.com/*******/*******-android-public-sdk'
}
and here is the app's build.gradle file:
apply plugin: 'com.android.application'
def computeVersionCode = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', 'HEAD', '--count'
standardOutput = stdout
}
return stdout.toString().trim().toInteger();
}
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.*******.demo"
minSdkVersion 15
targetSdkVersion 27
versionCode computeVersionCode()
versionName "1.0"
renderscriptTargetApi 20
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
debugConfig {
storeFile file("debug.jks")
storePassword "*******"
keyAlias "com.*******.android"
keyPassword "*******"
}
releaseConfig {
storeFile file("release.jks")
storePassword "*******"
keyAlias "com.*******.android"
keyPassword "*******"
}
}
buildTypes {
debug {
signingConfig signingConfigs.debugConfig
}
release {
signingConfig signingConfigs.releaseConfig
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'
implementation 'com.google.guava:guava:23.0'
implementation 'com.squareup:seismic:1.0.2'
implementation 'net.hockeyapp.android:HockeySDK:3.7.0'
implementation 'jp.wasabeef:blurry:1.0.5'
implementation project(path: ':*******-sdk', configuration:'default')
}
I have been trying to fix this for 4 days and am still stuck. I've tried all of the typical solutions found on stackoverflow. This has been a cascade of problem after problem and this specific one came directly after updating how the sdk is loaded in the app's build.gradle file. I suspect something is wrong with this line where I import the sdk as a dependency (end of app's build.gradle):
implementation project(path: ':*******-sdk', configuration:'default')
but not including 'configuration: 'default'' causes another bug where the app cannot discern which buildVariant of the SDK to use.
How can I get my app up and running while also maintaining the product flavors found in the SDK?

In my app I have a module(a library).When I set 'productFlavors' in the library build.The application can't dependency the module

In my app I have a module(basiclib is a library).When I set 'productFlavors' in the library build.I build the project.The application has more import error.It can't import the basiclib package,and the bascilib dependencies's package.
But I remove 'productFlavors' of basiclib.every thing is right.
Application build :
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
dataBinding {
enabled true
}
defaultConfig {
applicationId "xxxx"
minSdkVersion 11
targetSdkVersion 22
versionCode 18000
versionName "1.0.0"
}
lintOptions {
abortOnError false
}
buildTypes {
release {
signingConfig signingConfigs.myConfig
minifyEnabled true;
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
}
flavorDimensions "url", "theme"
productFlavors {
sit {
buildConfigField 'String', 'API_URL', '"xxxx"'
dimension "url"
}
uat {
buildConfigField 'String', 'API_URL', '"xxxx"'
dimension "url"
}
prd {
buildConfigField 'String', 'API_URL', '"xxx"'
dimension "url"
}
themewhite {
buildConfigField 'String', 'theme', '"white"'
dimension "theme"
}
}
sourceSets {
sit {
java.srcDirs = ['src/sit_uat/java']
}
uat {
java.srcDirs = ['src/sit_uat/java']
}
prd {
java.srcDirs = ['src/prd/java']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
sitCompile 'com.bugtags.library:bugtags-lib:latest.integration'
prdCompile 'com.umeng.analytics:analytics:latest.integration'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.0'
compile 'com.jiechic.library:xUtils:2.6.14'
compile 'com.loopj.android:android-async-http:1.4.7'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
// Did'n work.
compile project(path: ':basiclib')
}
Library build(basiclib)
apply plugin: 'com.android.library'
apply plugin: 'realm-android'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "url"
productFlavors {
sit {
buildConfigField 'String', 'API_URL', '"xxxxx"'
dimension "url"
}
uat {
buildConfigField 'String', 'API_URL', '"xxxxx"'
dimension "url"
}
prd {
buildConfigField 'String', 'API_URL', '"xxxxx"'
dimension "url"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.google.code.gson:gson:2.5'
compile 'io.realm:realm-android-library:2.2.2'
compile 'com.android.databinding:library:1.1'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.android.support:appcompat-v7:23.2.1'
}
I had the same problem and after a lot of searching I found the following documentation entry:
http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Referencing-a-Library
In short: Per default, in library modules only the default configuration (release / no flavour) is visible to other modules. To access the different flavours from your main module, add
publishNonDefault true
in the android section of your library's build.gradle file.
Then you have to add different flavours for the main module as well, they can be empty declarations. In the dependency section of your build.gradle reference the module as follows:
flavor1Compile project(path: ':yourlib', configuration: 'flavor1Release')
flavor2Compile project(path: ':yourlib', configuration: 'flavor2Release')

Categories

Resources