I have upgraded my android studio .. and I found many problems in the latest version
Although many similar questions exist, I checked the answers to all and none of them worked for me!
Here is the error I'm facing while compiling the code:
Program type already present: android.support.v4.app.BackStackState$1
Message{kind=ERROR, text=Program type already present: android.support.v4.app.BackStackState$1, sources=[Unknown source file], tool name=Optional.of(D8)}
gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
app gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.guideapp.trickapp"
minSdkVersion 14
targetSdkVersion 23
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
externalNativeBuild {
ndkBuild {
path '../../../Application.mk'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
}
Don't use the following:
compile 'com.google.android.gms:play-services:+'
because you must use an exact version of play service. And use only the specific Google Play services APIs your app uses. For example, if you're using location, you only need the following dependency:
implementation 'com.google.android.gms:play-services-location:15.0.1'
read more at Set Up Google Play Services
then change your support library to the same version of your buildToolsVersion
. So, you need to change the following:
implementation files('libs/support-v4-19.0.1.jar')
to
implementation 'com.android.support:support-v4:27.1.1'
Remove the support-v4-19.0.1.jar
file from your libs directory.
Last, use the same version for the following:
compileSdkVersion
buildToolsVersion
targetSdkVersion
My suggestion, use version 27. So, your app build.gradle
will be something like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.guideapp.trickapp"
minSdkVersion 14
targetSdkVersion 27
ndk {
moduleName "player_shared"
}
}
...
}
dependencies {
implementation 'com.google.android.gms:play-services-location:15.0.1'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
implementation 'com.android.support:support-v4:27.1.1'
}
Just add implementation 'com.android.support:support-v4:28.0.0'
. Don't forget to change for version you using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With