I'm trying to make a class for instrumentation test. This class is in the androidTest folder app\src\androidTest\java\.... However, AndroidJUnit4 and ActivityTestRule cannot resolve. In the import statement, import android.support.test.runner.AndroidJUnit4 the word "runner" is in red. The test class is in Kotlin. I tried deleted it and created one in Java, but still cannot import AdnroidJUnit4. I read some similar questions but didn't find the solution to my case. Those two are the project and app build.gradle files:
Is there anything wrong with my gradle files?
app build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.sample.me"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
archivesBaseName = "$applicationId-$versionName-$versionCode"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// For room compat
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
sourceSets {
androidTest.assets.srcDirs +=
files("$projectDir/schemas".toString())
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
}
}
buildToolsVersion '27.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// Room
implementation "android.arch.persistence.room:runtime:$rootProject.ext.roomVersion"
kapt "android.arch.persistence.room:compiler:$rootProject.ext.roomVersion"
// Support libs
implementation "com.android.support:recyclerview-v7:$rootProject.ext.supportVersion"
implementation "com.android.support:design:$rootProject.ext.supportVersion"
implementation "com.android.support:cardview-v7:$rootProject.ext.supportVersion"
implementation "com.android.support:appcompat-v7:$rootProject.ext.supportVersion"
implementation "com.android.support.test.espresso:espresso-idling-resource:$rootProject.ext.espressoVersion"
implementation 'joda-time:joda-time:2.9.9'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$rootProject.ext.kotlinVersion"
// Dependencies for local unit tests
testImplementation "junit:junit:$rootProject.ext.junitVersion"
testImplementation "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"
testImplementation "org.mockito:mockito-core:$rootProject.ext.mockitoVersion"
// Android Testing Support Library's runner and rules
androidTestImplementation "com.android.support.test:runner:$rootProject.ext.runnerVersion"
androidTestImplementation "com.android.support.test:rules:$rootProject.ext.runnerVersion"
// Dependencies for Android unit tests
androidTestImplementation "junit:junit:$rootProject.ext.junitVersion"
androidTestImplementation "org.mockito:mockito-android:$rootProject.ext.mockitoVersion"
//androidTestImplementation "com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-contrib:$rootProject.ext.espressoVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:$rootProject.ext.espressoVersion"
// Resolve conflicts between main and test APK: not resolve
androidTestImplementation "com.android.support:support-annotations:$rootProject.ext.supportVersion"
androidTestImplementation "com.android.support:support-v4:$rootProject.ext.supportVersion"
androidTestImplementation "com.android.support:recyclerview-v7:$rootProject.ext.supportVersion"
androidTestImplementation "com.android.support:appcompat-v7:$rootProject.ext.supportVersion"
androidTestImplementation "com.android.support:design:$rootProject.ext.supportVersion"
androidTestImplementation "com.android.support.test.espresso.idling:idling-concurrent:$rootProject.ext.espressoVersion"
androidTestImplementation "android.arch.persistence.room:testing:$rootProject.ext.roomVersion"
}
repositories {
mavenCentral()
}
top build.gradle
ext {
// Sdk and tools
compileSdkVersion = 26
targetSdkVersion = 26
minSdkVersion = 19
buildToolsVersion = '27.0.1'
supportVersion = '27.0.2'
// App dependencies
espressoVersion = '3.0.1'
roomVersion = '1.1.0-alpha1'
junitVersion = '4.12'
mockitoVersion = '2.8.47'
hamcrestVersion = '1.3'
runnerVersion = '1.0.1'
rulesVersion = '1.0.1'
espressoVersion = '3.0.1'
}
buildscript {
ext.kotlinVersion = '1.2.21'
ext.gradlePluginVersion = '2.3.0'
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-beta1' // Use plain string for auto update
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
repositories {
jcenter()
google()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
update Finally find out that this is because a blank space in project path. I removed the space and now can import the classes.
Try adding these in the dependancy these
androidTestCompile 'com.android.support.test:rules:1.0.2'
androidTestCompile 'com.android.support.test:runner:1.0.2'
Related
I have taken over an ex-employees project and I have been trying to make it run since past two days. However, the error I got today took a complete day but is still unsolvable.
I have been getting parameter specified as non null is null for compileSdkVersion in build.gradle of one of the sub projects. The main build.gradle has the required Sdk versions specified but this is still throwing error.
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
jcenter()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.25.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
signingConfigs {
config {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
dataBinding {
enabled = true
}
compileSdkVersion compileSdk
defaultConfig {
applicationId "com.cleanaway.driversapp"
minSdkVersion minSdk
targetSdkVersion targetSdk
multiDexEnabled true
versionCode 108400
versionName "1.84.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.config
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
buildTypes {
debug {
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "product", "mode"
productFlavors {
mock {
applicationIdSuffix = ".mock"
dimension "mode"
}
dev {
applicationIdSuffix = ".dev"
dimension "mode"
}
prod {
dimension "mode"
}
demo {
applicationIdSuffix = ".demo"
dimension "product"
}
cleanaway {
dimension "product"
}
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter()
//google()
}
kapt {
correctErrorTypes = true
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/evercam-stepglobal-1.0.jar')
implementation project(':ipcameracontrol')
implementation project(':cleanawaymodel')
implementation project(':vehicleapi')
implementation project(':networkutilities')
implementation project(':telogisapi')
//Crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.6#aar') {
transitive = true;
}
// Android/Google
implementation "com.android.support:appcompat-v7:$rootProject.libAndroidSupportVersion"
implementation "com.android.support:design:$rootProject.libAndroidSupportVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation "com.android.support:recyclerview-v7:$rootProject.libAndroidSupportVersion"
implementation "com.android.support:cardview-v7:$rootProject.libAndroidSupportVersion"
implementation "androidx.appcompat:appcompat:1.+"
//Firebase
implementation "com.google.firebase:firebase-core:$rootProject.firebaseVersion"
implementation "com.google.firebase:firebase-storage:$rootProject.firebaseVersion"
implementation "com.google.firebase:firebase-auth:$rootProject.firebaseVersion"
// Android architecture components
implementation 'android.arch.lifecycle:extensions:1.1.1'
kapt "android.arch.lifecycle:compiler:1.1.1"
implementation 'android.arch.persistence.room:runtime:1.1.1'
kapt "android.arch.persistence.room:compiler:1.1.1"
implementation "android.arch.persistence.room:rxjava2:1.1.1"
androidTestImplementation "android.arch.core:core-testing:1.1.1"
implementation 'android.arch.lifecycle:reactivestreams:1.1.1'
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$rootProject.kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$rootProject.kotlin_version"
// Data binding
kapt 'com.android.databinding:compiler:3.1.4'
// Crash reporting
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1#aar') {
transitive = true
}
// Injection
implementation "com.google.dagger:dagger:$rootProject.daggerVersion"
implementation "com.google.dagger:dagger-android:$rootProject.daggerVersion"
implementation "com.google.dagger:dagger-android-support:$rootProject.daggerVersion"
kapt "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
kapt "com.google.dagger:dagger-android-processor:$rootProject.daggerVersion"
kapt "com.google.dagger:dagger-android-support:$rootProject.daggerVersion"
// Data
implementation "com.google.code.gson:gson:$rootProject.libGsonVersion"
implementation "com.squareup.retrofit2:converter-gson:$rootProject.gsonConverterVersion"
implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
implementation "com.squareup.okhttp3:okhttp:$rootProject.libOkHttp3Version"
implementation "com.squareup.picasso:picasso:$rootProject.libPicassoVersion"
implementation('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax-api'
exclude module: 'stax'
exclude module: 'xpp3'
}
// Reactive library version 1
implementation "io.reactivex:rxjava:$rootProject.libRxJavaVersion"
implementation "io.reactivex:rxandroid:$rootProject.libRxAndroidVersion"
// Reactive library version 2
implementation 'io.reactivex.rxjava2:rxjava:2.1.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation "io.reactivex.rxjava2:rxkotlin:2.0.0"
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
// Memory leak testing
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
// Unit tests
testImplementation 'junit:junit:4.12'
testImplementation "org.robolectric:robolectric:$rootProject.libRobolectricVersion"
// Instrumentation tests
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support.test.espresso:espresso-idling-resource:3.0.2'
androidTestImplementation 'com.android.support.test.espresso.idling:idling-concurrent:3.0.2'
// Mocking
testImplementation 'org.mockito:mockito-core:2.9.0'
// Logging
implementation 'com.jakewharton.timber:timber:4.6.0'
// Time and Date
implementation 'joda-time:joda-time:2.9.9'
implementation files('libs/commons-lang-2.6.jar')
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "500" // or whatever number you want
}
}
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
This is the code of sub build.gradle.
This is the error message I am getting.
Where:
Build file 'D:\xxx\cleanaway-myview-app\driversapp\build.gradle' line: 39
What went wrong:
A problem occurred evaluating project ':driversapp'.
Parameter specified as non-null is null: method com.android.build.gradle.internal.dsl.BaseAppModuleExtension.compileSdkVersion, parameter version
The following fields don't make sense:
compileSdkVersion compileSdk
minSdkVersion minSdk
targetSdkVersion targetSdk
I think someone misunderstood the instruction that compileSdkVersion can be replaced with compileSdk. Because you need to put actual numbers there, for example
compileSdkVersion 31
minSdkVersion 28
targetSdkVersion 31
which would be the old way. The new way
compileSdk 31
minSdk 28
targetSdk 31
not sure if the old way still works. In any case you need to put actual numbers there. Which ones you want for your project is up to you. compileSdk and targetSdk it's usually best to use the highest possible and minSdk the minimum android version you want to support.
See also What is difference between compileSdk and compileSdkVersion in android studio gradle script when using jetpack compose
My project has two modules i.e. app and moduleX.
app project is mostly built on Java and moduleX is completly in Kotlin.
While creating "debug" build, it's running fine but when I try to create release build i.e. devRelease, it give following error-
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDevRelease'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.compat.R$attr
Here is the app level build.gradle-
apply plugin: 'com.android.application'
apply plugin: 'com.facebook.testing.screenshot'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.appname"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner rootProject.ext.testInstrumentationRunner
}
flavorDimensions "environment"
productFlavors {
dev {
dimension "environment"
versionNameSuffix "-dev"
applicationIdSuffix ".dev"
}
qa {
dimension "environment"
versionNameSuffix "-test"
applicationIdSuffix ".test"
}
staging {
dimension "environment"
versionNameSuffix "-staging"
applicationIdSuffix ".staging"
}
prod {
dimension "environment"
}
}
signingConfigs {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
release {
storeFile file("keystore/appname_keystore.jks")
storePassword properties.getProperty('storePassword')
keyAlias properties.getProperty('keyAlias')
keyPassword properties.getProperty('keyPassword')
}
}
buildTypes {
debug {
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bundle {
language {
enableSplit = false
}
}
configurations.all {
resolutionStrategy {
// force certain versions of dependencies (including transitive)
force 'com.squareup.okhttp3:okhttp:' + okHttpLibVersion
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//Unit testing
testImplementation rootProject.ext.junit
androidTestImplementation rootProject.ext.androidTestRunner
androidTestImplementation rootProject.ext.espresso
testImplementation rootProject.ext.mockito
testImplementation rootProject.ext.facebookScreenshotTestCommon
implementation rootProject.ext.facebookScreenshotTestLitho
androidTestImplementation rootProject.ext.supportTestRules
//Support Library & UI
implementation rootProject.ext.constraintLayout
implementation rootProject.ext.supportCompatV7
implementation rootProject.ext.supportDesign
implementation rootProject.ext.supportCardView
implementation rootProject.ext.supportCustomTabs
implementation rootProject.ext.glide
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// Dagger dependency for DI
implementation 'com.google.dagger:dagger:2.16'
annotationProcessor "com.google.dagger:dagger-compiler:2.16"
compileOnly 'javax.annotation:jsr250-api:1.0'
implementation 'javax.inject:javax.inject:1'
// RxJava lib
implementation rootProject.ext.rxAndroid
implementation rootProject.ext.rxJava
implementation rootProject.ext.rxJavaRetrofitAdapter
//Retrofit
implementation(rootProject.ext.retrofit) {
exclude module: 'okhttp'
}
implementation rootProject.ext.okHttp
implementation rootProject.ext.okHttpLoggingInterceptor
implementation rootProject.ext.retrofitGsonConverter
implementation rootProject.ext.retrofitScalarsConverter
//Memory leaks
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
//Others
implementation rootProject.ext.parceler
annotationProcessor rootProject.ext.parcelerAnnotationProcessor
implementation rootProject.ext.lombok
annotationProcessor rootProject.ext.lombokAnnotationProcessor
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
// Fingerprint Auth
implementation 'com.multidots:fingerprint-auth:1.0.1'
//Module Projects
api project(':energyswitchcui')
}
screenshots {
multipleDevices true
}
and here is the build.gradle file of moduleX-
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
// need separate runner for facebook screenshot test in module
testInstrumentationRunner 'com.appname.SnapshotTestRunner'
}
flavorDimensions "environment"
productFlavors {
dev {
dimension "environment"
}
qa {
dimension "environment"
}
staging {
dimension "environment"
}
prod {
dimension "environment"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
androidTest.java.srcDirs += 'src/androidTest/kotlin'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Unit testing
testImplementation rootProject.ext.junit
androidTestImplementation rootProject.ext.androidTestRunner
androidTestImplementation rootProject.ext.espresso
testImplementation rootProject.ext.mockito
testImplementation rootProject.ext.facebookScreenshotTestCommon
implementation rootProject.ext.facebookScreenshotTestLitho
androidTestImplementation rootProject.ext.supportTestRules
//Support Library & UI
implementation rootProject.ext.constraintLayout
implementation rootProject.ext.supportCompatV7
implementation rootProject.ext.supportDesign
implementation rootProject.ext.supportCardView
implementation rootProject.ext.supportCustomTabs
implementation rootProject.ext.glide
implementation 'com.intuit.sdp:sdp-android:1.0.6'
// RxJava lib
implementation rootProject.ext.rxAndroid
implementation rootProject.ext.rxJava
implementation rootProject.ext.rxJavaRetrofitAdapter
//Retrofit
implementation(rootProject.ext.retrofit) {
exclude module: 'okhttp'
}
implementation rootProject.ext.okHttp
implementation rootProject.ext.okHttpLoggingInterceptor
implementation rootProject.ext.retrofitGsonConverter
implementation rootProject.ext.retrofitScalarsConverter
//Others
implementation rootProject.ext.parceler
kapt rootProject.ext.parcelerAnnotationProcessor
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
}
repositories {
mavenCentral()
}
// need for facebook screenshot test in module
apply plugin: 'com.facebook.testing.screenshot'
screenshots {
multipleDevices true
}
This is the project level build.gradle file-
apply from: 'dependencies.gradle'
buildscript {
ext.kotlinVersion = '1.3.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.facebook.testing.screenshot:plugin:0.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is dependencies.gradle-
ext {
//Android
minSdkVersion = 24
targetSdkVersion = 28
compileSdkVersion = targetSdkVersion
testInstrumentationRunner = "com.appname.runner.SnapshotTestRunner"
androidSupportLibVersion = "28.0.0"
okHttpLibVersion = "3.14.0"
//Unit testing
junit = "junit:junit:4.12"
androidTestRunner = "com.android.support.test:runner:1.0.2"
espresso = "com.android.support.test.espresso:espresso-core:3.0.2"
mockito = "org.mockito:mockito-all:1.10.19"
facebookScreenshotTestCommon = "com.facebook.testing.screenshot:layout-hierarchy-common:0.8.0"
facebookScreenshotTestLitho = "com.facebook.testing.screenshot:layout-hierarchy-litho:0.8.0"
supportTestRules = "com.android.support.test:rules:1.0.2"
//Support Library & UI
constraintLayout = "com.android.support.constraint:constraint-layout:1.1.3"
supportCompatV7 = "com.android.support:appcompat-v7:$androidSupportLibVersion"
supportDesign = "com.android.support:design:$androidSupportLibVersion"
supportCardView = "com.android.support:cardview-v7:$androidSupportLibVersion"
supportCustomTabs = "com.android.support:customtabs:$androidSupportLibVersion"
glide = "com.github.bumptech.glide:glide:3.7.0"
// RxJava lib
rxAndroid = "io.reactivex.rxjava2:rxandroid:2.0.1"
rxJava = "io.reactivex.rxjava2:rxjava:2.1.8"
rxJavaRetrofitAdapter = "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0"
//Retrofit
retrofit = "com.squareup.retrofit2:retrofit:2.4.0"
okHttp = "com.squareup.okhttp3:okhttp:$okHttpLibVersion"
okHttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor:$okHttpLibVersion"
retrofitGsonConverter = "com.squareup.retrofit2:converter-gson:2.3.0"
retrofitScalarsConverter = "com.squareup.retrofit2:converter-scalars:2.3.0"
//Others
parceler = "org.parceler:parceler-api:1.1.6"
parcelerAnnotationProcessor = "org.parceler:parceler:1.1.6"
lombok = "org.projectlombok:lombok:1.16.16"
lombokAnnotationProcessor = "org.projectlombok:lombok:1.16.16"
}
I have already tried many answers i.e.
Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior
but nothing is working here.
Hi i have come up with the solution and run successful below gradles with just little version changes:
Main Project Level Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.facebook.testing.screenshot:plugin:0.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
//Android
minSdkVersion = 24
targetSdkVersion = 28
compileSdkVersion = targetSdkVersion
testInstrumentationRunner = "com.appname.runner.SnapshotTestRunner"
androidSupportLibVersion = "28.0.0"
androidCompatVersion = "1.0.0-beta01"
androidCardViewVersion = "1.0.0"
constraintlayoutVersion = "1.1.3"
okHttpLibVersion = "3.14.0"
//Unit testing
junit = "junit:junit:4.12"
androidTestRunner = "androidx.test:runner:1.1.0-alpha4"
espresso = "androidx.test.espresso:espresso-core:3.1.0-alpha4"
supportTestRules = "com.android.support.test:rules:1.0.2"
//Support Library & UI
constraintLayout = "androidx.constraintlayout:constraintlayout:$constraintlayoutVersion"
supportCompatV7 = "androidx.appcompat:appcompat:$androidCompatVersion"
supportDesign = "com.android.support:design:$androidSupportLibVersion"
supportCardView = "androidx.cardview:cardview:$androidCardViewVersion"
supportCustomTabs = "com.android.support:customtabs:$androidSupportLibVersion"
glide = "com.github.bumptech.glide:glide:3.7.0"
mockito = "org.mockito:mockito-all:1.10.19"
facebookScreenshotTestCommon = "com.facebook.testing.screenshot:layout-hierarchy-common:0.8.0"
facebookScreenshotTestLitho = "com.facebook.testing.screenshot:layout-hierarchy-litho:0.8.0"
// RxJava lib
rxAndroid = "io.reactivex.rxjava2:rxandroid:2.0.1"
rxJava = "io.reactivex.rxjava2:rxjava:2.1.8"
rxJavaRetrofitAdapter = "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0"
//Retrofit
retrofit = "com.squareup.retrofit2:retrofit:2.4.0"
okHttp = "com.squareup.okhttp3:okhttp:$okHttpLibVersion"
okHttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor:$okHttpLibVersion"
retrofitGsonConverter = "com.squareup.retrofit2:converter-gson:2.3.0"
retrofitScalarsConverter = "com.squareup.retrofit2:converter-scalars:2.3.0"
//Others
parceler = "org.parceler:parceler-api:1.1.9"
parcelerAnnotationProcessor = "org.parceler:parceler:1.1.9"
lombok = "org.projectlombok:lombok:1.16.16"
lombokAnnotationProcessor = "org.projectlombok:lombok:1.16.16"
}
App Level gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.gradletest"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation rootProject.ext.junit
androidTestImplementation rootProject.ext.androidTestRunner
androidTestImplementation rootProject.ext.espresso
androidTestImplementation rootProject.ext.supportTestRules
testImplementation rootProject.ext.mockito
testImplementation rootProject.ext.facebookScreenshotTestCommon
implementation rootProject.ext.facebookScreenshotTestLitho
implementation rootProject.ext.constraintLayout
implementation rootProject.ext.supportCompatV7
implementation rootProject.ext.supportDesign
implementation rootProject.ext.supportCardView
implementation rootProject.ext.supportCustomTabs
implementation rootProject.ext.glide
// RxJava lib
implementation rootProject.ext.rxAndroid
implementation rootProject.ext.rxJava
implementation rootProject.ext.rxJavaRetrofitAdapter
//Retrofit
implementation(rootProject.ext.retrofit) {
exclude module: 'okhttp'
}
implementation rootProject.ext.okHttp
implementation rootProject.ext.okHttpLoggingInterceptor
implementation rootProject.ext.retrofitGsonConverter
implementation rootProject.ext.retrofitScalarsConverter
implementation rootProject.ext.parceler
// annotationProcessor rootProject.ext.parcelerAnnotationProcessor
implementation rootProject.ext.lombok
annotationProcessor rootProject.ext.lombokAnnotationProcessor
//Memory leaks
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.multidots:fingerprint-auth:1.0.1'
implementation project(':energyswitchcui')
}
Module("energyswitchcui") gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Unit testing
testImplementation rootProject.ext.junit
androidTestImplementation rootProject.ext.androidTestRunner
androidTestImplementation rootProject.ext.espresso
testImplementation rootProject.ext.mockito
testImplementation rootProject.ext.facebookScreenshotTestCommon
implementation rootProject.ext.facebookScreenshotTestLitho
androidTestImplementation rootProject.ext.supportTestRules
//Support Library & UI
implementation rootProject.ext.constraintLayout
implementation rootProject.ext.supportCompatV7
implementation rootProject.ext.supportDesign
implementation rootProject.ext.supportCardView
implementation rootProject.ext.supportCustomTabs
implementation rootProject.ext.glide
implementation 'com.intuit.sdp:sdp-android:1.0.6'
// RxJava lib
implementation rootProject.ext.rxAndroid
implementation rootProject.ext.rxJava
implementation rootProject.ext.rxJavaRetrofitAdapter
//Retrofit
implementation(rootProject.ext.retrofit) {
exclude module: 'okhttp'
}
implementation rootProject.ext.okHttp
implementation rootProject.ext.okHttpLoggingInterceptor
implementation rootProject.ext.retrofitGsonConverter
implementation rootProject.ext.retrofitScalarsConverter
//Others
implementation rootProject.ext.parceler
// kapt rootProject.ext.parcelerAnnotationProcessor
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
// need for facebook screenshot test in module
apply plugin: 'com.facebook.testing.screenshot'
screenshots {
multipleDevices true
}
Below are the errors that were encountered during gradle and what i have done to solve it:
1) Error: Invoke-customs are only supported starting with Android O (--min-api 26)
Solution: put below lines under android section of app level gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
2) Error: The given artifact contains a string literal with a package reference 'android.support.v4.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.
Solution: Removed "annotationProcessor rootProject.ext.parcelerAnnotationProcessor" from app level gradle and updated this library in main level gradle under "ext" section from 1.1.6 to 1.1.9 'parcelerAnnotationProcessor = "org.parceler:parceler:1.1.9"'
but it does not worked
So i removed that library and successfully build gradle and also can run the project. Here is the dropbox link you can find project on :https://www.dropbox.com/s/ki8gpfdaxh0dzo3/GradleTest.zip?dl=0
3) Above solution will work only in debug mode but in release build we have to also remove this two libraries to build successfully in release build:
facebookScreenshotTestCommon = "com.facebook.testing.screenshot:layout-hierarchy-common:0.9.0"
facebookScreenshotTestLitho = "com.facebook.testing.screenshot:layout-hierarchy-litho:0.9.0"
Following the docs at https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests, I have created the following build.gradle file for my app module:
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.25.3'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.myapp"
minSdkVersion 19
targetSdkVersion 19
versionCode 7
versionName "1.3.0"
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
// Required -- JUnit 4 framework
testImplementation 'junit:junit:4.12'
// Optional -- Mockito framework
testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'com.android.support:support-annotations:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-accessibility:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-web:3.0.2'
androidTestImplementation 'com.android.support.test.espresso.idling:idling-concurrent:3.0.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':deviceprint-lib-2.0.1')
implementation files('libs/gson-2.2.4.jar')
implementation files('libs/activation.jar')
implementation files('libs/additionnal.jar')
implementation files('libs/mail.jar')
implementation 'com.android.support:support-v4:27.1.1'
}
and the following project level build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
I created a directory at app/src/androidTest/java/com/mypackage and added the following file:
package com.mypackage;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public class ApplicationTest
{
public ApplicationTest()
{
}
#Test public void failingTest()
{
assertThat(false, is(true));
}
}
All of the import statements, and the #Test annotation are marked as errors, with the message, "cannot resolve symbol" and If I right click on the file in the project window, I do not have the option to "Run". Why?
The example started to work correctly after I restarted Android Studio. :facepalm:
Edit:
another note, as I recently experienced these same symptoms for a different reason: the build variant must be set to "debug" (or you must set testBuildType inside the android {} block of your module's build.gradle file to the variant you want to test)
After the update of supportVersion to 27.0.0 ONLY on Android 5.0.2 the app crash with this stacktrace:
W/WindowManager: Failed looking up window
java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W#f004691 does not exist
at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8426)
at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8417)
at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2558)
at com.android.server.wm.Session.remove(Session.java:186)
at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2920)
at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5390)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3223)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
Both on the device and on the emulator.
If I put 26.0.2 as supportVersion, the app still works normally as usual.
UPDATE
The problem persist with supportVersion 27.0.1
UPDATE 2
Project gradle
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'io.fabric.tools:gradle:1.24.2'
}
}
plugins {
id "com.diffplug.gradle.spotless" version "3.6.0"
}
allprojects {
repositories {
google()
jcenter()
jcenter { url = 'http://dl.bintray.com/swrve-inc/android' }
maven { url 'https://maven.fabric.io/public' }
maven { url 'http://maven.localytics.com/public' }
maven { url 'http://dl.bintray.com/teads/TeadsSDK-android' }
maven { url 'http://maven.apptimize.com/artifactory/repo' }
maven { url 'https://comscore.bintray.com/Analytics' }
}
}
ext {
//APPLICATION
compileSdkVersion = 27
buildToolsVersion = '27.0.1'
minSdkVersion = 19
targetSdkVersion = 27
//LIBRARIES
timberVersion = '4.6.0'
guavaVersion = '20.0'
multidexVersion = '1.0.2'
supportVersion = '27.0.1'
constraintVersion = '1.0.2'
playServiceVersion = '11.4.0'
commonLangVersion = '3.5'
jacksonVersion = '2.4.2'
appsFlyerVersion = '4.7.1'
facebookAudienceVersion = '4.26.1'
facebookSkdVersion = '4.26.0'
facebookAdapterVersion = '4.26.1.0'
flurryVersion = '6.9.2'
googleTrackingVersion = '2.2.4'
crashliticsVersion = '2.6.8'
swrveVersion = '4.10.1'
swrveLocationVersion = '1.3'
pubnativeVersion = '2.0.5'
localyticsVersion = '4.3.1'
teadsVersion = '2.4.13'
oguryPresageVersion = '2.1.21'
evernoteAndroidJobVersion = '1.1.11'
apptimizeVersion = '2.13.5'
comScoreVersion = '5.5.1'
bottomBarVersion = '2.3.1'
rxJavaVersion = '2.1.6'
rxAndroidVersion = '2.0.1'
//TEST LIBRARIES
testsVersion = '1.0.1'
espressoVersion = '3.0.1'
junitVersion = '4.12'
mockitoVersion = '1.10.19'
powermockVersion = '1.6.6'
robolectricVersion = '3.5'
assertjVersion = '1.2.0'
//PUBNATIVE ADAPTERS
pnFlurryVersion = '6.9.2'
pnAdmobVersion = '9.6.1'
}
App gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
kotlin {
target "**/*.kt"
ktlint()
}
}
def versionMajor = 8
def versionMinor = 8
def versionPatch = 8
def versionBuild = 8
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
flavorDimensions "std"
defaultConfig {
dimension "std"
applicationId "xxx.yyy.zzz"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode versionMajor * 1000 + versionMinor * 100 + versionPatch * 10 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
//APP VERSION NAME
buildConfigField "String", "VERSION_NAME_PREFIX", "\"zzzz\""
//MARKET CONFIG
buildConfigField "String", "MARKET_NAME", "\"GooglePlay\""
buildConfigField "String", "MARKET_ENDPOINT", "\"market://details?id=\""
buildConfigField "String", "MARKET_BACKOFF_ENDPOINT", "\"https://play.google.com/store/apps/details?id=\""
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
....
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
buildTypes {
debug {
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
}
release {
minifyEnabled true
proguardFiles 'acb.txt'
zipAlignEnabled true
}
}
lintOptions {
disable 'MissingTranslation'
checkReleaseBuilds true
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
fatal 'StopShip'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
//CORE LIB
implementation "com.jakewharton.timber:timber:${rootProject.ext.timberVersion}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
implementation "com.google.guava:guava:${rootProject.ext.guavaVersion}"
implementation "com.android.support:multidex:${rootProject.ext.multidexVersion}"
implementation "com.android.support:multidex-instrumentation:${rootProject.ext.multidexVersion}"
implementation "com.android.support:design:${rootProject.ext.supportVersion}"
implementation "com.android.support:cardview-v7:${rootProject.ext.supportVersion}"
implementation "com.android.support.constraint:constraint-layout:${rootProject.ext.constraintVersion}"
implementation "com.google.android.gms:play-services-identity:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-base:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-analytics:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-gcm:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-location:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-maps:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-ads:${rootProject.ext.playServiceVersion}"
implementation "org.apache.commons:commons-lang3:${rootProject.ext.commonLangVersion}"
implementation "com.fasterxml.jackson.core:jackson-databind:${rootProject.ext.jacksonVersion}"
implementation "com.fasterxml.jackson.core:jackson-core:${rootProject.ext.jacksonVersion}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${rootProject.ext.jacksonVersion}"
implementation "io.reactivex.rxjava2:rxjava:${rootProject.ext.rxJavaVersion}"
implementation "io.reactivex.rxjava2:rxandroid:${rootProject.ext.rxAndroidVersion}"
//SDK
implementation "com.appsflyer:af-android-sdk:${rootProject.ext.appsFlyerVersion}#aar"
implementation "com.facebook.android:facebook-android-sdk:${rootProject.ext.facebookSkdVersion}"
implementation "com.facebook.android:audience-network-sdk:${rootProject.ext.facebookAudienceVersion}"
implementation "com.flurry.android:analytics:${rootProject.ext.flurryVersion}"
implementation "com.flurry.android:ads:${rootProject.ext.flurryVersion}"
implementation files("libs/GoogleConversionTrackingSdk-${rootProject.ext.googleTrackingVersion}.jar")
implementation("com.crashlytics.sdk.android:crashlytics:${rootProject.ext.crashliticsVersion}#aar") {
transitive = true
}
//TEADS VIDEO
implementation("tv.teads.sdk:androidsdk:${rootProject.ext.teadsVersion}:fullRelease#aar") {
transitive = true
}
//OGURY - PRESAGE
implementation files("libs/presage-lib-${rootProject.ext.oguryPresageVersion}-obfuscated.jar")
//PUBNATIVE
implementation "net.pubnative:sdk:${rootProject.ext.pubnativeVersion}"
//PUBNATIVE - ADAPTERS
implementation "net.pubnative:sdk.adapter.admob:${rootProject.ext.pnAdmobVersion}"
implementation "net.pubnative:sdk.adapter.flurry:${rootProject.ext.pnFlurryVersion}"
//ADMOB - ADAPTERS
implementation "com.google.ads.mediation:facebook:${rootProject.ext.facebookAdapterVersion}"
//SWRVE PLOT
implementation "com.swrve.sdk.android:swrve-google:${rootProject.ext.swrveVersion}"
implementation(name: "swrve-location-${rootProject.ext.swrveLocationVersion}", ext: "aar")
//LOCALYTICS
implementation "com.localytics.android:library:${rootProject.ext.localyticsVersion}"
//JOB
implementation "com.evernote:android-job:${rootProject.ext.evernoteAndroidJobVersion}"
//APPTIMIZE
implementation "com.apptimize:apptimize-android:${rootProject.ext.apptimizeVersion}"
//COMSCORE
implementation "com.comscore:android-analytics:${rootProject.ext.comScoreVersion}"
//BOTTOM BAR
implementation "com.roughike:bottom-bar:${rootProject.ext.bottomBarVersion}"
//TEST
androidTestImplementation "com.android.support:support-annotations:${rootProject.ext.supportVersion}"
androidTestImplementation "com.android.support.test:runner:${rootProject.ext.testsVersion}"
androidTestImplementation "com.android.support.test:rules:${rootProject.ext.testsVersion}"
androidTestImplementation "com.android.support.test.espresso:espresso-core:${rootProject.ext.espressoVersion}"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:${rootProject.ext.espressoVersion}"
androidTestImplementation("com.android.support.test.espresso:espresso-contrib:${rootProject.ext.espressoVersion}") {
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude module: 'recyclerview-v7'
}
testImplementation "junit:junit:${rootProject.ext.junitVersion}"
testImplementation "org.mockito:mockito-core:${rootProject.ext.mockitoVersion}"
testImplementation "org.powermock:powermock-api-mockito:${rootProject.ext.powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4:${rootProject.ext.powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4-rule:${rootProject.ext.powermockVersion}"
testImplementation "org.powermock:powermock-classloading-xstream:${rootProject.ext.powermockVersion}"
testImplementation "org.robolectric:robolectric:${rootProject.ext.robolectricVersion}"
testImplementation "org.robolectric:shadows-multidex:${rootProject.ext.robolectricVersion}"
testImplementation "org.robolectric:shadows-httpclient:${rootProject.ext.robolectricVersion}"
testImplementation "com.android.support:support-annotations:${rootProject.ext.supportVersion}"
testImplementation "com.squareup.assertj:assertj-android:${rootProject.ext.assertjVersion}"
}
apply plugin: 'com.google.gms.google-services'
In my case it was due to the AppCompatActivity extend for the start activity, When it changed to Activity it is working fine!
You can try adding: maven { url "https://maven.google.com" }
Also set your support version to 27+
This has helped me in previous instance. Not tried it with 27.0.0 or 27.0.1
I know this is not the preferred approach but it can be used as a temporary fix. Wether you want to use it or ignore it, I leave it to you. But let me know if it works.
I've googled and searched in here the solution for this but haven't found it. I just updated my Android Studio to 3.0 and I'm trying to port my app to use feature modules in order to be able to make an Instant App, but when I try to run the app from Android Studio, I get the following error:
Error:Execution failed for task
':app:transformClassesWithStackFramesFixerForDebug'.
> com.android.build.api.transform.TransformException:
java.lang.RuntimeException: java.lang.RuntimeException:
java.util.concurrent.ExecutionException:
java.util.concurrent.ExecutionException:
com.android.builder.utils.FileCache$FileCreatorException:
java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF
I tried to exclude such file using packagingOptions, but apparently is not working. Here are my build.gradle files:
Project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
compileSdkVersion = 26
supportLib = '26.1.0'
}
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
App module 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' }
maven { url "https://jitpack.io" }
maven { url "https://s3.amazonaws.com/avocarrot-android-builds/dist" }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
maven { url "https://maven.google.com" }
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.myapp.mobile"
minSdkVersion 16
targetSdkVersion 26
versionCode 23004003
versionName "4.0.0.3"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
dexOptions {
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/MANIFEST.MF'
}
}
dependencies {
def mopub = '4.16.0#aar'
def avocarrot = '4.6.0'
def exoplayer = 'r2.2.0'
def mobfox = '3.2.3'
def pubnative = '2.0.4'
def facebook = '4.+'
def pubnativeFacebookAdapter = '2.0.2-4.22.1'
def taboola = '1.3.1'
def okhttp = '3.8.1'
def okio = '1.13.0'
def picasso = '2.5.2'
def firebase = '11.4.0'
def playServices = '11.4.0'
def supportLib = '26.1.0'
def gson = '2.8.1'
def circleimageview = '2.1.0'
def floatingactionbutton = '1.3.0'
def mpAndroidChart = 'v3.0.2'
def gridViewHeaderFooter = '1.0.12'
def multidex = '1.0.1'
def floatingsearchview = '2.0.3'
def cropper = '1.0.1#aar'
def adapterdelegates = '3.0.1'
def rxjava = '2.x.y'
def rxandroid = '2.0.1'
def rxjavaAdapter = '2.3.0'
def retrofit = '2.3.0'
def rxbinding = '2.0.0'
def diagonallayout = '1.0.6'
def fabSpeedDial = '1.0.6'
def butterknife = '8.7.0'
def sqlbrite = '2.0.0'
def leakcanary = '1.5.1'
def debugDB = '1.0.1'
def crashlytics = '2.6.8#aar'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/admarvel-android-sdk-core-adcolony.jar')
implementation files('libs/libAdapterSDKMoPub.jar')
implementation files('libs/AdMobMediationAdapter.jar')
implementation files('libs/lsmsdkadmobmediationadapter.jar')
implementation files('libs/MobFox-Android-AdMob-Adapter.jar')
implementation files('libs/gcm.jar')
implementation files('libs/achartengine-1.1.0.jar')
implementation files('libs/comscore.jar')
implementation files('libs/hmediaLib-1.3.0.jar')
implementation(name:'adux-1.0.0', ext:'aar')
implementation "com.avocarrot.sdk:mediation-sdk-nativead:$avocarrot"
implementation "com.google.android.exoplayer:exoplayer:$exoplayer"
implementation "com.facebook.android:audience-network-sdk:$facebook"
implementation "com.facebook.android:facebook-android-sdk:$facebook"
implementation "com.google.ads.mediation:facebook:$facebook"
implementation "com.github.mobfox:MobFox-Android-SDK-Core:$mobfox"
implementation "net.pubnative:sdk:$pubnative"
implementation "net.pubnative:sdk.adapter.facebook:$pubnativeFacebookAdapter"
implementation "com.squareup.okhttp3:okhttp:$okhttp"
implementation "com.squareup.okio:okio:$okio"
implementation "com.squareup.picasso:picasso:$picasso"
implementation "com.android.support:cardview-v7:$rootProject.supportLib"
implementation "com.android.support:support-v4:$rootProject.supportLib"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLib"
implementation "com.android.support:design:$rootProject.supportLib"
implementation "com.android.support:customtabs:$rootProject.supportLib"
implementation "com.google.android.gms:play-services-analytics:$playServices"
implementation "com.google.android.gms:play-services-ads:$playServices"
implementation "com.google.android.gms:play-services-wearable:$playServices"
implementation "com.google.code.gson:gson:$gson"
implementation "de.hdodenhof:circleimageview:$circleimageview"
implementation "com.melnykov:floatingactionbutton:$floatingactionbutton"
implementation "com.github.PhilJay:MPAndroidChart:$mpAndroidChart"
implementation "in.srain.cube:grid-view-with-header-footer:$gridViewHeaderFooter"
implementation "com.android.support:multidex:$multidex"
implementation "com.github.arimorty:floatingsearchview:$floatingsearchview"
implementation "com.soundcloud.android:android-crop:$cropper"
implementation "com.hannesdorfmann:adapterdelegates3:$adapterdelegates"
implementation "io.reactivex.rxjava2:rxjava:$rxjava"
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid"
implementation "com.squareup.retrofit2:adapter-rxjava2:$rxjavaAdapter"
implementation "com.squareup.retrofit2:retrofit:$retrofit"
implementation "com.squareup.retrofit2:converter-gson:$retrofit"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp"
implementation "com.jakewharton.rxbinding2:rxbinding:$rxbinding"
implementation "com.jakewharton.rxbinding2:rxbinding-support-v4:$rxbinding"
implementation "com.github.florent37:diagonallayout:$diagonallayout"
implementation "io.github.yavski:fab-speed-dial:$fabSpeedDial"
implementation "com.google.firebase:firebase-messaging:$firebase"
implementation "com.jakewharton:butterknife:$butterknife"
implementation "com.squareup.sqlbrite2:sqlbrite:$sqlbrite"
annotationProcessor "com.jakewharton:butterknife-compiler:$butterknife"
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary"
testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary"
debugImplementation "com.amitshekhar.android:debug-db:$debugDB"
implementation("com.crashlytics.sdk.android:crashlytics:$crashlytics")
{
transitive = true
}
implementation(name: 'DebugSettings', ext: 'aar')
wearApp project(':wear')
implementation project(':myapp-base')
}
apply plugin: 'com.google.gms.google-services'
Base module build.gradle
apply plugin: 'com.android.feature'
repositories {
maven { url "https://maven.google.com" }
}
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion '26.0.2'
baseFeature true
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api "com.android.support:appcompat-v7:$rootProject.supportLib"
implementation fileTree(dir: 'libs', include: ['*.jar'])
// 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'
application project(':app')
}
You're including the libs directory twice in your app's build.gradle
// Once
implementation fileTree(include: ['*.jar'], dir: 'libs')
// And once more, but more verbose
implementation files('libs/admarvel-android-sdk-core-adcolony.jar')
implementation files('libs/libAdapterSDKMoPub.jar')
implementation files('libs/AdMobMediationAdapter.jar')
implementation files('libs/lsmsdkadmobmediationadapter.jar')
implementation files('libs/MobFox-Android-AdMob-Adapter.jar')
implementation files('libs/gcm.jar')
implementation files('libs/achartengine-1.1.0.jar')
implementation files('libs/comscore.jar')
implementation files('libs/hmediaLib-1.3.0.jar')
This could be where your issue originates. Decide on one way to include these and let me know whether that works.