# Create APK file of automation script using Android Studio

**URL:** <https://discuss.appium.io/t/create-apk-file-of-automation-script-using-android-studio/16870>\
**Category:** Support\
**Created:** [May 25, 2017, 8:31am UTC](https://discuss.appium.io/t/create-apk-file-of-automation-script-using-android-studio/16870 "2017-05-25T08:31:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahul\_rai](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/8baadc/32.png) [@rahul\_rai](https://discuss.appium.io/u/rahul_rai)\
**Post date:** [May 25, 2017, 8:31am UTC](https://discuss.appium.io/t/create-apk-file-of-automation-script-using-android-studio/16870/1 "2017-05-25T08:31:39Z")

</div>

We have created automation script using Android studio and it is working good when I run it through Android studio.  
But now, we want a single APK file for this script so we can run automation on one click. When we click on “Build APK”, it is giving us error and reason is JARs used for Appium.

we are using

1. compile group: ‘io.appium’, name: ‘java-client’, version: ‘4.1.2’ (Tried with latest version also but giving same error)
2. selenium-java-3.4.0
3. Android Studio 2.3.1
4. Java 8 (Tried with 6 also but no success)

attached: build.gradle[build.gradle in text format.txt](https://discuss.appium.io/uploads/default/original/2X/6/6fafe7be8ae4d0a4435057bca8833a800c201097.txt) (3.0 KB)

JARs used:

 ![](https://discuss.appium.io/uploads/default/original/2X/4/4c481047ef92c8c772b174daab966285473d507f.png)

Please let us know any solution/suggestions.

Errors:  
Error:when not building a core library.  
Error:trouble processing “javax/xml/XMLConstants.class”:  
Error:Eclipse). If you are sure you’re not intentionally defining a  
Error:This is often due to inadvertently including a core library file  
Error:Ill-advised or mistaken usage of a core class (java.\* or javax.\*)  
Error:in your application’s project, when using an IDE (such as  
Error:core class, then this is the most likely explanation of what’s  
Error:going on.  
Error:However, you might actually be trying to define a class in a core  
Error:namespace, the source of which you may have taken, for example,  
Error:from a non-Android virtual machine project. This will most  
Error:compatibility of your app with future versions of the platform.  
Error:assuredly not work. At a minimum, it jeopardizes the  
Error:It is also often of questionable legality.  
Error:If you really intend to build a core library – which is only  
Error:appropriate as part of creating a full virtual machine  
Error:distribution, as opposed to compiling an application – then use  
Error:the “–core-library” option to suppress this error message.  
Error:If you go ahead and use “–core-library” but are in fact  
Error:building an application, then be forewarned that your application  
Error:will still fail to build or run, at some point. Please be  
Error:prepared for angry customers who find, for example, that your  
Error:application ceases to function once they upgrade their operating  
Error:system. You will be to blame for this problem.  
Error:If you are legitimately using some code that happens to be in a  
Error:core package, then the easiest safe alternative you have is to  
Error:repackage that code. That is, move the classes in question into  
Error:your own package namespace. This means that they will never be in  
Error:conflict with core system classes. JarJar is a tool that may help  
Error:you in this endeavor. If you find that you cannot do this, then  
Error:that is an indication that the path you are on will ultimately  
Error:lead to pain, suffering, grief, and lamentation.  
Error:1 error; aborting  
Error:Error converting bytecode to dex:  
Cause: Dex cannot parse version 52 byte code.  
This is caused by library dependencies that have been compiled using Java 8 or above.  
If you are using the ‘java’ gradle plugin in a library submodule add  
targetCompatibility = ‘1.7’  
sourceCompatibility = ‘1.7’  
to that submodule’s build.gradle file.  
Error:Execution failed for task ‘:app:transformClassesWithDexForDebug’.

> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex ‘C:\Users\aj.gradle\caches\modules-2\files-2.1\xml-apis\xml-apis\1.4.01\3789d9fada2d3d458c4ba2de349d48780f381ee3\xml-apis-1.4.01.jar’ to ‘D:\WorkspaceAndroid\Automation2\app\build\intermediates\pre-dexed\debug\xml-apis-1.4.01\_70aed6e1e0670fccc4c3b68c29ff142f4d983f65.jar’  
> Error:1 error; aborting
