【问题标题】:Error Android Studio:No dex files created while using Google's Calendar API错误 Android Studio:使用 Google 的日历 API 时未创建 dex 文件
【发布时间】:2017-01-17 16:06:13
【问题描述】:
apply plugin: 'com.android.application'
android {
    compileSdkVersion 24
    buildToolsVersion '24.0.1'
    defaultConfig {
        applicationId "com.example.calendarquickstart"
        minSdkVersion 11
        targetSdkVersion 24
        versionCode 1
        multiDexEnabled true
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.google.android.gms:play-services-auth:9.4.0'
    compile 'pub.devrel:easypermissions:0.1.5'
    compile('com.google.api-client:google-api-client-android:1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile('com.google.apis:google-api-services-calendar:v3-rev210-1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }

}

我正在尝试使用 google API 进行日历,但在运行应用程序时出现以下错误"

信息:Gradle 任务 [:app:clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:assembleDebug] 错误:任务执行失败 ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: 没有dex文件 创建于 C:\Users\user\AndroidStudioProjects\CalendarQuickstart\app\build\intermediates\transforms\dex\debug\folders\1000\10\guava-jdk5-17.0_bbc68f1b67df2c58337cd00757b7bfd105bb5573"

我正在按照link 中的步骤进行操作

为了运行这个应用程序需要在 gradle 文件中进行哪些更改?

【问题讨论】:

    标签: android-studio google-calendar-api


    【解决方案1】:

    尝试在您的 build.gradle 文件中启用 multidex 支持,如Configuring Your App for Multidex with Gradle 所述:

    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.0"
    
        defaultConfig {
            ...
            minSdkVersion 14
            targetSdkVersion 21
            ...
    
            // Enabling multidex support.
            multiDexEnabled true
        }
        ...
    }
    
    dependencies {
      compile 'com.android.support:multidex:1.0.0'
    }
    

    补充阅读:

    Android 应用程序 (APK) 文件包含 Dalvik Executable (DEX) 文件形式的可执行字节码文件,其中包含用于运行您的应用程序的编译代码。 Dalvik Executable 规范将单个 DEX 文件中可以引用的方法总数限制为 65,536 个,包括 Android 框架方法、库方法和您自己代码中的方法。在计算机科学的上下文中,术语 Kilo,K,表示 1024(或 2^10)。因为 65,536 等于 64 X 1024,所以此限制称为“64K 参考限制”。

    超过此限制要求您将应用构建过程配置为生成多个 DEX 文件,称为 multidex 配置。

    【讨论】:

    • 我试过了,但我还是遇到了和以前一样的错误
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-16
    • 2023-03-07
    • 2021-01-03
    相关资源
    最近更新 更多