# Build Failed (android)

**URL:** <https://forum.ionicframework.com/t/build-failed-android/38071>\
**Category:** ionic-v1\
**Created:** [November 28, 2015, 5:23pm UTC](https://forum.ionicframework.com/t/build-failed-android/38071 "2015-11-28T17:23:28Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![iwan\_uschka](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/iwan_uschka/32/91684_2.png) [@iwan\_uschka](https://forum.ionicframework.com/u/iwan_uschka)\
**Post date:** [November 28, 2015, 5:23pm UTC](https://forum.ionicframework.com/t/build-failed-android/38071/1 "2015-11-28T17:23:28Z")

</div>

I don’t really know what happened since last time where i built my project successfully, but now i can’t make it to build my ionic project for android platform.  
Build process determines here: `processDebugResources`.  
Error message:

`.../platforms/android/build/intermediates/res/debug/values-v23/values.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.`

`.../platforms/android/build/intermediates/res/debug/values-v23/values.xml:26: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.`

I don’t use any material design stuff in my project.

`Cordova 5.4.1`  
`Ionic CLI 1.7.10`  
`Android SDK Tools 24.4.`1 installed  
`Android SDK Platform-tools 23.0.1` installed  
`Android SDK Build-tools 23.0.2` installed  
`Android 6.0 (API 23) SDK Platform` installed  
`Android M (API 22) SDK Platform Android M Preview` installed  
`Android 5.1.1 (API 22) SDK Platform` installed  
`Android 4.4W.2 (API 20) SDK Platform` installed  
`Android 4.4.2 (API 19) SDK Platform` installed

In `.../platforms/android/AndroidManifest.xml` you can find this line: `<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />`.

I tried to set `android:targetSdkVersion` in the manifest-XML to 23. No success.  
I removed `Android SDK Build-tools 23.0.2` and installed `Android SDK Build-tools 22.0.1`. No success.

Don’t know what to do.  
Building for iOS platform works.

Thanks for help!

---

<div class="post-metadata">

**Author:** ![Muffasa](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@Muffasa](https://forum.ionicframework.com/u/Muffasa)\
**Post date:** [November 29, 2015, 6:43pm UTC](https://forum.ionicframework.com/t/build-failed-android/38071/2 "2015-11-29T18:43:30Z")

</div>

exact same issue here

---

<div class="post-metadata">

**Author:** ![Muffasa](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@Muffasa](https://forum.ionicframework.com/u/Muffasa)\
**Post date:** [December 1, 2015, 9:21am UTC](https://forum.ionicframework.com/t/build-failed-android/38071/3 "2015-12-01T09:21:57Z")

</div>

Ok, for me the problem was with the cordova.plugins.diagnostics. after removing it i was able to build with the Android SDK tools 22.0.1.  
after tring installing older version of the plugin the build succeed:  
`cordova plugin add --save cordova.plugins.diagnostic@2.2.0`  
but it was sad to realize it wont work on any device runing marshmelow because of the new approach android is taking upon premissions, just like IOS, live premmision requests on usage.

so the solution, as suggested [here](https://www.npmjs.com/package/cordova.plugins.diagnostic) unde Important android note, you must compile with the Android SDK build tools 23.x.

run android in your command line and install all the 22&&23 APIs including the build tools, and add this lines to your config.xml.

> ```
> <preference name="android-minSdkVersion" value="16"/>
> <preference name="android-targetSdkVersion" value="23"/>
> 
> ```

this will dictate the sdk build number. in order for this to take effect a new AndroidManifest.xml file must be generated, to guarentee it just remover ad add the android platform to the projet, and use hooks:

```
ionic platform remove android
ionic hooks add
ionic platform add android

```

ionic android build should work now.

---

<div class="post-metadata">

**Author:** ![iwan\_uschka](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/iwan_uschka/32/91684_2.png) [@iwan\_uschka](https://forum.ionicframework.com/u/iwan_uschka)\
**Post date:** [December 1, 2015, 10:25am UTC](https://forum.ionicframework.com/t/build-failed-android/38071/4 "2015-12-01T10:25:10Z")

</div>

Thanks Muffasa.  
You’re right. The diagnostics plugin is the “problem”.

But your approach doesn’t work for me. I added

`  
``

to my config.xml.  
But when i do this

`ionic platform remove android ionic hooks add ionic platform add android`

i get the following output:

`Creating Cordova project for the Android platform: Path: platforms/android Package: <PACKAGENAME> Name: <NAME> Activity: MainActivity Android target: android-22`

Build process fails again:

`FAILURE: Build failed with an exception (processDebugResources): com.android.ide.common.internal.LoggedErrorException: Failed to run command: /usr/local/Cellar/android-sdk/24.4/build-tools/23.0.2/aapt package -f --no-crunch -I /usr/local/Cellar/android-sdk/24.4/platforms/android-22/android.jar -M /.../platforms/android/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /.../platforms/android/build/intermediates/res/debug -A /.../platforms/android/build/intermediates/assets/debug -m -J /.../platforms/android/build/generated/source/r/debug -F /.../platforms/android/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package <PACKAGE-NAME> -0 apk --output-text-symbols /.../platforms/android/build/intermediates/symbols/debug Error Code: 1 Output: /.../platforms/android/build/intermediates/res/debug/values-v23/values.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'. /.../platforms/android/build/intermediates/res/debug/values-v23/values.xml:26: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.`

Any suggestions?  
Thank you!

 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/2/7/27e46235e785d7d253c3fd329644c23c834f524c.png)

---

<div class="post-metadata">

**Author:** ![kriegar](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kriegar/32/91147_2.png) [@kriegar](https://forum.ionicframework.com/u/kriegar)\
**Post date:** [December 1, 2015, 5:07pm UTC](https://forum.ionicframework.com/t/build-failed-android/38071/5 "2015-12-01T17:07:02Z")

</div>

Has anyone managed to get a solution to this?

I have ran into the same problem and need to launch an app that relies on this plugin this week so need to either get this working or find another solution that allows me to tell if a user has their GPS turned off or not.

---

<div class="post-metadata">

**Author:** ![kriegar](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kriegar/32/91147_2.png) [@kriegar](https://forum.ionicframework.com/u/kriegar)\
**Post date:** [December 2, 2015, 11:10am UTC](https://forum.ionicframework.com/t/build-failed-android/38071/6 "2015-12-02T11:10:44Z")

</div>

iwan\_uschka I think im at the same stage as you, I have updated everything to use version 23 and have the target set to 23 and yet I get the same error message as you.

Have you had any luck figuring it out?

---

<div class="post-metadata">

**Author:** ![ZephDavies](https://avatars.discourse-cdn.com/v4/letter/z/f07891/32.png) [@ZephDavies](https://forum.ionicframework.com/u/ZephDavies)\
**Post date:** [December 2, 2015, 12:59pm UTC](https://forum.ionicframework.com/t/build-failed-android/38071/7 "2015-12-02T12:59:49Z")

</div>

You need to use:  
`ionic platform add android@5.0.0`

> **[dpa99c/cordova-diagnostic-plugin-example](https://github.com/dpa99c/cordova-diagnostic-plugin-example#testing-android-runtime-permissions)**
>
> cordova-diagnostic-plugin-example - Demonstrates use of Diagnostic plugin

Since I’ve helped you, maybe you can help me:  
When you now use `ionic run`, does it uninstall your application before installing it again?  
Mine does, and it means i lose my localStorage and database between ionic runs. It never did this before.  
See [[WORKAROUND] “ionic run” started uninstalling before installing](https://forum.ionicframework.com/t/ionic-run-started-uninstalling-before-installing/38030)

---

<div class="post-metadata">

**Author:** ![kriegar](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kriegar/32/91147_2.png) [@kriegar](https://forum.ionicframework.com/u/kriegar)\
**Post date:** [December 2, 2015, 2:23pm UTC](https://forum.ionicframework.com/t/build-failed-android/38071/8 "2015-12-02T14:23:19Z")

</div>

> [@ZephDavies](#):
>
> ionic platform add android@5.0.0

ZephDavies, that did it! I wish I had known this yesterday as it would have saved me a lot of pain haha.

As for your issue, im not quite sure as I am now getting an error saying ANDROID\_SDK\_ROOT is undefined and This AVD’s configuration file is missing a kernel file. This could be due to me messing around with things earlier though so ill get to the bottom of that and let you know.

---

<div class="post-metadata">

**Author:** ![iwan\_uschka](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/iwan_uschka/32/91684_2.png) [@iwan\_uschka](https://forum.ionicframework.com/u/iwan_uschka)\
**Post date:** [December 3, 2015, 9:35am UTC](https://forum.ionicframework.com/t/build-failed-android/38071/9 "2015-12-03T09:35:21Z")

</div>

Thanks ZephDavies. That did it for me.  
Do we have to add the platform version because it’s not released officially? Couldn’t find any information about it on the cordova website.

---

<div class="post-metadata">

**Author:** ![cpcbell](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/cpcbell/32/94381_2.png) [@cpcbell](https://forum.ionicframework.com/u/cpcbell)\
**Post date:** [December 3, 2015, 3:26pm UTC](https://forum.ionicframework.com/t/build-failed-android/38071/10 "2015-12-03T15:26:33Z")

</div>

I saw similar issues yesterday when trying to integrate instabug, which had updated its SDK to use 23 android support library. I can confirm editing build.gradle in android studio:

```
/* compileSdkVersion cdvCompileSdkVersion
buildToolsVersion cdvBuildToolsVersion
 */
compileSdkVersion 23
buildToolsVersion "23.0.1"

```

and then following Android Studios prompts to update build tools was a “quick fix” to get a good build.

Note: I always integrate instabug afterwards in Android Studio, but this could help people that are seeing the latest versions of plugins expecting 23 as the compile environment.

I’m hoping to find that I can set an environment variable that ionic/cordova will pick up so I don’t have to set compileSdkVersion and buildToolsVersion manually in build.gradle

Cheers

---

<div class="post-metadata">

**Author:** ![itlr](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/itlr/32/97646_2.png) [@itlr](https://forum.ionicframework.com/u/itlr)\
**Post date:** [May 19, 2016, 7:43pm UTC](https://forum.ionicframework.com/t/build-failed-android/38071/11 "2016-05-19T19:43:36Z")

</div>

Thanks for the tip.

Although this fixed the issue for me. I was running a version 4.4.4 genymotion emulator. [http://screencast.com/t/zsbilYOnMVPO](http://screencast.com/t/zsbilYOnMVPO) I’d expect a build built against 5.0.0 to not work there but apparently it works. Why?

The other question is I wonder if this would lock me in a specific of Android OS. What if I wanted to test multiple android versions? I just tried ionic platform add android@4.4.4 didn’t seem to do anything.

---

<div class="post-metadata">

**Author:** ![jayeshjain\_minio](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@jayeshjain\_minio](https://forum.ionicframework.com/u/jayeshjain_minio)\
**Post date:** [June 17, 2016, 11:30am UTC](https://forum.ionicframework.com/t/build-failed-android/38071/12 "2016-06-17T11:30:36Z")

</div>

Here is what I did :

Upgrade your library to API23

```
 <preference name="android-minSdkVersion" value="16"/>
 <preference name="android-targetSdkVersion" value="23"/>

```

Add this to config.xml.

Then go to `/platforms/android/project.properties` and update the target to 23  
target=android-23

Check cordova platform ls  
The version must be 5 or greater, so if not: cordova platform rm android && cordova platform add android@5

---

<div class="post-metadata">

**Author:** ![thaker](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@thaker](https://forum.ionicframework.com/u/thaker)\
**Post date:** [August 1, 2016, 6:45am UTC](https://forum.ionicframework.com/t/build-failed-android/38071/13 "2016-08-01T06:45:07Z")

</div>

Thank you brother, you saved my life… i was stuck on this from many days.  
i removed Cordova Diognostic and it work like charm  
😀  
But, if i want to use Cordova Diognostic which version you prefer to install

---

<div class="post-metadata">

**Author:** ![iwan\_uschka](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/iwan_uschka/32/91684_2.png) [@iwan\_uschka](https://forum.ionicframework.com/u/iwan_uschka)\
**Post date:** [August 1, 2016, 7:08am UTC](https://forum.ionicframework.com/t/build-failed-android/38071/14 "2016-08-01T07:08:42Z")

</div>

hey thaker, please see documentation of [cordova-diagnostic](https://github.com/dpa99c/cordova-diagnostic-plugin#building-for-api-22-or-lower), you can read there what to do if you prefer to use deprecated version of the plugin because of using old android platform version

otherwise i would prefer of course to use latest version of the plugin (and using latest version of android platform) because a lot of useful features were added to the last releases

---

<div class="post-metadata">

**Author:** ![cnngraphics](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@cnngraphics](https://forum.ionicframework.com/u/cnngraphics)\
**Post date:** [September 16, 2016, 7:17pm UTC](https://forum.ionicframework.com/t/build-failed-android/38071/15 "2016-09-16T19:17:06Z")

</div>

I would think unless you rename your package, or change ap ID in config.xml it will be overridden
