New AndroidStudio 2.3 Error - java

I have just installed new Android Studio and tried to create a new project. But I get this strange error. I am using 32 bit Linux system.
Error:Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: AAPT process not ready to receive commands
Information:BUILD FAILED
Error:java.util.concurrent.ExecutionException: java.lang.RuntimeException: AAPT process not ready to receive commands
Information:Total time: 14.838 secs
Information:2 errors
Information:0 warnings
Information:See complete output in console
I don't understand why I am getting this error.
Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.sandesh.testing"
minSdkVersion 15
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'])
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:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Gradle (project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// 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
}

In your case problem is newest Android Studio does not run on 32bit only system. On download page you can check the requirement also:
64-bit distribution capable of running 32-bit applications
The newest version does not support 32bit. I think you should try with one solution but I dont know how long it will work :
Step1.Go to terminal
Step2.type gedit .profile
Step3.paste the below line at end of the page
Step4.export ANDROID_EMULATOR_FORCE_32BIT=true
Step5.type source .profile in terminal or restart system
Please remember that may be in future Android Stdio stop supporting this too so its better you should move to bit64 or downgrade your version of android studio.

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.

Unable to build gradle and create java class

Any project in my android studio fails to build.The error message is as follows-
Gradle sync failed: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.3-all.zip'.
Consult IDE log for more details (Help | Show Log)
Moreover i'm unable to make a new java class in android studio by File->new->Java class as no such option is available. I found some answers saying right click on java folder then clicking Mark Directory as -> SOurce root, even this option is not there . Moreover, for resolving the gradle issue, i found some answers saying click File->Invalidate Caches/Restart and delete the .gradle file in home directory then update android studio, i did accordingly but still nothing works.
build.gradle contents are-
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.android.iitmandi"
minSdkVersion 15
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'])
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:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5'
testCompile 'junit:junit:4.12'
}
Contents of gradle-wrapper.properties are-
#Tue Mar 28 20:10:53 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Build.grale-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// 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
}
on doing Build->Clean project this error message was shown-
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugUnitTestApkCopy'.
> Could not resolve junit:junit:4.12.
Required by:
project :app
> Could not resolve junit:junit:4.12.
> Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Could not GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out
I even uninstalled Android-Studio 2.3 and installed 2.2.2 instead but still the problem persists
the code in JUnit library is referenced in the project but there is no related JUnit dependent library yet...you either have to delete the referencing line(s) of code in the gradle or install the JUnit library.For more info https://debugah.com/failed-to-resolve-junitjunit4-12-how-to-solve-11544/

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.

Android studio jdk finished with non-zero value 2

Ok, i know this topic is in stack overflow already, but i did everything i could, i did the multydex thing in my gradle, i did every answer i tried to get at stackoverflow, now i need really help on this, yesterday i was unable to run my app after 3 hs of trying to resolve this, hope you guys can bring me a hand
here is my app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "myproject.myname.com.myapp"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
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 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-storage:9.0.0'
compile 'com.google.firebase:firebase-database:9.0.0'
compile 'com.google.firebase:firebase-auth:9.0.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.firebaseui:firebase-ui-database:0.4.4'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
here is my project gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:3.0.0'
// 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
}
if i try to add the multidex = true and all the multiplex lines i got this error
Error:Execution failed for task ':app:packageAllReleaseClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzajj.class
im really confused and i cant find the answer since yesterday , if someone can help me i will be so glad, thanks
UPDATE
Ok , it seems the firebase compiles were causing the problem for the java jdk value error
after changing it to version 9.4.0 it worked
Change ffirebase:firebase-storage ,'com.google.firebase:firebase-database:9.0.0','`com.google.firebase:firebase-auth:' version to 9.4.0 rather than 9.0.0
Let me know if this works for you .

"Cannot determine expansion folder" when running android Instrumentation tests

We want to set up instrumentation tests for our app, that also has 2 flavors. We have successfully set up Android Studio to run instrumented tests directly from the IDE, but trying to run instrumented tests from the command line via 'gradle connectedCheck' always results in the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDevelopmentDebugAndroidTestJavaResources'.
> Cannot determine expansion folder for /Users/james/Development/AndroidProjects/parkinsons11/app/build/intermediates/packagedJarsJavaResources/androidTest/development/debug/junit-4.12.jar936209038/LICENSE-junit.txt with folders
Our test app, which also has two flavours and is set up for instrumented tests, runs both from the IDE and from command line without incident.
Here is our gradle file from our main project:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.app.ourapp"
minSdkVersion 16
versionCode 11
versionName "1.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
assets.srcDirs = ['src/main/assets',
'src/main/assets/font']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
productFlavors {
live {
versionName "1.1 live"
applicationId "com.app.ourapp.live"
}
development {
versionName '1.1 development'
applicationId "com.app.ourapp.development"
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':library:datetimepicker')
compile project(':library:tools')
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:+'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'org.quanqi:mpandroidchart:1.7.+'
compile 'commons-io:commons-io:2.+'
compile 'joda-time:joda-time:2.+'
compile 'com.microsoft.azure.android:azure-storage-android:0.4.+'
testCompile 'junit:junit:4.12'
testCompile "org.robolectric:robolectric:${robolectricVersion}"
testCompile "org.mockito:mockito-core:1.+"
androidTestCompile 'junit:junit:4.12'
androidTestCompile "org.mockito:mockito-core:1.+"
}
And here is our gradle.build from our test app (which works):
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.test.picroft.instrumentationtestapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
newFlavour {
applicationId "com.test.picroft.instrumentationtestapp.newflavor"
}
oldFlavour {
applicationId "com.test.picroft.instrumentationtestapp.oldflavor"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.+"
androidTestCompile 'junit:junit:4.12'
androidTestCompile "org.mockito:mockito-core:1.+"
}
I'm at a loss as to where I'm going wrong. I've compared the directory structure from both apps and there's no meaningful difference. Here's a rough outline of our main project's structure:
src
-androidTest
--java
---*
-live
--res
---layout
---values
-main
--java
---*
-test
--java
---*
I'm totally confused why instrumented tests on one app works fine both in IDE and in command line, while the other refuses to work via command line.
It seems the issue resolved itself. I believe it was some kind of corruption of the build state that was fixed through an invalidate/restart.
Its also worth pointing out that when you switch build flavours in the Build Variation panel, its worth it to wait until Android Studio finishes synchronizing and is not performing any tasks before doing a build or run. I've found that when I was hitting build or run and Android Studio hadn't finished switching the build flavour, it caused all manner of unpredictable issues.
I think the problem might be that you haven't defined a default instrumentation runner, as mentioned here. You should include this in your build.gradle file
android {
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}

Categories

Resources