相关疑难解决方法(0)

Android Gradle插件0.7.0:"在打包APK期间重复文件"

使用Android Gradle插件0.7.0以下内容build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.0'
    }
}

apply plugin: 'android'

repositories {
    maven { url "https://android-rome-feed-reader.googlecode.com/svn/maven2/releases" }
    maven { url "http://dl.bintray.com/populov/maven" }
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion '18.1.1'

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
    }
    buildTypes {
        release {
            runProguard true
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
        }
    }
    productFlavors {
        defaultFlavor {
            proguardFile 'proguard-rules.txt'
        }
    }
    sourceSets {
        instrumentTest.setRoot('src/instrumentTest')
    }
}

configurations {
    apt
}

ext.androidAnnotationsVersion = '2.7.1';

dependencies {
    compile 'com.android.support:support-v4:18.0.0' …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio android-gradle-plugin

322
推荐指数
7
解决办法
12万
查看次数

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat

如果我从命令行运行gradle assembleDebug,我突然收到此错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.util.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:592)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:550)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:531)
    at com.android.dx.merge.DexMerger.mergeDexBuffers(DexMerger.java:168)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:186)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:300)
    at com.android.dx.command.dexer.Main.run(Main.java:232)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:91)
Run Code Online (Sandbox Code Playgroud)

如果我grep for v4,我会在build文件夹中看到两个文件.

Binary file build/pre-dexed/debug/support-v4-19.0.0-2ba5fdd60a6c3836b3104a863fe42897da1fa9d1.jar matches
Binary file build/pre-dexed/debug/support-v4-r7-227d905d79b23b20866531d4f700446c040a2ccb.jar matches
Run Code Online (Sandbox Code Playgroud)

我的gradle文件仅包含此支持库:

compile 'com.android.support:support-v13:19.0.0'
Run Code Online (Sandbox Code Playgroud)

关于如何以某种方式包含r7库,我很难过.我跑了gradle clean,当我重新运行assembleDebug时它总是出现在那里.

如果我在构建目录中grep r7,我在文件中看到它:

Binary file build/exploded-bundles/ComGoogleAndroidGmsPlayServices4030.aar/classes.jar matches
Run Code Online (Sandbox Code Playgroud)

如果我不包含v13,那么其他东西不会编译.

但v13是否包含v4支持库?

这是Play服务AAR包和v13库之间的不兼容吗?

我从gradleplease.appspot.com抓起了gradle文件.

删除播放服务并不能解决问题; 同样的错误.

我在build.gradle中的依赖项:

 dependencies {


 // Google Play Services
//compile 'com.google.android.gms:play-services:4.0.30'

// Support Libraries
//compile 'com.android.support:support-v4:19.0.0'
///compile 'com.android.support:appcompat-v7:19.0.0'
//compile 'com.android.support:gridlayout-v7:19.0.0'
compile …
Run Code Online (Sandbox Code Playgroud)

android gradle android-support-library android-gradle-plugin

210
推荐指数
10
解决办法
16万
查看次数

如何修复在与操作系统无关的路径“build-data.properties”中找到多个文件

添加对“androidx.security:security-crypto:1.0.0-alpha02”的依赖项后,我收到错误消息“在与操作系统无关的路径‘build-data.properties’中发现了多个文件。” 我尝试通过更改库的版本(1.1.0-alpha01;1.0.0-alpha02;1.0.0-alpha01)并修改我在网上找到的 packageoptions 部分来纠正它,但没有任何效果。感谢您的帮助。

apply plugin: 'com.android.application'

android {
compileSdkVersion 30
buildToolsVersion "30.0.1"

defaultConfig {
    applicationId "com.skcc.myapp"
    minSdkVersion 28
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        debuggable false
    }
}

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}

}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-vision:11.8.0'
implementation "androidx.security:security-crypto:1.0.0-alpha02"


//
}
Run Code Online (Sandbox Code Playgroud)

dependencies android gradle android-studio build.gradle

13
推荐指数
1
解决办法
1万
查看次数

为什么需要gradle build packagingOptions?

在我的gradle文件中,我有以下内容:

packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE'
}
Run Code Online (Sandbox Code Playgroud)

根据文件:

/**
 * Adds an excluded paths.
 * @param path the path, as packaged in the APK
 */
Run Code Online (Sandbox Code Playgroud)

这是什么意思?有人可以给我一个真实的例子,说明为什么需要进行这些排除吗?

android build.gradle

7
推荐指数
2
解决办法
4573
查看次数

PackagingOptions 的用途是什么?

当我使用 android studio canary 时,我在 build.gradle 中注意到了一些事情。

它的具体用途是什么?

packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}' // ??? 
        }
    }
Run Code Online (Sandbox Code Playgroud)

android kotlin build.gradle

6
推荐指数
1
解决办法
2960
查看次数