Android Gradle 3 build failed - android

I have some troubles compiling my project with Gradle 3. When I update my project to use this version of Gradle, the gradle sync is okay, but as soon as I hit the run button, it gives me this:
Error:Execution failed for task
':app:compileBetaGoogleWebkitDebuggableReleaseJavaWithJavac'.
> java.lang.NoClassDefFoundError: com/fyber/annotations/FyberSDK
With older gradle (2.3.3) it works just perfect, but I need to update the project, for undisclosable, professional reason. What can go wrong between those two gradle versions, that one sees the FyberSDK and the other does not?
Here is my gradle script
apply plugin: 'com.android.application'
def mVersionCode = 16;
def mVersionName = "1.16"
android {
signingConfigs {
releaseSigning {
keyAlias 'redacted'
keyPassword 'redacted'
storeFile file('redacted')
storePassword 'redacted'
}
}
compileSdkVersion 23
defaultConfig {
applicationId "redacted"
minSdkVersion 19
targetSdkVersion 23
versionCode mVersionCode
versionName mVersionName
resValue "string", "app_version_name", mVersionName
resValue "string", "app_name", "redacted"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseSigning
}
debuggableRelease {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseSigning
}
}
flavorDimensions "server", "lib"
productFlavors {
pubGoogle {
dimension "server"
minSdkVersion 19
buildConfigField("boolean", "isGoogleBuild", "true")
}
betaGoogle {
dimension "server"
minSdkVersion 14
resValue "string", "app_version_name", mVersionName + "beta"
resValue "string", "app_name", "redacted Beta"
buildConfigField("boolean", "isGoogleBuild", "true")
}
pubAmazon {
dimension "server"
minSdkVersion 19
buildConfigField("boolean", "isGoogleBuild", "false")
}
betaAmazon {
dimension "server"
minSdkVersion 14
resValue "string", "app_version_name", mVersionName + "beta"
resValue "string", "app_name", "redacted Beta"
buildConfigField("boolean", "isGoogleBuild", "false")
}
/*xwalk {
dimension "lib"
}*/
webkit {
dimension "lib"
}
}
}
repositories {
mavenCentral()
maven {
name "Fyber's maven repo"
url "https://fyber.bintray.com/maven"
}
}
configurations {
provided
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.sponsorpay:sponsorpay-android-sdk:7.2.8'
compile 'com.fyber:fyber-sdk:8.17.0'
// Fyber Annotations
provided 'com.fyber:fyber-annotations:1.3.0'
annotationProcessor 'com.fyber:fyber-annotations-compiler:1.4.0'
// Fyber mediation services
// UnityAds Mediation
compile 'com.fyber.mediation:unityads:2.1.1-r1#aar'
// ChartBoost Mediation
compile 'com.fyber.mediation:chartboost:6.6.3-r2#aar'
// Vungle Mediation
compile 'com.fyber.mediation:vungle:5.3.0-r1#aar'
// Vungle third-party dependencies
compile 'com.google.dagger:dagger:2.7'
compile 'javax.inject:javax.inject:1'
compile 'de.greenrobot:eventbus:2.2.1'
compile 'io.reactivex:rxjava:1.2.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.google.android.gms:play-services-basement:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
// For AppsFlyer
compile 'com.appsflyer:af-android-sdk:4.6.0#aar'
compile 'com.google.android.gms:play-services-ads:11.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
//xwalkCompile 'org.xwalk:xwalk_core_library:23.53.589.4'
}
apply plugin: 'com.google.gms.google-services'

I also encountered this problem, eventually solved the problem.
you maybe use a annotations like this:
#FyberSDK
all you need to is find this annotations ,and change it's build.gradle file with this:
apply plugin: 'com.android.library'
android {
// ...
// add this code to enable annotationProcessor
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
}
dependencies {
// ...
// Fyber Annotations
compileOnly 'com.fyber:fyber-annotations:1.3.0'
annotationProcessor 'com.fyber:fyber-annotations-compiler:1.4.0'
// ...
}
try this code ,and sync your project.hope is work fine, it's work fine for me.
if you want learn more for detail, you can read my blog here:
https://segmentfault.com/a/1190000012245056

Related

How Do I Solve Android Gradle Plugin Error On Android Studio 3.1.1?

I upgraded Android Gradle plugin to version 3.1.1 and Gradle to Version 4.4. I got the error. How can I solve it?. Please, Anyone.
Could not find method flavorDimension() for arguments [market] on
ProductFlavor_Decorated{name=google, dimension=null,
minSdkVersion=null, targetSdkVersion=null, renderscriptTargetApi=null,
renderscriptSupportModeEnabled=null,
renderscriptSupportModeBlasEnabled=null,
renderscriptNdkModeEnabled=null, versionCode=null, versionName=null,
applicationId=null, testApplicationId=null,
testInstrumentationRunner=null, testInstrumentationRunnerArguments={},
testHandleProfiling=null, testFunctionalTest=null, signingConfig=null,
resConfig=null, mBuildConfigFields={}, mResValues={},
mProguardFiles=[], mConsumerProguardFiles=[],
mManifestPlaceholders={}, mWearAppUnbundled=null} of type
com.android.build.gradle.internal.dsl.ProductFlavor. Open File
My (OLD) build.gradle code.
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'XXXXXX'
keyPassword 'XXXXXX'
storeFile file('../XXXXXX.jks')
storePassword 'XXXXXX'
}
}
compileSdkVersion 26
buildToolsVersion "26.0.3"
defaultConfig {
applicationId 'com.XXX.XXX'
minSdkVersion 16
targetSdkVersion 27
versionCode 5
versionName "5.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
signingConfig signingConfigs.config
}
}
productFlavors {
dev {
// Enable pre-dexing to produce an APK that can be tested on
// Android 5.0+ without the time-consuming DEX build processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the production version.
minSdkVersion 16
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// my lib
compile project(':cdroid')
compile project(':videoview')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'org.jsoup:jsoup:1.10.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.firebase:firebase-ads:10.2.4'
compile 'nz.co.delacour.exposure-core:exposurevideoplayer:1.0.3'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'fm.jiecao:jiecaovideoplayer:5.5.4'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
(I still see the error) I modified my build.gradle to
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'XXXXX'
keyPassword 'XXXXX'
storeFile file('../XXXXX.jks')
storePassword 'XXXXX'
}
}
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId 'com.XXXXX.XXXXX'
minSdkVersion 16
targetSdkVersion 27
versionCode 5
versionName "5.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
signingConfig signingConfigs.config
}
}
flavorDimensions "minApi"
productFlavors {
dev {
// Enable pre-dexing to produce an APK that can be tested on
// Android 5.0+ without the time-consuming DEX build processes.
minSdkVersion 21
dimension "minApi"
}
prod {
// The actual minSdkVersion for the production version.
minSdkVersion 16
dimension "minApi"
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// my lib
compile project(':cdroid')
compile project(':videoview')
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:support-compat:27.1.1'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'org.jsoup:jsoup:1.10.1'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.firebase:firebase-ads:15.0.0'
compile 'nz.co.delacour.exposure-core:exposurevideoplayer:1.0.3'
compile 'com.android.support.constraint:constraint-layout:1.1.0'
compile 'fm.jiecao:jiecaovideoplayer:5.5.4'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:multidex:1.0.3'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
My New Error iS
Unable to load class 'org.gradle.api.internal.component.Usage'.
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
As of Android Gradle plugin version 3.0, all flavors must be assigned to a flavor dimension.
flavorDimensions "minApi"
productFlavors {
dev {
// Enable pre-dexing to produce an APK that can be tested on
// Android 5.0+ without the time-consuming DEX build processes.
minSdkVersion 21
dimension "minApi"
}
prod {
// The actual minSdkVersion for the production version.
minSdkVersion 16
dimension "minApi"
}
}
Also, you should be using the latest tools version and you should update various other parts of your build.gradle file (for instance, compile is deprecated and should be replace with implementation or, sometimes, api) For more information, see Migrate to Android Plugin for Gradle 3.0.0.
Just change buildToolsVersion of build.gradle(app) and set it to '27.0.3' sync the gradle.
buildToolsVersion '27.0.3'
the gradle 4.4 required flavour dimension, define default flavour dimension in you app build.gradle
android {
...
flavorDimensions "default"
...
}
I had the same issue. But after some research I came up with the code below, everything working fine now. Hopefully, this might helpful to someone else.
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.APPNAME.androidapp"
minSdkVersion 21 //flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
flavorDimensions "default"
productFlavors {
production {
dimension "default"
resValue "string", "app_name", "APPNAME"
applicationIdSuffix ""
}
staging {
dimension "default"
resValue "string", "app_name", "APPNAME Stg"
applicationIdSuffix ".stg"
}
development {
dimension "default"
resValue "string", "app_name", "APPNAME Dev"
applicationIdSuffix ".dev"
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

I am not able to build release APK. Every time I get DexMergerException.
Here are my build.gradles:
I am using MVVM structure. I have core(package name for core is same as my app package) has my lib where I only write view models, models and network layers.
Errors I am getting:
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException
Program type already present:
app build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
signingConfigs {
debug {
storeFile file(DEBUG_STORE_FILE)
}
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
v2SigningEnabled false
}
}
compileSdkVersion 27
flavorDimensions "default"
defaultConfig {
applicationId "com.puma.one8crew"
minSdkVersion 21
targetSdkVersion 27
vectorDrawables.useSupportLibrary = true
versionCode 1
multiDexEnabled true
versionName "1.0"
resValue 'string', 'facebook_app_id', FACEBOOK_APP_ID_DEV
resValue 'string', 'fb_login_protocol_scheme', FACEBOOK_LOGIN_PROTOCOL_SCHEME
manifestPlaceholders += [
FACEBOOK_APP_ID_BGY: FACEBOOK_APP_ID_DEV,
FB_LOGIN_SCHEME : FACEBOOK_LOGIN_PROTOCOL_SCHEME
]
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dataBinding {
enabled = true
}
buildTypes {
debug {
minifyEnabled false
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
/* productFlavors {
prod {
resValue 'string', 'facebook_app_id', FACEBOOK_APP_ID_DEV
resValue 'string', 'fb_login_protocol_scheme', FACEBOOK_LOGIN_PROTOCOL_SCHEME
}
stage {
resValue 'string', 'facebook_app_id', FACEBOOK_APP_ID_DEV
resValue 'string', 'fb_login_protocol_scheme', FACEBOOK_LOGIN_PROTOCOL_SCHEME
}
}*/
applicationVariants.all { variant ->
variant.outputs.all { output ->
def project = "one8crew"
outputFileName = "${project}_${variant.buildType.name}_${variant.versionName}.apk"
}
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = true //delete the already predexed libraries
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':core')
implementation 'com.android.support:animated-vector-drawable:27.0.1'
implementation 'com.android.support:customtabs:27.0.1'
implementation 'com.android.support:cardview-v7:27.0.1'
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
implementation 'com.android.support:recyclerview-v7:27.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.android.support:support-v4:27.0.1'
implementation 'com.android.support:design:27.0.1'
implementation 'com.android.support:support-v13:27.0.1'
implementation 'com.alimuzaffar.lib:pinentryedittext:1.3.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//Dependencies for LifeCycle Android ViewModel
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation project(':com.wowza.gocoder.sdk')
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
//support design lib dependency fot tab
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1#aar') {
transitive = true;
}
}
Below is my core build.gradle and I have also updated the same version for all lib.
core build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
repositories {
flatDir {
dirs 'libs'
}
jcenter()
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
compileOnly 'com.wowza.gocoder.sdk.android:com.wowza.gocoder.sdk:1.0b7#aar'
// compile 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.google.dagger:dagger:2.11'
api('com.squareup.retrofit2:retrofit:2.1.0') {
exclude module: 'okhttp'
}
api 'com.google.code.gson:gson:2.8.1'
api 'com.squareup.retrofit2:converter-gson:2.3.0'
api 'swarajsaaj:otpreader:1.1'
api 'com.github.bumptech.glide:glide:4.3.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
//Dependencies for LifeCycle Android ViewModel
implementation 'android.arch.lifecycle:extensions:1.1.1'
// annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
compileOnly project(':com.wowza.gocoder.sdk')
compile project(':libraries:horizontalcalendar')
compile project(':libraries:calendarview')
//Library for setting fonts
api 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.android.support:multidex:1.0.3'
}
I tried so many time and I am not able to understand the reason behind this issue.
Same happened today to me and this is what solved the issue:
Find all the dependencies of com.google.android.gms:play-services.
They all have now different versions. Just place the mouse over them and correct the version numbers (i.e. for me was upgrading maps from 15.0.0 to 15.0.2 and tag-manager to 15.0.1)

Execution failed for task ':app:transformClassesWithInstantRunForClientDebug'

The error
My gradle file
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
compile project(':venuemap')
// compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
// compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"
// compile "com.android.support:design:$rootProject.supportLibraryVersion"
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
// compile "com.google.android.gms:play-services:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-location:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-maps:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-plus:$rootProject.playServicesVersion"
compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
compile "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"
compile "com.squareup.okhttp3:okhttp:$rootProject.okhttpVersion"
compile "com.squareup.okhttp3:logging-interceptor:$rootProject.okhttpVersion"
compile 'com.google.maps.android:android-maps-utils:0.4.4'
// compile 'com.google.maps.android:android-maps-utils:0.4+'
// compile 'com.google.maps.android:android-maps-utils:0.5+'
compile 'net.hockeyapp.android:HockeySDK:4.1.1'
compile 'com.flurry.android:analytics:6.5.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0#aar'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'org.parceler:parceler-api:1.1.9'
compile 'com.github.jd-alexander:library:1.1.0'
compile 'com.android.support:multidex:1.0.0'
compile "com.google.firebase:firebase- core:$rootProject.playServicesVersion"
compile 'com.facebook.android:facebook-android-sdk:4.+'
// annotationProcessor 'org.parceler:parceler:1.1.9'
compile('com.crashlytics.sdk.android:answers:1.4.0#aar') {
transitive = true;
}
}
android {
def defaultApplicationId = "com.yamo.android"
def defaultVersionName = "1.1.7"
def buildNumber = "53" // increment when merging with master
def defaultVersionCode = Integer.parseInt(buildNumber)
def buildNumberSuffix = " (" + buildNumber + ")"
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
applicationId defaultApplicationId
versionCode defaultVersionCode
versionName defaultVersionName
vectorDrawables.useSupportLibrary = true
// multiDexEnabled true
}
signingConfigs {
debug {
storeFile rootProject.file("keystore/debug.keystore")
}
release {
storeFile rootProject.file("keystore/release.keystore")
storePassword "password"
keyAlias "locassa"
keyPassword "password"
}
}
buildTypes {
debug {
minifyEnabled true
useProguard false
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
useProguard true
shrinkResources true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
live {
versionName defaultVersionName + buildNumberSuffix
}
client {
versionName defaultVersionName + "-CLIENT" + buildNumberSuffix
applicationId defaultApplicationId
}
internal {
versionName defaultVersionName + "-INTERNAL" + buildNumberSuffix
applicationId defaultApplicationId + ".internal"
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
}
//apply from:
rootProject.file('config/checkstyle/checkstyle.gradle')
apply plugin: 'com.google.gms.google-services'
}
When building app, I have got this error.
I am using android studio 2.3.3.
CompileSdkVersion is 26 and buildToolsVersion is 26.0.2.
And my gradle version is 2.3.3.
I have been searching the solution about this problem for several days but I didn't find anything on google.
Please help me to resolve this error. Thanks a lot!
This is your Problem :
compile 'com.facebook.android:facebook-android-sdk:4.+'
Use this :
compile 'com.facebook.android:facebook-android-sdk:4.4.0'

android gradle build - run task before assembleRelease or assembleLive

Below is my build.gradle file for app.
build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
android {
signingConfigs {
liveSigning {
keyAlias 'xxxxxxx'
keyPassword 'xxxxxx'
storeFile file('D:\\xxxxx\\xxxxxxx\\xxxxx\\xxxx.jks')
storePassword 'xxxxxxx'
}
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
useLibrary 'org.apache.http.legacy'
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [];
}
defaultConfig {
applicationId rootProject.ext.applicationId
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
multiDexEnabled true
resConfigs "en"
vectorDrawables.useSupportLibrary true
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.liveSigning
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
task ndkBuild(type: Exec) {
commandLine rootProject.ext.ndkPath, '-C', file('src/main').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
lintOptions {
abortOnError false
}
productFlavors {
live {
minSdkVersion rootProject.ext.minSdkVersion
applicationId rootProject.ext.applicationId
signingConfig signingConfigs.liveSigning
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
resConfigs "en"
}
}
flavorDimensions "default"
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//compile files('libs/gson-2.2.4.jar')
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:design:${rootProject.ext.supportLibVersion}"
compile files('libs/cordova-5.jar')
compile files('libs/org.apache.commons.io.jar')
compile files('libs/httpmime-4.2.3.jar')
compile files('libs/jsoup-1.7.3.jar')
compile files('libs/activation.jar')
compile project(':libraries:EventBus')
compile project(':libraries:PDFViewCtrlTools')
compile project(':libraries:imageannotations')
compile project(':libraries:bottom-bar')
compile project(':libraries:tooltip')
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
compile files('libs/glide-3.6.1.jar')
//compile 'com.roughike:bottom-bar:2.2.0'
compile project(':libraries:k4l-video-trimmer')
compile 'com.android.support:multidex:1.0.1'
compile 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.0.1'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'me.relex:circleindicator:1.2.2'
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
apply plugin: 'com.google.gms.google-services'
Before I generate signed APK to upload for google play store , I want to execute command line code. And by using that command line program i want to do some pre release activity like disable logs of NDK, change url to live website and etc. So how can I execute it before assembleLive or assembleRelease ? I don't want to execute that command line code before "assembleDebug". I want to execute it only before "assembleLive or assembleRelease".
I added below code to my gradle file and it works like a charm.
task prelivetask (type: Exec) {
commandLine 'cmd','/C', 'start', 'change.cmd'
}
tasks.whenTaskAdded { task ->
if (task.name == 'assembleRelease' || task.name == 'assembleLive') {
task.dependsOn prelivetask
}
}

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