I'm trying to start my first Android Studio app and coming across the same error over and over when I try to run or debug. I'm building a music app using the Spotify API and have imported the zipped jar files in the correct directory (under libs in my app).
What seems to be the problem is that maybe my SDK folder is in another drive? I don't think so, but it was the only thing I can think it would be. I even moved over my Android Studio folder and tried running it from the same D: drive but didn't make any difference.
I also have all the appropriate SDKs installed incl. SDK Tools, Platform-tools, SDK Build-tools 19.1, 20, API 19, 20, Android Support Repository, Library, Google Play serivces, Repository, USB Driver, and Intel Emulator.
This is the error I am getting:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\adt-bundle-windows-x86_64-20140702(2)\adt-bundle-windows-x86_64-20140702\sdk\build-tools\19.1.0\dx.bat --dex --output C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\dex\debug C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\classes\debug C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\dependency-cache\debug C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\exploded-aar\com.spotify.sdk\spotifysdk\1.0.0-beta5\libs\jnihelpers-1.0.jar D:\adt-bundle-windows-x86_64-20140702(2)\adt-bundle-windows-x86_64-20140702\sdk\extras\android\m2repository\com\android\support\support-v4\19.0.1\support-v4-19.0.1.jar C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\exploded-aar\com.spotify.sdk\spotifysdk\1.0.0-beta5\classes.jar C:\Users\Jesse\AndroidStudioProjects\SubRosa\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\19.0.1\classes.jar
Error Code:
1
Output:
'D:\adt-bundle-windows-x86_64-20140702' is not recognized as an internal or external command,
operable program or batch file.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Here is some my code and gradle builds/props:
local.properties
sdk.dir=D\:\\adt-bundle-windows-x86_64-20140702(2)\\adt-bundle-windows-x86_64-20140702\\sdk
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0' // Note: this version should match the latest build-tools version
// that you installed in the SDK manager
defaultConfig {
applicationId "com.jesse.spalding.subrosa"
minSdkVersion 14
targetSdkVersion 19
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions {
preDexLibraries = false
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.spotify.sdk:spotifysdk:1.0.0-beta5#aar'
compile 'com.android.support:appcompat-v7:19.0.1'
}
If anyone has any idea what the deal is what this, please let me know. I need to start working on this for a final project and just can't figure this technical thing out for some reason.
The problem seems to be that your SDK is in a path that has a parenthesis in it (D:\adt-bundle-windows-x86_64-20140702(2)\adt-bundle-windows-x86_64-20140702\sdk), which is causing problems in one of the phases of the build process. Move your SDK to a path with a simpler name and update its location in Android Studio (Project Structure > SDK Location) and you should be good to go.
Related
I just created a new application and added android platform. Since I failed to install API 28 for days, I want to run the project against the working SDK 21. How can I configure the application to run with sdk 21?
My app/App_resources/android/app.gradle is the default one with:
android {
defaultConfig {
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
in platforms/android/.gradle/ I see 4.10.2
while my build.gradle is:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When i run tns run android --emulator
the message is:
Gradle build...
+ setting applicationId
+ applying user-defined configuration from D:\pyworks\agrigo7\mobileapp\agrigo\app\App_Resources\Android\app.gradle
Using support library version 28.0.0
+ adding nativescript runtime package dependency: nativescript-optimized-with-inspector
+ adding aar plugin dependency: D:\pyworks\agrigo7\mobileapp\agrigo\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find Platform SDK with path: platforms;android-28
In my Android SDK, I tried to install API 28 but it kept on failing and failing. My current SDK looks like:
given API 21 is installed, I tried:
tns run android --compileSdk 21 --emulator
It first does show 28.0.0. then gives a lot of errors:
+ setting applicationId
+ applying user-defined configuration from D:\pyworks\agrigo7\mobileapp\agrigo\app\App_Resources\Android\app.gradle
**Using support library version 28.0.0**
+ adding nativescript runtime package dependency: nativescript-optimized-with-inspector
+ adding aar plugin dependency: D:\pyworks\agrigo7\mobileapp\agrigo\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
Output: error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
I think you are getting confused between the support library and SDK version. They are different and your support library's major version should always match your SDK's major version which means you can't use support library 28.x with SDK 21.x.
#Jenlooper had given a brief about this breaking change at the 5.0 launch, you must specify the right support library version in the gradle file (project.ext.supportVersion).
Besides, Google Play restricts all new app submissions to target SDK 26 (Android 8.0) so I would recommend you to try SDK 26 instead of 21 which you can't use to publish.
When I try to compile with Nativescript 3.3.1 and the latest tns-android I receive the error No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
I've tried upgrading nativescript CLI to next development release and tns-android to next development release but this issue persists. I've also tried modifying my app.gradle to something along the lines below:
dependencies {
compile 'com.android.support:appcompat-v7:26.0.2'
}
android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.Audible"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
ext {
complieSdkVersion = 26
buildToolsVersion = "26.0.1"
}
But nothing has worked so far. What is the solution to this issue?
I was able to fix it by using the following app.gradle:
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.HelloWorld"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
Add
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
}
To the app.gradle file in app/App_Resources/Android/app.gradle
Once you do that you might have to accept the licenses and download Android API 26 packages even if you have already downloaded most of API 26 before. Check "Show Package Details" in the Android SDK tools to prompt you to download and accept API 26 packages.
After that if its still telling you you need to accept the license
https://developer.android.com/studio/intro/update.html#download-with-gradle
That link will help you out. Here is a copy from that link that helped me finally fix the issue.
If you have accepted the license agreements on one workstation, but wish to build your projects on a different one, you can export your licenses by copying over the accepted licenses directory. To copy the licenses to another machine, follow these steps:
On a machine with Android Studio installed, click Tools > Android > SDK Manager. At the top of the window, note the Android SDK Location.
Navigate to that directory and locate the licenses/ directory inside it. (If you do not see a licenses/ directory, return to Android Studio and update your SDK tools, making sure to accept the license agreements. When you return to the Android SDK home directory, you should now see the directory.)
Copy the entire licenses/ directory and paste it into the Android SDK home directory on the machine where you wish to build your projects.
Gradle will now be able to automatically download missing packages your project depends on.
I am a new to android developing. I have been trying to Build the Gradle in android studio but it always returns an error. I have not been able to run my app even a single type on my android device. Thus, need some help. This time, I am getting this error
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Could not open local class set analysis write cache (F:\ANDROID_PROGRAMS_BEGGINER.gradle\2.10\tasks_app_compileDebugJavaWithJavac\localClassSetAnalysis).
Unexpected lock protocol found in lock file. Expected 3, found 0.
I have tried the following steps , but still facing the same issue :-
Invalidate Cache/Restart
Delete .gradle folder in C://Users/User_Profile directory
Here is my build.gradle file :-
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.android.justjava"
minSdkVersion 15
targetSdkVersion 24
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:24.0.0'
}
My gradle .properties file is quite simple . It has just the following one line :-
org.gradle.daemon=true
I have been using the latest android studio version
Looking for an answer.
Thanks
UPDATE : Just now when I again deleted both .gradle folders, I am getting another error which is
Error:Execution failed for task ':app:clean'.
Unable to delete file: F:\ANDROID_PROGRAMS_BEGGINER\app\build\generated\source\r\androidTest\DefaultConnectionReuseStrategy.html
Try deleting your .gradle folder in project root. Got same error for me and tried clean build project but no effect. Then i found that the problem is with gradle files. So deleted the .gradle folder and got it running. Dont worry about deleting Android Studio will automatically generate deleted folders
Every time I start Android Studio I get the following error:
Gradle 'VertretungsplanProject' project refresh failed: Could not
fetch model of type 'IdeaProject' using Gradle distribution
'http://services.gradle.org/distributions/gradle-1.6-bin.zip'. A
problem occurred configuring project ':Vertretungsplan'. A problem
occurred configuring project ':Vertretungsplan'. Failed to notify
project evaluation listener. A problem occurred configuring project
':libraries:actionbarsherlock'. Failed to notify project evaluation
listener. Could not normalize path for file
'P:\Projekte\VertretungsplanProject\libraries\actionbarsherlock:Vertretungsplan\libs\android-support-v4.jar'.
The syntax for the filename, directoryname or the volume label is
wrong
My project looks like this:
Gradle settings:
build.gradle of :Vertretungsplan:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/commons-io-2.4.jar')
compile project(':libraries:actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
}
build.gradle of :VertretungsplanProject is empty.
build.gradle of :actionbarsherlock:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile files(':Vertretungsplan/libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
When I want to compile now this error appears:
Deprecated make implementation
Old implementation of "Make" feature is enabled for this project.
It has been deprecated and will be removed soon.
Please enable newer 'external build' feature in Settings | Compiler.
After changing this setting to Use external build everything is working fine.
But this appears every time I start Android Studio and this is really annoying.
UPDATE
I deleted the android-support-v4.jar from the libs folder and simply wrote compile 'com.android.support:support-v4:18.0.0' to the build.gradle of ActionbarSherlock. Then the android-support-v4.jar is used from the installed SDK.
EDIT
Go to File > Settings > "Build,Execution,Deployment"> Compiler
Click compiler directly.
Check the option: Use external build > Apply > OK.
It worked for me !! :)
You seem to have more than one issue. Problems loading gradle on startup and problems resolving the dependency path name in your environment.
I recently found a fix for the "Failed to import Gradle project" issue, which could be linked to your dependency issue.
At least if you fix one, you know your issue could specifically be the dependency path resolution rather than a gradle/android studio issue...
Check out the troubleshooting section here:
http://developer.android.com/sdk/installing/studio.html#Troubleshooting
The basic steps are:
1. Close android studio
2. Open the SDK manager
(run android binary/executable which should be in /tools)
3. Scroll down the list and expand extras
4. Tick the "Android Support Repository"
5. Click Install Packages.. etc etc...
You need to download this as Android Studio 0.2.x needs a new maven repository used by the new build system for the support library, instead of using support library jar's.
Let us know if anything changes after trying this fix.
In the error message, the path appears: 'P:\Projekte\VertretungsplanProject\libraries\actionbarsherlock\:Vertretungsplan\libs\android-support-v4.jar'
It looks like you're on Windows. The semicolon before Vertretungsplan is not a legal filesystem character. This appears in your script as
compile files(':Vertretungsplan/libs/android-support-v4.jar')
Try changing this to
compile files('Vertretungsplan/libs/android-support-v4.jar')
Started Android Studio today, and it popped up an update notice. Since I'm eager to explore new features and bug fixes, I clicked yes. Now the Project Structure dialog where you setup dependencies is missing, and has been replaced by a message:
We will provide a UI to configure project settings later. Until then, please manually edit your build.gradle file(s.)
So, I go out to try to figure out how to add ActionBarSherlock to my project as a project dependency, and have hit a brick wall. I have no idea how to import ActionBarSherlock project as a Library Project, and configure my project to use it. There isn't much documentation on this at Google, IntelliJ, and the Gradle docs assume a LOT of pre-existing knowledge of build systems.
There are plenty of posts on SO how to do this (although referenced with already missing Project structure dialog)
How do I add a library project to Android Studio?
Android-Studio ActionBar sherlock error with gradle
Installing ActionbarSherlock with Android Studio?
Problems importing project into Android Studio regarding ActionBarSherlock
In short:
Create a folder (i.e. /libraries) in your root.
Extract actionbarsherlock there
Create a new file build.gradle in actionbarsherlock root with the following contents
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
In your project's build.gradle
dependencies {
//NOTE that "libraries" is actually a folder name you created in step 1
compile project(":libraries:actionbarsherlock")
//Any other dependencies here
//Make sure there is no android-support-v4.jar in this build file
//as it is already contained in actionbarsherlock project
}
In settings.gradle
//NOTE that "libraries" is actually a folder name you created in step 1
include ':libraries:actionbarsherlock', ':<Your project name>'
EDIT
Last step: Close your project and open it back again for Studio to pick up the Intelli-sense data