I'm still exceptionally new to Android Development, about 2 weeks in to my first project. So, a resolution may be obvious, and I can only hope this eventually helps another in my shoes.
The goal was to build an app for FireTV that would stream media (on-demand or live video stream).
I started research on Amazon's developer portal, downloaded AS, Amazon SDK, and anything else I was told I would need to continue. My first thoughts were to familiarize myself with Lollipop, using Google TV's for emulator, and using the TV Activity template, which from what I see is heavily based on the Leanback library. I built and tested and modified to my hearts content, and had a working app, using emulators that can handle api21. Then came the time to 'retro-fit' what I had working with Amazon's Fire TV sdk Add-On (API 17). Learned a bit about AppCompat and a few other errors along the way, most I could figure out on my own. But now, I'm stuck.
Gradle won't compile now that I'm using the FireTV add-on, and the console output isn't helpful to me, at this level.
" What went wrong:
Execution failed for task ':app:processDebugResources'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\path\to\sdk\build-tools\21.1.2\aapt.exe package -f --no-crunch -I C:\path\to\sdk\platforms\android-17\android.jar -M C:\path\to\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -I C:\path\to\sdk\add-ons\addon-amazon_fire_tv_addon-amazon-17\libs\notification.jar -I C:\path\to\sdk\add-ons\addon-amazon_fire_tv_addon-amazon-17\libs\gamecontroller.jar -S C:\path\to\app\build\intermediates\res\debug -A C:\path\to\app\build\intermediates\assets\debug -m -J C:\path\to\app\build\generated\source\r\debug -F C:\path\to\app\build\intermediates\res\resources-debug.ap_ --debug-mode --custom-package com.d53e.rbeal.fntsysportsnetwork -0 apk --output-text-symbols C:\path\to\app\build\intermediates\symbols\debug
Error Code:
1
Output:
ERROR: Asset package include 'C:\path\to\sdk\add-ons\addon-amazon_fire_tv_addon-amazon-17\libs\notification.jar' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.*
"
Been stuck here for two days, running short on time and am urgently needing progress. Can't figure out how to include --stacktrace or --info as suggested.
In panic, i tried to port the project to eclipse, and as an end result am stuck with "Cannot Resolve 'R'" errors, the only fix I can find is to change the build target, but I think I need to use Amazon's.
I'd rather use Android Studio, but at this point any help would be greatly appreciated.
build.gradle
apply plugin: 'com.android.application'
android {
// compileSdkVersion 21
compileSdkVersion "Amazon.com:Amazon Fire TV SDK Addon:17"
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.d53e.myname.appname"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.android.support:leanback-v17:21.0.2'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.amazon.device.tools.build:gradle:1.0.0'
}
(project) build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.amazon.device.tools.build:gradle:1.0.0'
//classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
One of those moments where i want to slam my head against a wall...
Manually copy the file into the "projectName/app/libs" folder,
Change the project explorer view to project, so you can see the libs folder
Right click on the item[s] within, and select "Add as Library"
Much like that last step in eclipse.
Related
When trying to run my app for the first time It does not work.
Here is the error message I got and can't resolve it.
Error:FAILURE: Build failed with an exception.
* What went wrong:
Task 'prepareReleaseUnitTestDependencies' not found in project ':app'.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
And this the build.gradle file in my project:
apply plugin: 'com.android.application'
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.example.android.smth"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
resConfigs "auto"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
A Simple file/invalidate cache / restart can work or try one of the solution below
You can try one of this solution
Upgrade Android Studio to 0.8.7
Preferences | Updates | Switch "Beta Channel" to "Canary Channel", then do a Check Now.
You might be able to skip this.
Checked the Gradle wrapper (currently 1.12.2; don’t try to use 2.0 at this time).
Assuming you don’t need a particular version, use the latest supported distribution
$ vi ~/project/gradle-wrapper.properties
...
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
This can be set in Android Studio at Preferences | Gradle (but 0.8.7 was giving me ‘invalid location’ errors).
The 'wrapper' is just a copy of Gradle for each Android Studio project. It allows you to have Gradle 2 in your OS, and different versions in your projects. The Android Developer docs explain that here.
Then adjust your build.gradle files for the plugin. The Gradle plugin version must be compatible with the distribution/wrapper version, for the whole project. As the Tools documentation (tools.android.com/tech-docs/new-build-system/user-guide#TOC-Requirements) is slightly out of date, you can set the plugin version too low (like 0.8.0) and Android Studio will throw an error with the acceptable range for the wrapper.
Example, in build.gradle, you have this plugin:
dependencies {
classpath "com.android.tools.build:gradle:0.12.+"
}
You can try switching it to the exact version, like this:
dependencies {
classpath "com.android.tools.build:gradle:0.12.2"
}
and (after recording what version you’re changing from in each case) verifying that every build.gradle file in your project pulls in the same plugin version. Keeping the “+” should work (for 0.12.0, 0.12.1, 0.12.2, etc), but my build succeeded when I updated Google’s Volley library (originally gradle:0.8.+) and my main project (originally 0.12.+) to the fixed version: gradle:0.12.2.
Other checks
Ensure you don’t have two Android Application modules in the same Project
This may interact with the final solution (different Gradle versions, above), and cause
UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define (various classes)
To check, Build | Make Project should not pop up a window asking what application you want to make.
Invalidate your caches
File | Invalidate Caches / Restart (stackoverflow.com/a/19223269/513413)
If step 2 doesn't work, delete ~/.gradle/ (www.wuttech.com/index.php/tag/groovy-lang-closure/)
Quit Android Studio
$ rm -rf ~/.gradle/
Start Android Studio, then sync:
Tools | Android | Sync Project with Gradle Files
Repeat this entire sequence (quit...sync) a few times before giving up.
Clean the project
Build | Clean Project
you must include your app module in the settings.gradle file
include ':app'
and if it added try to remove it from the settings.gradle file then sync your project
I am following this tutorial to make monkeytalk agent build so that i can record the event and write some test cases. I have also downloaded git project with is running but is not showing in monkey talk IDE and no events are recording.
I have also made my own project and follow all the steps from 1 to 9. I am testing it on real device so I skipped 10th step. The issue I am facing is that when I sync the project the gradle is building properly but when I am running the project it give me following error.
Error:Execution failed for task ':app:compileDebugJava'.
No such property: bootClasspath for class: com.android.build.gradle.AppPlugin
If anyone have any idea, your help is appreciated. Thanks!!!
After try lots of things i at last successfully integrated MonkeyTalk agent in my APK using Android Studio, here are some details steps that would help a lot.
Tip :
used gradle build version 1.0.0, although 1.2.3 is available but there are some issues with that version of gradle and the monkeytalk client agent apk.
if you are using google play services use 7.0.0 version
Steps :
For steps you can refer to this document
but here are few problems that I face when following this post, here are the following :
make libs folder in your app folder and put monkeytalk-agent-2.0.10.jar there, in your app build.gradle use this
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
....
}
no need of using
monkeytalkCompile fileTree(dir: 'monkey-libs', include: ['*.jar'])
this give me error when i am running the project
no need of writing
monkeytalk.initWith(buildTypes.debug)
monkeytalk {
applicationIdSuffix ".monkey"
}
just use this :
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
i think this will help, if anyone is facing problem please let me know. My build is successfully running on monkeytalk IDE
Instead of AspectJ plugin - com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.5' try to use https://github.com/Archinamon/GradleAspectJ-Android.
First add a maven repo link into your repositories block of module build file:
maven { url 'https://github.com/Archinamon/GradleAspectJ-Android/raw/master' }
Add the plugin to your buildscript's dependencies section:
classpath 'com.archinamon:AspectJ-gradle:1.0.15'
Apply the aspectj plugin:
apply plugin: 'com.archinamon.aspectj'
Now build your project and run.
Note: above changes are there only for step#3 and step#5. other steps will be same.
I've updated my Android SDK and also the PlayServices Library. Nothing seems to work right now.
The import com.google.android.*; does not exists, and I've added the 'compile' lines on the Gradle File.
Have someone experienced this? How can I solve this?
EDIT
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 14
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:22.1.1'
compile 'com.google.code.gson:gson:2.3'
compile 'org.roboguice:roboguice:3.0.1'
compile 'com.google.android.gms:play-services:7.3.0'
}
That's the Gradle File for a Module.
If you use Android Studio and want to use the latest Google libraries via Gradle dependency, you will have to update the
You can do this via Tools -> Android -> SDK Manager -> You have to update the stuff under Extras
Also make sure that you are not using the Offline Mode of Gradle. You can find this option via (I did this on a Mac) Android Studio -> Preferences -> Gradle -> (Global Gradle Settings) Offline Work
Make sure this option is not checked.
Something which was mentioned by #CommonsWare already (and i add it just to sum up this answer) is to sync the project via the Gradle files. You can do this via the toolbar as seen here:
Or via the menu Tools > Android > Sync Project with Gradle Files
If nothing of the above is working for you, it would be really helpful if you can try to build the project via the command line or the terminal with the following command:
gradle clean build --debug
and then post the output here. It will hopefully show why it can't resolve the library.
Try Tools > Android > Sync Project with Gradle Files and see if that clears up your problem. There's a bug where Android Studio does not always warn you to do this with the yellow banner on the editor.
I have some unit and instrumentation tests in my androidTest folder.
I'm trying to run these tests on my local Jenkins.
I've successfully configured my project with Jenkins and I've also created an emulator for the instrumentation tests.
So far all the resources I've seen only focus on ant and earlier versions of Gradle. The syntax for writing tasks has slightly changed in the current version and I'm confused about this.
Here is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "myPackageName"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
You can write a jenkis script like this:
stage('Build & Install') {
//Build the apk and the test apk which will run the tests on the apk
sh 'chmod +x gradlew && ./gradlew --no-daemon --stacktrace clean :app:assembleDevDebug :app:assembleDevDebugAndroidTest'
}
stage('Tests') {
//Start all the existing tests in the test package
sh './gradlew --no-daemon --debug :app:connectedDevDebugAndroidTest'
}
This should install the apk and the test apk into the device and start the test cases in the test apk on installation.
Here I have given DevDebug as I have a flavor constant called Dev and build type is Debug. If you don't have any of those, you don't use them.
Create a job in junkins and (configure adb path) add this command to build steps as execute shell command or as a windows bat cmd
$ adb shell am instrument -w com.xyz.abc.test/android.test.InstrumentationTestRunner
P.S :- For better automation use robotium and spoon with junkins you can automate everything, you push a commit on git and you will get test results in your mail inbox it's that cool.
Edit
Running tests using spoon
Add these commands to build steps
./gradlew assembleDebugAndroidTest
./gradlew assembleDebug
specify debug-build.apk path and test-unaligned.apk path in spoon command properly
java -jar C:\Users\Shivam\Downloads\spoon-runner-1.1.1-jar-with-dependencies.jar --apk C:\Users\Shivam\Downloads\SpoonAndRobotiumTest\app\build\outputs\
apk\app-debug.apk --testapk C:\Users\Shivam\Downloads\SpoonAndRobotiumTest\
app\build\outputs\apk\app-debug androidTest-unaligned.apk --sdk E:\sdk
At first, you must install the Gradle Plugin on your Jenkins-CI installation. You can search it at http://yourhost/jenkins/pluginManager/
To continue integrating it, you can take a look at this presentation, specially on the lastest slides
I know there are 100's of questions/answers around this topic, but none of them seem to give me an answer. I know some(if not all) of my problems are around my lack of understanding of gradle in general. BUT, i'm hoping for some help.
I've got my project working just fine on my desktop. I'm traveling this week, and wanted to work on it some on my laptop. I have all the files, and have the same version of Android Studio on both machines. I kept getting all kinds of gradle errors when opening my project. I think I've went on several wild goose chases at this point.
So I decided to step back and just create a NEW basically blank project in Studio. That ALSO has all kinds of gradle issues. I tried uninstalling Android Studio and re-insatlling, and still no dice even getting a basic project to not give the gradle errors.
I am getting
11:12:27 PM Gradle 'MyApplication' project refresh failed:
A fatal exception has occurred. Program will exit.
: Gradle settings
As the error.
Below is my two gradle files.
Top Level File(which was blank in my actual project, but has something in it in the default one)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
The next build file
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:18.0.0'
}
I am using Android Studio 0.4.2
I am at a complete loss of what is going on. I think it could be that Studio is not actually recognizing that this is an android project. I tried some of the gradlew.bat commands and I got an error mentioning that it does not like the "apply plugin: 'android'" entry. But, I have no idea why that would be.
Any thoughts on where I should start would be greatly appreciated. I have no ideas of where to go next, and guessing at it anymore is not an option.
I've got the same issue with IntelliJ IDEA(which Android Studio is based on) on my laptop and found a solution here: https://code.google.com/p/android/issues/detail?id=65219
Set File -> Settings -> Compiler -> Java Compiler -> Additional command line parameters
-Xms256m -Xmx512m
File -> Settings -> Compiler -> Gradle -> VM Options
-XX:MaxHeapSize=256m -Xmx256m
and in YourAppName/build.gradle update dependencies to use newer gradle version
classpath 'com.android.tools.build:gradle:0.9.+'
Then restart Android Studio and everything should be fine. Otherwise you can take a look at full log file by going to Help -> Show Log in Explorer
To add a little more knowledge to the 'Gradle XXXX project refresh failed'
.
Adding following line to
File -> Settings -> Compiler -> Gradle -> VM Options:
-Xmx256m
seems to solve the problem.
.
It is worth noting that it fixes only certain cause of the problem - and there may be many. In my case: the machine I'm using is 32-bit and has very little memory. As a result my compiler couldn't reserve enough memory on the heap and so refused to compile.
Therefore if you don't have much RAM try adding the above line.
If still stuck, try:
https://stackoverflow.com/a/21168562/3508719
Did you verify that you have buildToolsVersion 19.0.1 and compileSdkVersion 19 is available on you machine, since you are working on laptop I believe this is new setup.
Can you go to Tools -> Android -> SDK Manager and see if you need to install any version specified in your gradle script. Or update gradle script as per SDK and build tools you have.
My couple of issue were resolved by updating SDK and tools!