gpt4 book ai didi

android - 无法解析符号 'MultiDex'

转载 作者:行者123 更新时间:2023-12-04 23:56:44 26 4
gpt4 key购买 nike

我正在尝试启用 MultiDex。我添加了 multiDexEnabled truecompile 'com.android.support:multidex:1.0.3'构建.gradle。我做了一个java文件

public class ApplicationClass extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this); // <----------
}
}

并添加了android:name=".ApplicationClass" list 文件。

但是在java文件中,在MultiDex.install(this); MultiDex 部分是红色的,上面写着 Cannot resolve symbol 'MultiDex' .并且 gradle 同步失败。我也尝试添加 android:name="android.support.multidex.MultiDexApplication"显示,而不是创建 java 文件和扩展应用程序类。它也没有用。零件MultiDexApplication是红色的,上面写着unresolved class 'MultiDexApplication'

我认为我系统中的 android 支持库有问题。 Multidex 来自这个库。此外,当我更改任何 'com.android.support:appcompat-v7:26.+' 时(到 Android Studio 建议的特定版本 26.0.1)或 'com.android.support.constraint:constraint-layout:1.0.2' (到较新的版本 1.1.2),gradle sync 失败。

我调查了 <SDK>/extras目录。我看到有三个不同的支持目录。不确定这是否与问题有关。

enter image description here

构建.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.vvaezian.multilingovocabularypractice"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true <--- added ---
}
buildTypes {
debug {
buildConfigField 'String', "ApiKey", MultiLingo_ApiKey
}
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'String', "ApiKey", MultiLingo_ApiKey
}
}

packagingOptions {
exclude 'project.properties'
exclude 'META-INF/INDEX.LIST'
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.mcxiaoke.volley:library:1.0.19'
testImplementation 'junit:junit:4.12'

implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.okhttp3:okhttp:3.8.0'

implementation('com.google.cloud:google-cloud-translate:1.3.1') {
exclude group: 'org.apache.httpcomponents'
exclude group: 'org.json', module: 'json'
}
annotationProcessor 'com.google.cloud:google-cloud-translate:1.3.1'
compile 'com.android.support:multidex:1.0.3' // <----- added ----
// using 'implementation' instead of 'compile' didn't resolve the issue
}

日志文件也没有说明 gradle sync 失败的原因。只有一行写着 Too many events posted ...

2018-08-01 13:56:54,922 [e-1024-b01]   INFO - e.project.sync.GradleSyncState - Started sync with Gradle for project 'MultiLingoVocabularyPractice'. 
2018-08-01 13:56:54,924 [e-1024-b01] INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender activation event: SYNC_STARTED
2018-08-01 13:56:54,924 [e-1024-b01] INFO - idea.project.IndexingSuspender - Starting batch update for project: Project '/local-scratch/vvaezian/AndroidStudioProjects/MultiLingoVocabularyPractice' MultiLingoVocabularyPractice
2018-08-01 13:56:54,934 [hread 1914] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /local-scratch/vvaezian/android-studio/jre
2018-08-01 13:56:54,935 [hread 1914] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /local-scratch/vvaezian/android-studio/jre
2018-08-01 13:56:54,943 [hread 1914] INFO - xecution.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: -Didea.version=3.1 -Djava.awt.headless=true -Pandroid.injected.build.model.only=true -Pandroid.injected.build.model.only.advanced=true -Pandroid.injected.invoked.from.ide=true -Pandroid.injected.build.model.only.versioned=3 -Pandroid.injected.studio.version=3.1.3.0 -Pandroid.builder.sdkDownload=false --init-script /tmp/ijinit.gradle
2018-08-01 13:56:57,640 [hread 1916] INFO - agnostic.FrequentEventDetector - Too many events posted, #7. Event: java.awt.event.InvocationEvent[INVOCATION_DEFAULT,runnable=LaterInvocator.FlushQueue,notifier=null,catchExceptions=false,when=1533157017640] on sun.awt.X11.XToolkit@5b185819
2018-08-01 13:56:57,676 [hread 1914] INFO - e.project.sync.GradleSyncState - Started setup of project 'MultiLingoVocabularyPractice'.
2018-08-01 13:56:57,677 [e-1024-b01] INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender activation event: SETUP_STARTED
2018-08-01 13:56:57,789 [hread 1916] INFO - idea.project.IndexingSuspender - Indexing suspended (context: Project Setup)
2018-08-01 13:56:57,995 [e-1024-b01] INFO - ule.android.SdkModuleSetupStep - Set Android SDK 'Android API 26 Platform (1)' (/local-scratch/vvaezian/SDK) to module 'app'
2018-08-01 13:56:58,005 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/build-tools/26.0.1/package.xml
2018-08-01 13:56:58,009 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/build-tools/27.0.3/package.xml
2018-08-01 13:56:58,012 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/emulator/package.xml
2018-08-01 13:56:58,016 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/extras/android/m2repository/package.xml
2018-08-01 13:56:58,020 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/extras/google/m2repository/package.xml
2018-08-01 13:56:58,024 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/extras/m2repository/com/android/support/constraint/constraint-layout-solver/1.0.2/package.xml
2018-08-01 13:56:58,028 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/extras/m2repository/com/android/support/constraint/constraint-layout/1.0.2/package.xml
2018-08-01 13:56:58,032 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/patcher/v4/package.xml
2018-08-01 13:56:58,035 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/platform-tools/package.xml
2018-08-01 13:56:58,039 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/platforms/android-23/package.xml
2018-08-01 13:56:58,042 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/platforms/android-24/package.xml
2018-08-01 13:56:58,045 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/platforms/android-25/package.xml
2018-08-01 13:56:58,049 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/platforms/android-26/package.xml
2018-08-01 13:56:58,053 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/sources/android-26/package.xml
2018-08-01 13:56:58,056 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/system-images/android-24/google_apis_playstore/x86/package.xml
2018-08-01 13:56:58,060 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/system-images/android-26/google_apis/x86/package.xml
2018-08-01 13:56:58,063 [hread 1917] INFO - s.RepoProgressIndicatorAdapter - Parsing /local-scratch/vvaezian/SDK/tools/package.xml
2018-08-01 13:56:58,118 [hread 1914] INFO - e.project.sync.GradleSyncState - Gradle sync failed (3s 196ms)
2018-08-01 13:56:58,120 [e-1024-b01] INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender deactivation event: SYNC_FINISHED
2018-08-01 13:56:58,120 [e-1024-b01] INFO - idea.project.IndexingSuspender - Finishing batch update for project: Project '/local-scratch/vvaezian/AndroidStudioProjects/MultiLingoVocabularyPractice' MultiLingoVocabularyPractice
2018-08-01 13:56:58,150 [e-1024-b01] INFO - pl.ProjectRootManagerComponent - project roots have changed
2018-08-01 13:56:58,169 [hread 1916] INFO - idea.project.IndexingSuspender - Indexing released (context: Project Setup)
2018-08-01 13:56:58,199 [hread 1916] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 2ms; general responsiveness: ok; EDT responsiveness: ok
2018-08-01 13:56:58,254 [hread 1916] INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 55ms; general responsiveness: ok; EDT responsiveness: ok
2018-08-01 13:56:58,303 [hread 1916] INFO - #com.jetbrains.cidr.lang - Clearing symbols finished in 0 s.
2018-08-01 13:56:58,304 [hread 1916] INFO - #com.jetbrains.cidr.lang - Building symbols in FAST mode, 0 source files from total 0 project files
2018-08-01 13:56:58,305 [hread 1916] INFO - #com.jetbrains.cidr.lang - Loading Module Maps finished in 0 s.
2018-08-01 13:56:58,305 [hread 1916] INFO - #com.jetbrains.cidr.lang - Saving Module Maps finished in 0 s.
2018-08-01 13:56:58,305 [hread 1916] INFO - #com.jetbrains.cidr.lang - Saving Module Maps finished in 0 s.
2018-08-01 13:56:58,305 [hread 1916] INFO - #com.jetbrains.cidr.lang - Loaded 0 tables for 0 files (0 project files)
2018-08-01 13:56:58,305 [hread 1916] INFO - #com.jetbrains.cidr.lang - Building symbols for 0 source files
2018-08-01 13:56:58,306 [hread 1916] INFO - #com.jetbrains.cidr.lang - Building symbols for 0 unused headers
2018-08-01 13:56:58,307 [hread 1916] INFO - #com.jetbrains.cidr.lang - Building symbols finished in 0 s.
2018-08-01 13:56:58,307 [hread 1916] INFO - #com.jetbrains.cidr.lang - Saving modified symbols for 0 files (0 tables of total 0)
2018-08-01 13:56:58,307 [hread 1916] INFO - #com.jetbrains.cidr.lang - Saving symbols finished in 0 s.

最佳答案

    MultiDex.install(this); 

在应用程序中删除了这一行enter code here

关于android - 无法解析符号 'MultiDex',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51622042/

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