【问题标题】:Hello , i'm programming a android application when it builds the APK the compilation fails您好,我正在编写一个 android 应用程序,当它构建 APK 时编译失败
【发布时间】:2016-08-05 07:51:20
【问题描述】:

Android 上应用程序的 gradle,该应用程序在我的设备 Android 5.1 的调试模式下完美运行

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "cl.datacomputer.alejandrob.gogps"
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    // Enabling multidex support.
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
    }
    }
    }

    dependencies {
compile fileTree(include: ['android-5.0.1_r1.jar'], exclude: 'android-support-v4.jar', dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile('com.android.support:appcompat-v7:23.1.0') {
    exclude module: 'support-v4'
}

compile 'com.android.support:design:23.4.0'
 }

这是错误,我不明白错误在哪里,对不起,如果我的英语不好,但我试着理解,我需要你的帮助,如果你需要更多详细信息,我会在这里阅读所有关于这对我没有任何作用。

   java.util.zip.zipexception: duplicate entry:android/support/annotation/colorres.class

【问题讨论】:

  • 我建议您只使用播放服务中所需的特定模块,而不是使用整个非常庞大的库
  • Tim Castelijns 我怎么做这个?,这是我第一次使用 Android Studio 和 Gradle。
  • 您有一些文档:developers.google.com/android/guides/setup 通过使用compile 'com.google.android.gms:play-services:8.4.0',您的应用程序将包含所有服务。而且可能您不需要其中的大多数...例如,如果您只需要 Google+,您应该使用com.google.android.gms:play-services-plus:8.4.0。您可以在上面的链接中的表 1 中获得每项服务的详细信息。
  • 我用你的推荐解决了这个问题,但是 lib android.jar 编译 fileTree(include: ['android-5.0.1_r1.jar'], exclude: 'android-support-v4.jar' , dir: 'libs') 我直接反编译并删除错误的.c​​lass,现在制作和APK并正确构建。

标签: android google-maps-api-2 android-support-design android-appcompat


【解决方案1】:

首先编译构建

用过

编译'com.google.android.gms:play-services:+'

代替

 compile 'com.google.android.gms:play-services:8.4.0'

并且还改变了你的 AndroidManifest.xml 添加这行 android:name

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:name="android.support.multidex.MultiDexApplication"
    >

并且在你的 build.gradle 中也添加

dexOptions {
    //incremental = true;
    preDexLibraries = false
    javaMaxHeapSize "4g"
}


packagingOptions {
    exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
    exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
}

【讨论】:

    【解决方案2】:

    您正在使用版本 23.1.0 和 23.4.0 试试这个

    compile('com.android.support:appcompat-v7:23.4.0') {
        exclude module: 'support-v4'
    }
    

    【讨论】:

      【解决方案3】:

      只需删除这一行 -

      {
          compile 'com.google.android.gms:play-services:8.4.0'
      }
      

      或尝试

       {
          compile 'com.google.android.gms:play-services:7.0.0'
      } 
      

      【讨论】:

      猜你喜欢
      • 2019-09-29
      • 1970-01-01
      • 2020-02-20
      • 1970-01-01
      • 2016-12-31
      • 1970-01-01
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多