I have a simple project androidproj which I'm trying to build with Jenkins. That is the reason I'm trying to build it from terminal with gradle. The project consists from:
androidmodule1
androidapp1 (androidapp1 has dependency on androidmodule1)
When I execute the cradle by using the following line:
./gradlew build --stacktrace
I get the following error:
FAILURE: Build failed with an exception.
Where: Build file '/Volumes/Storage/Jenkins/jobs/XXX-Android-Compilation/workspace/android/androidmodule1/build.gradle' line: 17
What went wrong: A problem occurred evaluating project ':androidmodule1'.
Ambiguous method overloading for method java.io.File#. Cannot resolve which method to invoke for [null, class
java.lang.String] due to overlapping prototypes between: [class
java.lang.String, class java.lang.String] [class java.io.File,
class java.lang.String]
I found this topic and checked that required SDK is installed, build tools are available:
ANDROID_HOME variable is set:
admin$ echo $ANDROID_HOME
/Users/admin/Library/Developer/Xamarin/android-sdk-macosx
My gradle is:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.company.androidmodule1"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Locally project started just fine.
Do you have any suggestions?
It turned our that Jenkins for some reason wasn't able to see configured environment variables. I had to go to Jenkins->Configuration->Environment Variables and manually specify JAVA_HOME & ANDROID_HOME paths:
Related
Everybody, im trying to generate a signed APK file , with android studio, Firts of all, I changed the "Build variant" from debug to release, then on grade.app minifyEnabled i put true, finally I created my Key and my password, and everything is alright until here, but on my last click, Android studio trys to generate the file but this message comes out
Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification
Warning: there were 1 unresolved references to library class members.
You probably need to update the library versions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
:app:proguardRelease FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:proguardRelease'.
java.io.IOException: Please correct the above warnings first.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
im too new with this software , so please be patient with me, i dont know which libraries should i Update.
My compileSdkVersion is 23, and my targed sdk version is 23.
Thanks you all of you.
here is my build.grade file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.manuelrios.aplicacion_inmobiliaria"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:4.2.42'
}
Add the below code in your app gradle
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
.
.
.
lintOptions {
checkReleaseBuilds false
}
}
Recently I have updated the Android Studio and also the SDK.
While rebuilding my app project i m getting following error...
What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.android.support:appcompat-v7:23.0.0.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
file:/C:/android new SDK/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
file:/C:/android new SDK/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
file:/C:/android new SDK/extras/google/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
file:/C:/android new SDK/extras/google/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
Required by:
AppOne:app:unspecified
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.913 secs
...............................................................
My Gradle file config is as follows ..
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 9
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'])
compile 'com.android.support:appcompat-v7:23.0.0'
}
Take android sdk manager and update
Android support Library
Android support Repository
It will fix the problem.
You need to install/Update the Android support Library and Android support Repository first and then rebuild the project.
I'm a student programmer and I'm continuing an Android project that has been previously started by other students before me. My problem is that I'm getting an error when I try to execute the Android app inside Android Studio. You can see the error message below. The compilation must have worked for the other students since I have an apk file. What's wrong with zipalign?
:app:zipalignDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:zipalignDebug'.
> Process 'command 'X:\Sdk Android Studio\build-tools\21.1.2\zipalign.exe''
finished with non-zero exit value -1073741502
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "csf.dfc.friendtracker"
minSdkVersion 15
targetSdkVersion 21
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:21.0.3'
compile files('libs/guava-18.0.jar')
compile files('libs/Pubnub-Android-3.7.2.jar')
compile files('libs/mysql-connector-java-5.1.34-bin.jar')
}
EDIT:
I haven't found the cause of the error but I added all the project objects in a new one and the error disappeared.
Remove the apk file in the Deploy directory and the export worked fine then.
I realized this happen when you have the directory "..\app\build\outputs\apk\" open in your Windows Explorer. You just need to close it and rebuild the project.
This happened to me too, when I tried to generate the apk in the following path:
C:\users\desktop
Change your signed generated apk destination path used to generate to the following:
<your project path>\app\build\outputs\apk
Example:
E:\androidStudio\CountDownTimer\app\build\outputs\apk
I recently added a new activity to my android studio project and now I am getting an error when I try and run it. It builds fine but I get the error below when I run it:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --output /Users/davidcavanagh/joshcpdandroid/app/build/intermediates/pre-dexed/debug/classes-22ecb8c50fefe43948d87c9fee8e36a6b7d1bb5a.jar /Users/davidcavanagh/joshcpdandroid/app/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/classes.jar
Error Code:
1
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.joshcpd.android"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:5.2.08'
compile 'com.android.support:appcompat-v7:20.0.0'
compile project(':libraries:zbar')
}
I have tried removing the supportLappcompat dependency but then I get even more errors. Any help greatly appreciated.
I finally solved this issue by downloading the latest version of gradle.
I still get this error every so often and I just fix it by going to File ----> Invalidate caches/restart
I find Android Studio to be very buggy
Based on where it's trying to find the dx command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx
it looks like you've crossed a build tools version with something else. The build file you posted in your question looks okay, but look in the other build files in your project (there's at least going to be something in libraries/zbar) and make sure their buildToolsVersion statements are okay. I suspect somewhere you have:
buildToolsVersion 'android-4.4W'
where you should have:
buildToolsVersion '20.0.0'
Now i know the reason of the problem. It was causes by wrong code in \sdk\android-sdk\tools\lib\find_java.bat
Wrong code:
find /i "x86" > NUL && set arch_ext=32 || set arch_ext=64
Correct code:
find /i "x86" > NUL && set arch_ext=32||set arch_ext=64
The wrong code leads to the path of java_exe be
E:\Android\sdk\ANDROI~1\tools\lib\\find_java32 .exe
So, when dx.bat runs
call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%
it will report the wrong status:
Error Code:
1
My platform: win8-32 bit android studio 1.0 - 4GB RAM
I had a similar issue, so I uninstalled the java jdk and reinstalled the latest version from oracle and everything went OK. The link for installing the latest version of jdk is here
Note: you need to update the jdk directory in android studio after doing the above
Having an issue with a project that has trouble with the :app:preDexDebug task when trying to run app. Error received is:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Current settings:
Android Studio 0.8.1
Android Build Tools 20.0.0
Java 1.7_55
Windows 7
Even a default project does not run, although a gradle sync builds fine.
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\...\AppData\Local\Android\android-sdk\build-tools\20.0.0\dx.bat --dex --output C:\...\TestApplication\app\build\intermediates\pre-dexed\debug\support-v4-19.1.0-c0d17b20b65717b1b327ef7ea8fea7e8a443e7fe.jar C:\...\AppData\Local\Android\android-sdk\extras\android\m2repository\com\android\support\support-v4\19.1.0\support-v4-19.1.0.jar
Error Code:
1
Output:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.testapplication"
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Resolved (on windows) by setting
set _JAVA_OPTIONS=-Xms512m -Xmx512m -XX:MaxPermSize=256m
Now script reports
Picked up _JAVA_OPTIONS: -Xms512m -Xmx512m -XX:MaxPermSize=256m
and works correctly.
What is strange, setting up variables GRADLE_OPTS and JAVA_OPTS had no effect.