I am new to android developing. I am trying to open an existing project and get it to compile. this the first time for me using android studio and the Gradle file got me a little confused.
I am trying to synchronize it but it is failing. This is the content of Gradle.build
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "de.establishement.packagelist"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationTrial "android.support.test.trial.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable= true
}
}
}
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.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
testCompile 'junit:junit:4.12'
}
I downloaded this project and I have it in my Desktop. this is what I get in my build messages:
FAILURE: Build failed with an exception.
* Where:
Build file '/mac/Desktop/javaproject/build.gradle' line: 21
* What went wrong:
Could not compile build file '/Users/mac/Desktop/javaproject/build.gradle'.
> startup failed:
build file '/Users/mac/Desktop/javaproject/build.gradle': 21: Statement labels may not be used in build scripts.
In case you tried to configure a property named 'debuggable', replace ':' with '=' or ' ', otherwise it will not have the desired effect.
# line 21, column 25.
debuggable: true
^
1 error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
ERROR: startup failed:
build file '/Users/mac/Desktop/javaproject/build.gradle': 21: Statement labels may not be used in build scripts.
In case you tried to configure a property named 'debuggable', replace ':' with '=' or ' ', otherwise it will not have the desired effect.
# line 21, column 25.
debuggable: true
^
1 error
Open File
Looking at your logs you must change debuggable: true to debuggable = true
Did you try it?
Wrong use. Try this;
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "de.establishement.packagelist"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationTrial "android.support.test.trial.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable true //This row is wrong.
}
}
}
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.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
testCompile 'junit:junit:4.12'
}
Related
//Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.cpsraozan.admission"
minSdkVersion 15
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 {
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:27.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
}
apply plugin: 'com.google.gms.google-services'
Go to your build.gradle file and add multidexEnable true on defaultConfig.
android {
compileSdkVersion 26
defaultConfig {
targetSdkVersion ..
multiDexEnabled true //add this
}
}
For more information See this
This is kind of NOT straight forward. Most likely you might have added a new dependency or updated a dependency which is causing multiple versions of the same library being added as a dependency.
Check if Android studio is highlighting any lines for this, especially in Gradle files.
Run a dump of all dependencies Gradle is processing using the command
./gradlew -q dependencies app:dependencies
check for conflicting dependencies and fix them.
I was struggling this morning with the same error and the requirement for multiDexEnabled didn't make sense. This is only for large projects with more than 64k methods. I found this solution somewhere on SO, but couldn't find it again. So reposting the answer.
Error:failed to create directory 'D:\rw_apps\MyApplication\app\build\generated\source\r\debug\com\example\bhavin\myapplication'
Error:java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.AaptException: AAPT2 link failed:
Error:com.android.builder.internal.aapt.AaptException: AAPT2 link failed:
Error:Execution failed for task ':app:processDebugResources'.
Failed to execute aapt
I tried lots of solution from other stackoverflow answers like
clean project,
restart android studio,
change build-tools,
re-download build-tools.
Run with --stacktrace are long so I share text file please check it.
I am using android studio 3.0 beta 6.
MY gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
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 {
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.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
Set android.enableAapt2=false in your gradle.properties file
In android studio-2.3.3
Error:java.util.concurrent.ExecutionException: java.lang.RuntimeException: AAPT process not ready to receive commands
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: AAPT process not ready to receive commands
It's a hello world application.
How can I solve this error?
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.shibly.myapplication"
minSdkVersion 10
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'
testCompile 'junit:junit:4.12'
}
try to look in this :
Gradle on Android Studio loading with error
"I had the same problem. I fixed it by downgrading my build tools version from 24.0.1 to 23.0.3.
Download older build tool version from http://dl.google.com/android/repository/build-tools_r23.0.3-linux.zip
, Extract the downloaded file and paste it in your SDK build-tools directory( mostly /home/user/Android/Sdk/build-tools)
,
Now in your app:gradle file change the buildToolsVersion to "23.0.3"
, Sync your gradle file and you should be good to go
Hope google fixes its build-tools bug"
Developing ndk programing. How to solve it error. Please give me
Error
Error:Execution failed for task ':app:linkAppArm64-v8aDebugSharedLibrary'.
A build operation failed.
Linker failed while linking libApp.so.
See the complete log at: file:///C:/android/NDKTutorialTwo/app/build/tmp/linkAppArm64-v8aDebugSharedLibrary/output.txt
Output.txt
See file:///C:/android/NDKTutorialTwo/app/build/tmp/linkAppArm64-v8aDebugSharedLibrary/output.txt for all output for linkAppArm64-v8aDebugSharedLibrary.
linking libApp.so failed.
C:/androidNDK/android-ndk-r12b/toolchains/aarch64-linux-android-4.9/prebuilt/windows/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld.exe: cannot find -lmui
collect2.exe: error: ld returned 1 exit status
Finished linkAppArm64-v8aDebugSharedLibrary, see full log file:///C:/android/NDKTutorialTwo/app/build/tmp/linkAppArm64-v8aDebugSharedLibrary/output.txt.
App level Gradle
apply plugin: 'com.android.model.application'
model{
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.metroinfrasys.ndktutorialtwo"
minSdkVersion.apiLevel 16
targetSdkVersion.apiLevel 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file('proguard-android.txt'))
}
}
ndk {
moduleName "App"
ldLibs.add("EGL")
ldLibs.add("android")
ldLibs.add("GLESv2")
ldLibs.add("dl")
ldLibs.add("log")
ldLibs.add("mui")
}
}
}
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:24.2.0'
testCompile 'junit:junit:4.12'
}
Please give any solution
I've imported a module to android studio from eclipse and when I want to import a class from this module, the build fails with this error message:
/home/matias/workspace/Apps/app/src/main/java/io/example/app/MainActivity.java:8: error: package com.example.components.activities does not exist
import com.example.components.activities.AndroidVideoCapture;
^
1 error
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
The module components builds successfully (using 'Build > Make Module 'components'), the problem shows up when I try to build the app (again, 'Build > Make Module 'app').
here's the app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "io.example.app"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:22.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(":components")
}
and the components build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-components.txt'
}
}
aaptOptions {
cruncherEnabled true
}
}
dependencies {
compile files('libs/amazon-ads-5.1.153.jar')
compile files('libs/amazon-device-messaging-1.0.1.jar')
compile project(':librarylvl')
compile project(':crop_lib')
compile project(':openGLVideoRenderer')
compile project(':libffmpeg')
//compile 'com.android.support:appcompat-v7:22.+'
compile 'com.google.android.gms:play-services:+'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.github.bumptech.glide:volley-integration:1.3.0'
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.getbase:floatingactionbutton:1.10.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.android.support:cardview-v7:22.0.+'
compile 'com.android.support:recyclerview-v7:22.0.+'
compile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
// change this 2 lines for release code
//compile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
//compile project(':nop-leakcanary')
}
so.. What is happening here? I'm missing some configurations or steps?
Note: if I import com.example.components.activities.* gradle fails to find the package, but I can import com.example.openglvideorenderer.RenderView just fine from the openGLVideoRenderer module.