Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android build fails #203

Closed
rajeevriitm opened this issue Apr 27, 2017 · 7 comments
Closed

Android build fails #203

rajeevriitm opened this issue Apr 27, 2017 · 7 comments

Comments

@rajeevriitm
Copy link

rajeevriitm commented Apr 27, 2017

I am working with the latest Diagnostic plugin. It is not working with ImagePicker plugin. Both plugins work independently. I am unable to build my sdk with ionic run android``. Gradle` throws an error ,

BUILD FAILED

Error: /home/raj/ionic/myapp3/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/home/raj/ionic/myapp3/platforms/android/build/intermediates/res/merged/debug/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
    
/home/raj/ionic/myapp3/platforms/android/build/intermediates/res/merged/debug/values-v24/values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
    
/home/raj/ionic/myapp3/platforms/android/build/intermediates/res/merged/debug/values-v24/values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

/home/raj/ionic/myapp3/platforms/android/build/intermediates/res/merged/debug/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

I did recently updated my SDK tools. I am not sure if thats what cause the problem.

android: 6.2.1
SDK tools: 25
Support Repository: 47
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />

I have build-tools 25,24,23 installed as well.
I did try removing and readding platform and all plugins. Nothing seems to help.

@dpa99c
Copy link
Owner

dpa99c commented Apr 27, 2017

This error seems to most commonly arise from a mismatch between the Android compile SDK version and the support library / build tools version (see here).

The solution in most cases seems to be updating the cordova-android platform to the latest version.
Note that if you have previously saved the platform version to the config.xml using cordova platform add android --save then doing cordova platform rm android && cordova platform add android will not add the latest version, but whatever version is pinned in config.xml, so best to do cordova platform add android@latest. (You can substitute ionic for cordova in those commands if you prefer - the CLI args are the same).

Also see #161 and #168 which are similar.

@dpa99c
Copy link
Owner

dpa99c commented Apr 27, 2017

I just noticed your comment about the ImagePicker plugin. It is another possible cause if the two plugins together seem trigger the issue but not individually.

ImagePicker appears to insert its own custom theme which is based on the Holo Light theme and this may be causing the problem since the AppCompat library on which this plugin depends introduces backward compatibility of material themes for devices running pre-Lollipop Android.

@rajeevriitm
Copy link
Author

Thanks @dpa99c for the quick reply. I am adding @latest android platform. And I have updated everything in my android sdk manager to the latest available, so that no problems occur from there. And each plugins work when the other is not installed. So it seems like an issue with plugins dependencies. Any ideas on how this can be solved?

@rajeevriitm
Copy link
Author

I have opened an issue Imagepicker repo as well

Telerik-Verified-Plugins/ImagePicker#51

@dpa99c
Copy link
Owner

dpa99c commented Apr 28, 2017

You didn't say before that you were using the Telerik variant of the ImagePicker plugin.

Your problem is a Gradle dependency collision:

The Telerik ImagePicker is specifically dependent on v23 of the AppCompat library and pins this version to v7:23+ in its plugin.xml.

Whereas this plugin (diagnostic) doesn't pin a specific version (v7:+). This will pull in the latest version of the AppCompat library.

Therefore, there's a dependency version mismatch. In which case, Gradle will take the highest version, which is the most recent version as specified by the diagnostic plugin.

And by including the latest version of AppCompat, the build fails because the ImagePicker plugin is specifically dependent on v23 AppCompat - you can confirm this by installing only the ImagePicker plugin into a test project, changing the plugin.xml to specify v7:+, add the latest Android platform, then try building: it will fail with the same error you are seeing now.

Your easiest option is to fork this (diagnostic) plugin repo, and set the AppCompat version in plugin.xml to match that required by the ImagePicker plugin: i.e. change v7:+ to v7:23+. This will avoid installing the latest version and causing ImagePicker to break the build. You'll then need to install this version into you project directly from your forked repo. I won't accept this as a pull request though, since pinning the version to v23 is likely to cause problems in projects alongside other plugins. That's the reason I don't pin a specific Gradle library version in the plugin.xml: to avoid these types of collisions. In native Android projects, you don't have this problem because you manually specify your Gradle dependencies in build.gradle

Alernatively you could fork the Telerik ImagePicker plugin repo and edit the plugin.xml to unpin the version (set as v7:+). However, you'll probably need to edit the source code and fix it to work with the latest version of the AppCompat library. However, this could be fed back as a pull request to the main plugin repo.

@rajeevriitm
Copy link
Author

@dpa99c Dependency mismatch was the issue. I tried the temporary solution and changed AppCompat dependency to 23+ in diagnostic and its working now.

I am also trying for a permanent solution. I am trying to make ImagePicker to not pin a version of the library but I am not sure how the source code will have to be changed. I have opened an issue there, yet to hear from them..

Thanks you so much @dpa99c . You were really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@dpa99c @rajeevriitm and others