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.BackStackRecord$Op
Message{kind=ERROR, text=Program type already present: android.support.v4.app.BackStackRecord$Op, sources=[Unknown source file], tool name=Optional.of(D8)}
Here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.narsun.grocery"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.github.sd6352051.niftydialogeffects:niftydialogeffects:1.0.0#aar'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup:android-times-square:1.6.5#aar'
implementation 'com.daimajia.slider:library:1.1.5#aar'
implementation 'com.astuetz:pagerslidingtabstrip:1.0.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.github.myinnos:AwesomeImagePicker:1.0.2'
implementation 'com.github.ratty3697:android-smart-animation-library:1.6'
implementation 'com.github.zcweng:switch-button:0.0.3#aar'
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
implementation 'com.google.android.exoplayer:exoplayer:2.6.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.10'
implementation 'com.android.support:multidex:1.0.3'
testImplementation 'junit:junit:4.12'
}
You can tell me if there is anything else to add to understand what I'm doing or where I'm wrong.
In case anyone comes here with a similar issue. In my case it was because I had included an appcompat JAR file in the libs folder as well as having implementation 'com.android.support:appcompat-v7:26.0.0' in my gradle file.
When I removed the JAR file, that fixed my issue.
Probably the packages versions are not compatible. Try downgrading com.android.support packages, namely appcompat
so - implementation 'com.android.support:appcompat-v7:27.0.1'
I want to share how you can understand the error message.
First method, check your dependencies in build.gradle:
In this case, if I tried to remove that implementation, the error gone.
Second method, Check libs folder of your app which included .jar files:
In this case, if I tried to move that .jar to somewhere else, the error gone.
For the info for other who will face the same error, I was able to solve my problem by removing the following library from my gradle file:
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
This was the library creating issues for me. Thanks
I'm including a custom aar in my app/libs folder, and I correctly added the flatLib object to the root build.gradle, but incorrectly added the '*.aar' to the fileTree implementation in the app/build.gradle:
build.gradle
allprojects {
repositories {
...
flatDir {
dirs 'libs'
}
}
}
app/build.gradle
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'])
^^^
BAD
Related
I received a jar files for one of the application SDKs. I need to extend this SDK to include my features. One of the jar file include android and androidx packages.
The steps I followed to integrate the sdk jar files to my base brand new application, I added jar files under libs directory of app. Then right click the jar file and clicked "add as library".
I went to basicActivity and tried to import of the files from the SDK jar file, it was not detected. So, I added dependency in the libs folder, then build the application (Build -> Rebuild Project). Then so many of the duplicate class error came like the below,
Duplicate class android.support.v4.app.RemoteActionCompatParcelizer found in modules core-1.7.0-runtime (androidx.core:core:1.7.0) and jetified-main (main.jar)
with advices from other threads, I added exclude group
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.bo.ri"
minSdk 21
targetSdk 32
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
}
configurations {
all { // You should exclude one of them not both of them
exclude group: "androidx.annotation", module: "annotation"
exclude group: "androidx.fragment", module: "fragment"
exclude group: "androidx.activity", module: "activity"
exclude group: "androidx.core", module: "core"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
The duplicate class errors started fading, however, with subsequent builds, I get the following error. How to fix this?
ERROR:D:\Android.gradle\caches\transforms-3\19075c4677e37e538c54d7f745fc8af4\transformed\appcompat-1.4.1\res\color\abc_btn_colored_text_material.xml:22: AAPT: error: attribute alpha (aka com.bo.ri:alpha) not found.
Hint: I cleared caches within .gradle folder as well
I have this problem: When I run my project on Android Studio it works fine, but when I try to Build the APK (on BUILD > BUILD Apk(s)) it shows me the next error:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [/Users/sergio/Documents/ink/touch_android/app/build/intermediates/multi-dex/debug/componentClasses.jar] (Can't read [/Users/sergio/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.3.3/63b77400b5f1cf83a81823562c48d3120ef5518e/jackson-databind-2.3.3.jar(;;;;;;**.class)] (Duplicate zip entry [jackson-databind-2.3.3.jar:com/fasterxml/jackson/databind/JsonDeserializer$None.class]))
as far as I know this is caused by a duplicated class called JsonDeserializer, that I found on my project
but I can't find a way to 'unlink' this files from each jar listed. This is my gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "---"
minSdkVersion 19
targetSdkVersion 23
versionCode -
versionName "-"
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
multiDexEnabled true
ndk {
abiFilters "x86", "armeabi-v7a", "armeabi"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { resources.srcDirs = ['src/main/resources', 'src/main/java/includes'] } }
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
}
}
dependencies
{
//compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
implementation files('libs/gson-2.5.jar')
implementation files('libs/guava-18.0.jar')
implementation files('libs/snmp6_1.jar')
implementation 'com.crittercism:crittercism-android-agent:5.6.4'
implementation files('libs/jackson-annotations-2.2.3.jar')
implementation files('libs/jackson-databind-2.2.3.jar')
implementation files('libs/httpmime-4.3.2.jar')
implementation files('libs/httpcore-4.3.1.jar')
implementation files('libs/commons-lang3-3.4.jar')
implementation files('libs/commons-validator-1.4.0.jar')
implementation files('libs/jackson-core-2.2.3.jar')
implementation files('libs/commons-net-3.1.jar')
implementation files('libs/ZSDK_ANDROID_API.jar')
implementation files('libs/opencsv-2.2.jar')
implementation files('libs/commons-io-2.2.jar')
implementation files('libs/mrzjniInterfaceJar.jar')
implementation 'com.kyleduo.switchbutton:library:1.4.1'
implementation 'com.github.nkzawa:socket.io-client:0.3.0'
implementation 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'
implementation 'com.android.support:multidex:1.0.1'
implementation('de.keyboardsurfer.android.widget:crouton:1.8.5#aar')
implementation 'com.android.support:appcompat-v7:23.4.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:23.4.0'
implementation files('libs/cw-deviceapi20171026.jar')
implementation 'org.jmrtd:jmrtd:0.5.5'
implementation 'net.sf.scuba:scuba-sc-android:0.0.9'
implementation 'com.madgag.spongycastle:prov:1.54.0.0'
implementation 'edu.ucar:jj2000:5.2'
implementation 'com.github.mhshams:jnbis:1.1.0'
implementation files('libs/BrotherPrintLibrary.jar')
implementation files('libs/MobilePrintLib.jar')
}
try removing this implementation
implementation files('libs/jackson-core-2.2.3.jar')
and do
Build > Clean Project
In the module where you are adding jackson dependency exclude that class which is already in the other lib. Otherwise, exclude it from the other lib and leave it on the jackson.
Suddenly i got an error in the execution of the app.
I know that this qustion was already asked here: Annotation processors must be explicitly declared now
However the solution don't answer the problem :(
this is my build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
buildToolsVersion '27.0.0'
aaptOptions {
cruncherEnabled = true
}
defaultConfig {
applicationId "com.freelance.crdzbird_dev.clarobadge"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
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'
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.+'
compile 'com.android.support:support-v4:26.+'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.javiersantos:MaterialStyledDialogs:2.1'
annotationProcessor 'com.google.auto.value:auto-value:1.1'
compile 'ai.api:libai:1.4.8'
compile 'ai.api:sdk:2.0.7#aar'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'io.mattcarroll.hover:hover:0.9.8'
compile 'com.gjiazhe:MultiChoicesCircleButton:1.0'
compile "org.apache.logging.log4j:log4j-core:2.8"
compile 'com.sackcentury:shinebutton:0.1.9'
compile 'com.yalantis:contextmenu:1.0.7'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.2'
compile 'me.samthompson:bubble-actions:1.3.0'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.github.apl-devs:appintro:v4.2.2'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
compile 'com.google.firebase:firebase-messaging:10.2.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
repositories {
mavenCentral()
Anyone knows how can this error be solved. I search in google without success.
This is the error that recieve
Error:Execution failed for task ':app:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- log4j-core-2.8.jar (org.apache.logging.log4j:log4j-core:2.8)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
That user's error said this annotation processor was missing auto-value-1.1.jar (com.google.auto.value:auto-value:1.1), and the answer was to add:
annotationProcessor 'com.google.auto.value:auto-value:1.1'
Your error says log4j-core-2.8.jar (org.apache.logging.log4j:log4j-core:2.8) so you thought the answer was to add this?
annotationProcessor 'com.google.auto.value:auto-value:1.1'
You've copied it verbatim! Of course it won't work! Change the annotation processor to the one you're actually using.
Cough cough cough annotationProcessor 'org.apache.logging.log4j:log4j-core:2.8'
Please Add this to your build.gradle
testImplementation('org.robolectric:robolectric:4.3.1') {
// https://github.com/robolectric/robolectric/issues/5245
exclude group: 'com.google.auto.service', module: 'auto-service'
}
Like this
After that clean Project and Build
Hope it Helps
This problem occurred after i updating my android studio to 2.0 when i try to run i get this:
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(org.jsonschema2pojo.gradle.GenerateJsonSchemaTask$_configureAndroid_closure4) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is not an inner class.
this is my build.gradle (Modeule: app)
Can someone explain to me how to solve this.
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 {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "tazligen.com.tazligen"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txtd'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/NOTICE.txt'
}
productFlavors {
}
}
ext {
supportLibVersion = "23.2.1"
googlePlayServicesVersion = "8.4.0"
junitVersion = "4.12"
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile "junit:junit:${junitVersion}"
// Android Support Library
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
// Networking libraries
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.6.2'
compile 'org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:0.4.16'
compile 'javax.annotation:jsr250-api:1.0'
compile 'org.apache.httpcomponents:httpmime:4.3.1'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'io.realm:realm-android:0.84.1'
compile 'info.hoang8f:android-segmented:1.0.6'
compile 'com.github.blackfizz:eazegraph:1.2.2#aar'
compile 'com.nineoldandroids:library:2.4.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
}
Well i solved the problem myself . Well i just removed the line
compile 'org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:0.4.16'
and it worked. Guess in android studio 2.0 this isn't required anymore. Anyways it worked for me.
I want to read xls and xlsx files.
I use this line to access my workbook.
myWorkBook = WorkbookFactory.create(file);
My build gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.application"
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:19.1.0'
compile files('libs/poi-3.7.jar')
compile files('libs/poi-ooxml-3.9.jar')
compile project(':aFileChooser')
}
I cannot compile my project as I get the following error:
Error:(210, 41) error: cannot access NPOIFSFileSystem
class file for org.apache.poi.poifs.filesystem.NPOIFSFileSystem not found
Error:Execution failed for task ':app:compileDebugJava'.
Compilation failed; see the compiler error output for details.
Any ideas what could be wrong?
Your problem is almost certainly these lines:
compile files('libs/poi-3.7.jar')
compile files('libs/poi-ooxml-3.9.jar')
Specifically, two issues. Firstly, you must use matching versions of the Apache POI jars. It is not supported to use a mixture of old and new jars at the same time, they must all be from the same release. Secondly, both your jars are old ones, which due to their age miss some features.
Switch those to both be from POI 3.10.1 (or newer, eg 3.11 beta 2 as of writing), and you should then have the classes you need