I want use JUnit 4 framework in my android app and for that reason I added test support library and now my project now working. Here is the stack trace:
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK LICENSE.txt
File 1: C:\Users\Damian\.gradle\caches\modules-2\files-2.1\junit\junit-dep\4.10\64417b3bafdecd366afa514bd5beeae6c1f85ece\junit-dep-4.10.jar
File 2: C:\Users\Damian\.gradle\caches\modules-2\files-2.1\junit\junit-dep\4.10\64417b3bafdecd366afa514bd5beeae6c1f85ece\junit-dep-4.10.jar
This is my build.gradle file:
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "project.myapp.damian.myapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support.test:testing-support-lib:0.1'
compile 'com.android.support.test.espresso:espresso-core:2.0'
compile 'com.android.support.test.uiautomator:uiautomator-v18:2.0.0'
}
Look here and read the error message regarding the ignoring of license files.
Pasted from android studio.
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'LICENSE.txt'
}
}
Related
When I press on run in Android studio an Edit configuration windows pops up and says "Error: Module not specified".
I have added sources to the application libs folder by manually making a folder structure android/hardware/automotive/vehicle/V2_0 and copied the files in there.
Build completes without errors.
I haven't edited the MainActivity -class so it is all pre-generated code.
I believe this error has something to do with incorrect syntax when including but it seems to be hard to get it working :)
this is my settings.gradle file:
include ':app'
project(':app').projectDir = new File('libs/android/hardware/automotive/vehicle/V2_0')
and this is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.s26150.testingopencar"
minSdkVersion 21
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 {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile project(":android.hardware.automotive.vehicle.V2_0")
testCompile 'junit:junit:4.12'
}
What could be the issue here?
thanks in advance.
I do not want to use v23, I want to use v22. I have v22 specified everywhere, but when I try to sync the gradle file, I get:
Error:Failed to resolve: com.android.support:appcompat-v7:23.0.0
Install Repository and sync project
Open File
Show in Project Structure dialog
So I click Open File, and it opens the app build.gradle:
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
<snip>
}
}
compileSdkVersion 'Google Inc.:Google APIs:22'
buildToolsVersion '22.0.1'
defaultConfig {
applicationId 'com.global.android.cwa'
minSdkVersion 9
targetSdkVersion 20
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
}
}
productFlavors {
Pro {
applicationId "com.global.android.pwa"
signingConfig signingConfigs.config
targetSdkVersion 22
}
Simple {
applicationId "com.global.android.swa"
signingConfig signingConfigs.config
targetSdkVersion 22
}
Beta {
applicationId "com.global.android.pwab"
signingConfig signingConfigs.config
targetSdkVersion 22
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services-auth:9.0.0'
}
If I choose to Install Repository and sync project, then I get errors during compilation along the lines of:
android-apt-compiler: [appcompat] D:\Android SDK\extras\android\support\v7\appcompat\res\values-v23\styles_base.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
And I can see in external libraries that it is including appcompat-v23.
Can someone please help me exercise the demon out of gradle that keeps trying to include appcompat v23 in my project?
You are using
compile 'com.google.android.gms:play-services:9.0.0'
This version has a dependency with support libraries v23.
You have to compile with API23.
compileSdkVersion 23
I have downloaded jar file of Loopj library and placed it in libs folder. have tried many changes but getting same error. Can anyone please help me to solve this.
build.gradle :-
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.pratik.receivedsms"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies
{
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.loopj.android:android-async-http:1.4.8'
}
What worked for me is opening gradle terminal from android studio and executing the following command:
gradlew installarchives
It should also work without downloading the jar file.
Another note is that I am using version 1.4.5.
Good luck!
I have gone through many answers for this question like:
Error :: duplicate files during packaging of APK
Gradle sync fails after adding Firebase dependency: duplicate files during packaging of APK
But still after adding packagingOptions I am getting duplicate file error.
I am working on library and here is my app build gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.mcxiaoke.volley:library:1.0.14'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3')
}
EDIT
Adding packagingOption to my sample where I am adding my library as dependency solves the problem can anyone let me know why I have to add it to my sample build.gradle? Or is there any way to remove from sample.
I updated my Android Studio to 1.0.1. I followed this tutorial http://tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0 and changed from runProguard to minifyEnabled true. I also changed it in my library project. When I tried to compile it gave me Error:Execution failed for task ':> java.io.FileNotFoundException: ProjectName\library\proguard-rules.txt (The system cannot find the file specified). I researched for that and I found a solution. I added blank proguard-rules.txt file into that folder. After trying to compile, it gave me even more errors. The main error now was that it cannot find symbol class PageIndicator, which is my library's class. I don't even know what can I do for that.
My project's build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.miesto.meniu"
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':library')
compile files('libs/volley.jar')
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.0#aar'
compile('com.google.api-client:google-api-client-xml:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.http-client:google-http-client-gson:1.17.0-rc'
compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
My library's build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:21.0.0'
}
What am I doing wrong?
I solved this problem when I deleted my library and added it again.