简体   繁体   English

错误:将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / example / admin / myapplication / MainActivity;

[英]Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/example/admin/myapplication/MainActivity;

I am getting this error while running this program on my device since I updated my AndroidStudio to the current latest version and I am having trouble understanding the problem. 由于我将AndroidStudio更新为当前最新版本,因此在设备上运行此程序时遇到此错误,我无法理解问题。 It would be grateful if someone could help me with it. 如果有人可以帮助我,将不胜感激。 I guess there's some problem in gradle or manifest files. 我猜在gradle或清单文件中有一些问题。

This is my build.gradle: 这是我的build.gradle:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.example.admin.myapplication"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
    'proguard-rules.pro'
            }
        }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.googlecode.libphonenumber:libphonenumber:8.4.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.facebook.android:account-kit-sdk:4.+'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}

AndroidManifest.xml AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.admin.myapplication">

<uses-sdk android:minSdkVersion="15" />


<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />



<application
    android:allowBackup="false"
    android:icon="@mipmap/icon"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <meta-data
        android:name="com.facebook.accountkit.ApplicationName"
        android:value="@string/app_name" />
    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/FACEBOOK_APP_ID" />
    <meta-data
        android:name="com.facebook.accountkit.ClientToken"
        android:value="@string/ACCOUNT_KIT_CLIENT_TOKEN" />

    <activity
        android:name="com.facebook.accountkit.ui.AccountKitActivity"
        android:theme="@style/AppLoginTheme"
        tools:replace="android:theme" />
    <activity 
android:name="com.facebook.accountkit.ui.AccountKitEmailRedirectActivity">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="@string/ak_login_protocol_scheme" />
        </intent-filter>
    </activity>
    <activity
        android:name=".LoginActivity"
        android:screenOrientation="portrait"
        android:theme="@style/FullscreenTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".AccountActivity"
        android:label="@string/account"
        android:screenOrientation="portrait" />
    <activity
        android:name=".EmergencyActActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme" />
    <activity
        android:name=".HealthActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme" />
    <activity
        android:name=".BrowseActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".EmargencyResponseActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme" />
    <activity
        android:name=".StepsActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Main2Activity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity android:name=".SignUpActivity"></activity>
</application>

Try add this in defaultConfig multiDexEnabled true and in dependencies compile 'com.android.support:multidex:1.0.1' and Create an Application class : 尝试将其添加到defaultConfig multiDexEnabled true并在dependencies compile 'com.android.support:multidex:1.0.1'并创建一个Application类:

public class ThisApplication extends MultiDexApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

and add this class to manifest in application tag 并将此类添加到清单中的应用程序标记

<application
android:name=".ThisApplication"
<!-- other attrs -->
>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / RNFetchBlob / RNFetchBlobConst; - Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst; 错误:将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / internal / zzee; - Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzee; 错误:将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / common / api / zza; - Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zza; 错误:将字节码转换为 dex 时出错:原因:com.android.dex.DexException:多个 dex 文件定义了 Lokhttp3/internal/http/RealResponseBody; - Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/http/RealResponseBody; 将字节码转换为dex时出错:原因:com.android.dex.DexException: - Error converting bytecode to dex: Cause: com.android.dex.DexException: 将字节码转换为dex:原因:com.android.dex.DexException:定义了多个dex文件 - converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Gradle 构建错误将字节码转换为 dex 时出错:原因:com.android.dex.DexException:多个 dex 文件定义 Landroid/arch/lifecycle/liveData$1 - Gradle build error Error converting bytecode to dex:Cause: com.android.dex.DexException:Multiple dex files define Landroid/arch/lifecycle/liveData$1 错误:Android Dex:com.android.dex.DexException:多个dex文件定义了Lcom / sinovoice / hcicloudsdk / recorder / ASRCommonRecorder; - Error:Android Dex: com.android.dex.DexException: Multiple dex files define Lcom/sinovoice/hcicloudsdk/recorder/ASRCommonRecorder; com.android.dex.DexException错误:多个dex文件定义了Lcom / google / android / libraries / places / internal / dh; - Error com.android.dex.DexException: Multiple dex files define Lcom/google/android/libraries/places/internal/dh; com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / internal / config / zzao; - com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/config/zzao;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM