Android appcompat-v7 libraries not recognized - java

I moved my project to a new computer, with freshly installed Java and Android Studio, and it started acting weirdly. First, I was required to change "compile" with "implementation" in my gradle file. I did that, and then I was required to change my target sdk version, I did that too, and I also changed the version of the appcompat libraries, but in my classes the imports of appcompat are not recognized and also the methods, and the project does not build.
I cleaned, rebuilt, removed the .idea folder, did basically everything I could think of.
My gradle file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.betako.pretprodazba"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:animated-vector-drawable:26.0.1'
implementation 'com.android.support:mediarouter-v7:26.0.1'
implementation 'com.android.support:design:26.0.1'
implementation 'com.google.android.gms:play-services:8.1.0'
implementation files('libs/commons-net-1.4.1.jar')
}

Related

Program type already present: net.sf.cglib.beans.BeanCopier$BeanCopierKey while building with gradle

I'm a noob in the android automation and I do my first steps (in windows). I have my first program in android studio 3.1 and Appium server. when I try to run the program I get:
Program type already present: net.sf.cglib.beans.BeanCopier$BeanCopierKey
Message{kind=ERROR, text=Program type already present: net.sf.cglib.beans.BeanCopier$BeanCopierKey, sources=[Unknown source file], tool name=Optional.of(D8)}
I've tried to delete the cglib jar from the gradle external libraries but error persist.
from "gradlew dependencies" command (windows) I didnt see any cglib dependencies
I'm stuck on this for more than a week. any help will be very much appreciated
below are my build.gradle and gradle.properties files
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
multiDexEnabled true
applicationId "com.example.shayg.myapplication"
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
} }
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation ('com.android.support.constraint:constraint-layout:1.0.2')
{exclude group: "com.google.code.gson:gson:2.2.2"
exclude group:"net.sf.cglib.beans"}
testImplementation 'junit:junit:4.12'
androidTestImplementation ('com.android.support.test:runner:1.0.1')
{exclude group: "com.android.support:support-annotations:25.4.0"
exclude group:"net.sf.cglib.beans"}
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//implementation 'com.google.code.gson:gson:2.2.2'
implementation ('io.appium:java-client:4.0.0')
{exclude group:"org.seleniumhq.selenium:selenium-java:2.53.0"
exclude group:"com.google.code.gson:gson:2.3.1"
exclude group:"org.apache.httpcomponents:httpclient:4.5.1"
exclude group:"commons-codec:commons-codec:1.9"
exclude group:"commons-logging:commons-logging:1.1.1"
exclude group:"commons-collections:commons-collections:3.2.1"
exclude group:"net.sf.cglib.beans"
}
implementation ('org.seleniumhq.selenium:selenium-java:2.53.1')
{exclude group:"com.google.code.gson"
exclude group:"net.sf.cglib.beans"}
}
gradle.properties
org.gradle.parallel=true
enableD8="false"

REST Android Client using Spring and OAuth2 Error DexArchiveMergerException: Unable to merge dex

I have a server running and I want to connect an android client to the server with spring's oauth2. I use Android Studio. My problem is related to the gradle configurations, which I don't know how it should be.
Problem: When I run the app, I get this error:
Error:Execution failed for task':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have seen many other questions with the same problem, I tried the solutions (like adding multiDexEnabled true, clean and rebuild the project etc.) but none of them worked. I think that the problem is caused because these two dependencies:
implementation 'org.springframework.security.oauth:spring-security-oauth2:2.2.0.RELEASE'
implementation 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
might have some common jars or something. Any help would be appreciated.
My build.gradle (Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "readinghood.restclient"
minSdkVersion 14
targetSdkVersion 26
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'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/spring.tooling'
exclude 'META-INF/spring.handlers'
exclude 'META-INF/spring.schemas'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
implementation 'org.springframework.security.oauth:spring-security-oauth2:2.2.0.RELEASE'
implementation 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
}
My build.gradle (Project: RestClient)
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE")
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'http://repo.spring.io/libs-release' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
dexOptions {
preDexLibraries = false
}
compileSdkVersion 27
buildToolsVersion '27.0.3'
packagingOptions
{
exclude 'AndroidManifest.xml'
exclude 'META-INF/LICENSE'
exclude 'META-IN F/NOTICE'
exclude 'META-INF/DEPENDENCIES'
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
applicationId "com.support.project"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
Try this it should work for your cause. Go through this link to understand why we should add this line of code multiDexEnabled true
I finally solved the problem. There were two modules that were duplicate, so I had to exclude them from the Module build.gradle file. What I had to do was:
compile('org.springframework.android:spring-android-rest-template:2.0.0.M3') {
exclude module: 'spring-android-core'
}
compile('org.springframework.security.oauth:spring-security-oauth2:2.3.0.RC1'){
exclude module: 'spring-web'
}

Using Eclipe Collections with Android - build.gradle fails

For an Android project which I'm developing I need* to use the Eclipse Collections framework. So I integrated it to my build.gradle according to their "get started", and imported the needed libraries. The problem is that when I tried to run the app on my Android device it fails with the message:
Error:Execution failed for task
':app:transformResourcesWithMergeJavaResForDebug'.
More than one file was found with OS independent path 'LICENSE-EDL-1.0.txt'
I did some googling and got to a few questions here at Stackoverflow with similar (though not identical) problems, but none of the proposed solutions worked for me (most of them suggested to add packagingOptions to build.gradle). If it matters anyhow - my app uses OpenCV4Android, and I'm developing it in Android Studio.
In addition, just to be clear, everything works fine without the Eclipse-Collections additions..
Here's of my app's build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.example.android.coftest"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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.eclipse.collections:eclipse-collections-api:9.0.0'
compile 'org.eclipse.collections:eclipse-collections:9.0.0'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:26.+'
compile 'com.android.support:support-vector-drawable:26.+'
testCompile 'junit:junit:4.12'
compile project(':openCVLibrary330')
}
* it's not a must-have, but it makes my code more simple and elegant, and I would really like to have that.
add this in your gradle :
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE-EDL-1.0.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}

com.android.builder.packaging.DuplicateFileException in android studio

I am not getting how to resolve this? Can anyone suggest me some solutions
My Application Gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.admin.bigquerytutorials"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.cloud:google-cloud-bigquery:0.26.0-beta'
}
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK project.properties
File1: C:\Users\Admin.gradle\caches\modules-2\files-2.1\com.google.cloud\google-cloud-bigquery\0.26.0-beta\69de62300e43f068fee504fbc055fce5d2e64b94\google-cloud-bigquery-0.26.0-beta.jar
File2: C:\Users\Admin.gradle\caches\modules-2\files-2.1\com.google.cloud\google-cloud-core\1.8.0\98ede50a9dfdf818204cfc65e494936feb8c5078\google-cloud-core-1.8.0.jar
In Your app level gradle. Whatever you get duplicate put it here. I was getting in project.properties. I did that and it worked
android{
......
......
......
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/io.netty.versions.properties'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'project.properties' <<<<<-------This line worked for me
}
}

Duplicate files copied in APK Error

First off, Ive researched the forms and found many topics covering this. However, I have attempted all options that I found and nothing seems to work. Here is the error:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK org/codehaus/jackson/impl/VERSION.txt
File1: C:\Users\Austin\AndroidStudioProjects\Intelwatch\app\libs\jackson-core-asl-1.8.5.jar
File2: C:\Users\Austin\AndroidStudioProjects\Intelwatch\app\build\intermediates\exploded-aar\com.esri.arcgis.android\arcgis-android\10.2.7\jars\libs\jackson-core-1.9.5.jar
app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.f0xcr4f7.intelwatch"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions{
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/VERSION'
exclude 'META-INF/VERSION.txt'
exclude 'META-INF/version.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar', '.so'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.esri.arcgis.android:arcgis-android:10.2.7'
compile files('libs/android-async-http-1.3.1.jar')
compile files('libs/jackson-core-asl-1.8.5.jar')
compile files('libs/jackson-mapper-asl-1.8.5.jar')
compile files('libs/KumulosAndroid.0.2.3.jar')
}

Categories

Resources