Android的工作室1.4和矢量图像 [英] Android studio 1.4 and vector image

查看:158
本文介绍了Android的工作室1.4和矢量图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我最新的Andr​​oid演播室到1.4版本。我在,你可以编译矢量图像也为API℃的应用程序更改日志看到; 21.我试了一下。我改变了版本的Gradle从1.3.0到1.4.1并实现矢量图形,而不是光栅。在建设过程中,我得到这个错误:

Today I up to date android studio to 1.4 version. I saw in the changelog that you can compile an app with vector image also for api < 21. I tried it. I changed the gradle version from 1.3.0 to 1.4.1 and implemented vector image instead of raster. During building process I get this error:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 2

对不起我的英文不好。我希望你明白。先谢谢了。

Sorry for my bad english. I hope you understand. Thanks in advance.

推荐答案

步骤1.首先尝试清洁和放大器;重新启动您的项目,看看它是否为你。在多数情况下,它会解决你的问题。

Step 1. First try out Cleaning & restarting your Project and see if it works out for you. In mostly cases it will solve out your issues.

步骤2.如果没有这个工程为你,这意味着你将不得不启用MultiDex模式。

Step 2. If none of this works out for you that means you will have to enabled MultiDex mode.

为Android 5.0 Multidex支持和更高

Android 5.0以上版本使用了运行时调用的艺术,本机
  支持从应用APK文件加载多个DEX文件。艺术
  执行pre-编译在应用程序安装时它扫描
  类(.. N).dex文件,并将其编译成用于单个.oat文件
  通过Android设备执行。有关Android的更多信息
  5.0运行时,看到介绍AR​​T。

Android 5.0 and higher uses a runtime called ART which natively supports loading multiple dex files from application APK files. ART performs pre-compilation at application install time which scans for classes(..N).dex files and compiles them into a single .oat file for execution by the Android device. For more information on the Android 5.0 runtime, see Introducing ART.

这意味着您的应用程序将在API级别21或以上的正常工作。

That means your app would working fine on API level 21 or above.

Multidex支持到Android 5.0之前

之前的Andr​​oid 5.0平台的版本使用的Dalvik运行时
  执行程序code。默认情况下,Dalvik的限制应用​​到单
  每个APK classes.dex字节code文件。为了解决这个问题
  限制,您可以使用multidex支持库,成为
  您的应用程序的主DEX文件的一部分,然后设法进入
  额外的DEX文件和它们所包含的code。

Versions of the platform prior to Android 5.0 use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode file per APK. In order to get around this limitation, you can use the multidex support library, which becomes part of the primary DEX file of your app and then manages access to the additional DEX files and the code they contain.

所以,首先确保你已经导入正确的依赖,这似乎您可以通过下面的方法做。

So, Firstly making sure you have imported correct dependency, which It seems you could do by below way.

dependencies {
  // Change as per the latest dependency
  compile 'com.android.support:multidex:1.0.1'
}

在您的清单中从multidex支持库应用程序元素添加 MultiDexApplication 类。

In your manifest add the MultiDexApplication class from the multidex support library to the application element.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>

替代的,如果你的应用程序扩展应用类,则可以覆盖 attachBaseContext()方法叫 MultiDex.install(本)启用 multidex

Alternative to that, If your app extends the Application class, you can override the attachBaseContext() method and call MultiDex.install(this) to enable multidex.

public void onCreate(Bundle arguments) {
    MultiDex.install(getTargetContext());
    super.onCreate(arguments);
    ...
}

最后,你需要加入 multiDexEnabled真如下更新你的build.gradle文件

defaultConfig {  
        applicationId '{Project Name}'  
        minSdkVersion 15  
        targetSdkVersion 23  
        versionCode 1  
        versionName "1.0"  
        multiDexEnabled true  
    }  

我希望它会帮助你。

I hope it will help you out.

这篇关于Android的工作室1.4和矢量图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆