gpt4 book ai didi

android - 更新到android studio 3.0后无法mergedex

转载 作者:行者123 更新时间:2023-11-29 02:34:55 27 4
gpt4 key购买 nike

将我的 Studio 更新到 3.0 后,我遇到了问题:

Error:Execution failed for task ':app:processDebugManifest'. 
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.0) from [com.android.support:design:26.0.0]
AndroidManifest.xml:28:13-35 is also present at [com.android.support:appcompat-v7:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:26:9-28:38 to override.

我通过添加以下代码解决了这个问题:

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.0.2'
}
}
}

但是在我的 build.gradle 末尾引入该代码后,当我尝试在我的手机上运行我的应用程序时它显示另一个错误:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

I referred to many links with the similar problems, but I couldn't find the solution to my problem.

这是我的build.gradle (Module:app)

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
multiDexEnabled true
applicationId "com.example.mahe.blooddonation"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}


buildTypes {
release {
minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})

implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services:11.6.2'
implementation 'com.google.firebase:firebase-auth:11.6.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'


compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/google-play-services.jar')
compile files('libs/http-core-4.1.jar')
compile files('libs/httpclient-4.0.3.jar')
compile files('libs/mail.jar') }

我的项目的 build.gradle 是:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
}
}

allprojects {
repositories {
maven{
url "https://github.com/omadahealth/omada-nexus/raw/master/release"
}
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

我的 list 文件是:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.mahe.blooddonation">

<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<application
android:allowBackup="true"
android:icon="@mipmap/dexter"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".IntroScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SignUp" />
<activity android:name=".Login" />
<activity
android:name=".DonorOrReciever"
android:label="@string/title_activity_donor_or_reciever" />
<activity android:name=".RecieverActivity" />
<activity android:name=".ActivityProfile" />
<activity android:name=".EditProfile"></activity>
</application>

而且我已经从我的 gradle 中删除了配置代码块,没有它它编译得很好,但是我仍然遇到无法合并 dex 的问题。

我完整的堆栈跟踪:

Error:java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Error:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Error:com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

我希望有人能对我有所帮助。

最佳答案

我尝试了一个空项目和以下 build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '26.0.2'

defaultConfig {
multiDexEnabled true
applicationId "bla.bla.bla"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}

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

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services:11.6.2'
implementation 'com.google.firebase:firebase-auth:11.6.2'
implementation 'com.mcxiaoke.volley:library-aar:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}

...一切都适合我。也许尝试同样的方法,一个接一个地添加本地库,看看是什么导致了这个错误。我希望你能找到这样的问题。

关于android - 更新到android studio 3.0后无法mergedex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47628101/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com