Error:Execution failed for task ':app:compileDebugJavaWithJavac - java

I'm facing this problem when I try to run my app
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
java.io.FileNotFoundException: C:\Users\ggg\Desktop\android\app\libs\support-v4-25.1.0.jar (The
system cannot find the file specified)
this is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.gumball.at.adventure"
minSdkVersion 14
targetSdkVersion 23
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
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-25.1.0.jar')
}
any help please

Change your targetSdkVersion to 25
and add this line
multiDexEnabled true
You can add dependencies from here

Try to replace
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-25.1.0.jar')
to
compile fileTree(dir: 'libs', include: ['*.jar'])
for including jar library files in your project.
Best you can use gradle dependencies functionalities to add library in your project. Example
compile 'com.android.support:support-v4:25.1.0'
It will automatically download the required library to the project. You don't need to download manually jar files and add to the project.

Related

"Failed to resolve: com.android.support:support-v4:26.0.0" and other similar errors on Gradle sync [duplicate]

This question already has answers here:
Failed to resolve: com.android.support:cardview-v7:26.0.0 android
(26 answers)
Closed 5 years ago.
I have just created a new Android Studio project for both Android Mobile and wear. The initial gradle build failed because I am getting several errors-
Error: Failed to resolve: com.android.support:support-v4:26.0.0
Error: Failed to resolve: com.android.support:percent:26.0.0
Error: Failed to resolve: com.android.support:recyclerview-v7:26.0.0
Error: Failed to resolve: com.android.support:support-annotations:26.0.0
With each error, I am given the option to Install repository and sync project, but nothing happens when I click on it. I have spent several hours trying to find why I am getting these errors, but I can't find any solutions. Does anybody know how to fix these very frustrating errors? Thank you!
build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (mobile)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.georgeberdovskiy.androidweartest"
minSdkVersion 23
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'
})
wearApp project(':wear')
compile 'com.google.android.gms:play-services-wearable:11.0.4'
compile 'com.android.support:appcompat-v7:26+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile "com.android.support:support-core-utils:26+"
testCompile 'junit:junit:4.12'
}
build.gradle (wear)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.georgeberdovskiy.androidweartest"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided 'com.google.android.wearable:wearable:2.0.4'
compile 'com.google.android.support:wearable:2.0.4'
compile 'com.google.android.gms:play-services-wearable:11.0.4'
compile "com.android.support:support-core-utils:26+"
}
I am sure that my version of Android Studio is updated, and all support repositories and APIs are installed.
I don't have an Android wear project, but I had the same problem when I wanted to upgrade the Support Library version for an existing project to 26.0.0. Since 26.0.0 the support libraries are available through Google's Maven repository. So I had to add the repository to my build. gradle file.
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Check out https://developer.android.com/topic/libraries/support-library/setup.html for more details.
The following worked for me:
In the Application build.gradle considered to add following:
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
}
}
in the Module build.gradle:
compileSdkVersion 26
buildToolsVersion "26.0.1"
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-wearable:11.0.4'
compile 'com.android.support:support-compat:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-annotations:26.0.1'
compile 'com.android.support:support-vector-drawable:26.0.1'
compile 'com.android.support:animated-vector-drawable:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v13:26.0.1'
compile 'com.android.support:percent:26.0.1'
compile 'com.android.support:wear:26.0.1'
compile 'com.google.android.support:wearable:2.0.4'
provided 'com.google.android.wearable:wearable:2.0.4'
}
Either change your build tool version from 26.0.1 to 26.0.0 or you can replace 26.0.0 by 26.+ like below.
compile 'com.android.support:support-v4:26.0.0'
to
compile 'com.android.support:support-v4:26.+"
Do same with all...
Hope it helps.
Happy Coding! ^_^
For now, I fixed this with changing in the wear build.gradle:
compile 'com.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'
It seems like the problem is com.google.android.support:wearable:2.0.4. With that, Using 26.0.1 build tools compiles fine. I haven't gone any further with this but it looks like a dependency problem related to a repository although that is really just a guess from the error messages.
Add the following dependencies in your app/build.gradle.
repositories {
maven { url 'https://maven.fabric.io/public' }
maven{url 'https://maven.google.com'}
}
Replace this:
compile 'com.android.support:recyclerview-v7:26.0.0'
With this
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
Do same with all
Update - new version released
compile 'com.android.support:recyclerview-v7:26.1.0'
Add following dependency in your gradle
Replace
compile 'com.android.support:support-v4:26.0.0'
with
compile 'com.android.support:support-v4:25.0.0'
and Replace
compile 'com.android.support:appcompat-v7:26+'
with
compile 'com.android.support:appcompat-v7:25.0.0'
The reason that my project was giving me these errors was because I created the project for Android Platform 26. However, Wear currently doesn't support 26, and it is essential to change the target and compile SDK versions to 25 in the wear module of build.gradle.
Link to Android Developers documentation - https://developer.android.com/training/wearables/apps/creating.html#setting-up-a-phone
build.gradle (wear)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.georgeberdovskiy.findmyphone"
minSdkVersion 25
targetSdkVersion 25
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.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.android.gms:play-services-wearable:11.0.4'
}
apply plugin: 'com.google.gms.google-services'
I only needed to change the compile and target SDK versions to 25 in the wear module. I left them as 26 for the mobile module.
This one worked for me
allprojects {
repositories {
jcenter()
google()
}
}
google() does the magic with the following configuration
Studio version : 3.0 beta 2
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
I meet this problem, changing the build tool/ sdk version didn't work, clearly write compile version didn't work, off line build didn't work.
Finally I just change wearable version, and this problem gone.
provided 'com.google.android.wearable:wearable:2.0.4'
compile 'com.google.android.support:wearable:2.0.4'
to
provided 'com.google.android.wearable:wearable:2.0.2'
compile 'com.google.android.support:wearable:2.0.2'
By the way, I used offline building now because it is really fast when I check this issue.

Could not find method exclude() for arguments [{module=support-v4}]

I am trying to run my application with instant run turned off but I get this error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
android/support/v4/view/KeyEventCompatEclair.class
Here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.jua.app"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
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:23.4.0'
compile project(path: ':app_Data')
compile files('libs/android-support-v4.jar')
}
I tried the solution from this thread:
compile files('libs/android-support-v4.jar'){
exclude module: "support-v4"
}
And now I am receiving this error when I try to Sync now gradle.build:
Error:(29, 0) Could not find method exclude() for arguments
[{module=support-v4}] on file collection of type
org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection.
Open File
I am a little lost right now, If anyone has any idea how to solve this I would appreciate it.
EDIT
I removed
compile files('libs/android-support-v4.jar')
completly and I still get the first error.
This is a syntax issue. The closure in which you are calling exclude is being interpreted as an argument to the files() method, which is incorrect. Should look like this
compile (files('libs/android-support-v4.jar')){
exclude module: "support-v4"
}
For anyone having the same problem, I deleted android-support-v4.jar from folder and now it works. For some reason, if you remove it from inside the gradle.build file it continues to create problems.

Adding gradle dependency for pd for android in my gradle file does nothing

I am trying to import pd-for-android into my project as a gradle dependancy as per the instructions on pd-for-android's githubpage (i.e. make sure jcenter() is in the top level repositories in build.gradle, then add compile 'org.puredata.android:pd-core:1.0.1' to your dependancies in the app build.gradle)
I followed these instructions but I cannot see the library downloading into my external libraries. Is there something else i need to do in order to get this working?
here's my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
...
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
ndk {
...
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:23.2.1'
compile 'io.reactivex:rxjava:+'
compile 'io.reactivex:rxandroid:+'
compile 'org.puredata.android:pd-core:1.0.1'
}
Check if It's inside app\build\intermediates\exploded-aar\
If you have there the library, you shouldn't have any problem to use it.
Does it show up correctly as dependency when you click File->Project Structure and then on the dependencies tab in Android Studio?
if not, have you tried to add it there via the "+" Button?

Error:Execution failed for task ':app:dexDebug'. Process 'command java.exe finished with non-zero exit value 2

I know this question has been asked many times but i am still not able to find the solution. I check for each and every possible duplication library but didn't find it. Here is my Manifest
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dp.myquest"
minSdkVersion 16
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/abs.jar')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/android-async-http-1.4.4.jar')
compile files('libs/android-query-full.0.26.7.jar')
compile files('libs/App42_ANDROID_SDK_3.0.1.jar')
compile files('libs/commons-collections4-4.0.jar')
compile files('libs/commons-net-3.3.jar')
compile files('libs/mail.jar')
compile files('libs/picasso-2.5.0.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.facebook.android:facebook-android-sdk:3.19.0'
}
It has nothing to do with duplicate, the problem is android has a limit of 64k method for an dex file in app.
You need to enable multidex.
This is how you can do it
http://developer.android.com/tools/building/multidex.html

Package does not exist when using separate App as a dependency

I'm trying to compile an App utilising a separate App as a dependency but when I compile referencing modules from this library I see several "error:package does not exist" and "error:cannot find symbol class" messages from graddle. The following are my two build files.
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'AndroidManifest.xml'
exclude 'resources.arsc'
exclude 'classes.dex'
}
}
dependencies {
repositories {
mavenCentral()
}
compile 'com.android.support:support-v4:+'
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.google.android.gms:play-services:+'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:+'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'se.emilsjolander:stickylistheaders:2.+'
compile 'com.googlecode.libphonenumber:libphonenumber:+'
compile files('libs/crashlytics.jar')
compile files('libs/httpclient-4.2.3.jar')
compile files('libs/libphonenumber-5.9.jar')
compile files('libs/mobileservices-0.2.0-javadoc.jar')
compile files('libs/mobileservices-0.2.0.jar')
compile files('libs/stringtotime-1.0.4.jar')
compile files('libs/urbanairship-lib-2.0.2.jar')
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+'
compile files('libs/FlurryAnalytics-4.0.0.jar')
compile 'com.squareup.picasso:picasso:2.3.3'
compile project(':wheel')
}
Dependency gradle:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "kankan.wheel"
minSdkVersion 5
targetSdkVersion 7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Can anyone help/experienced this before? Android Studio does not highlight any issues in the class and I can ctrl+click through to the packages referenced which seems to mean it is set up correctly...
Thanks!
The buildTypes section should not be in library build.gradle file.
You cannot have two gradle scripts using the com.android.application plugin at the same time. Change the dependency project to apply the 'library' plugin.
If that doesn't do it, change the targetSdkVersion of your dependency to that of your core project.
If you are using a Android library module as a dependency (i.e. mylib), then make sure in your app.iml file that you see the following line toward the end of the file:
<orderEntry type="module" module-name="mylib" exported="" />
Try changing min and target sdk to 11 and 19 according in dependency gradle-default config.
I had a similar issue posted here
But I got it resolved using #Doge's suggestion,
I converted the dependency android project to library project.
Thanks.

Categories

Resources