gpt4 book ai didi

android - 意外的顶级异常 : in Android Studio

转载 作者:行者123 更新时间:2023-11-29 14:30:51 25 4
gpt4 key购买 nike

我知道这里已经被问过太多次了,但我仍然无法解决这个问题。我已经尝试过前面问题中提供的解决方案,但它们无法正常工作。

这是我的 gradle 依赖 -

compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.facebook.android:facebook-android-sdk:3.22.0'
compile project(':IndicatorLib')
compile 'com.makeramen:roundedimageview:1.5.0'
compile 'com.github.clans:fab:1.5.0'
// GMS in the library was causing merging error, we need to exclude the duplicate dependencies
compile ('io.nlopez.smartlocation:library:3.2.0') { exclude group: 'com.google.android.gms'}

这是我的 gradle 依赖输出 -

_releaseApk - ## Internal use, do not manually configure ##
+--- com.google.code.gson:gson:2.3.1
+--- com.android.support:appcompat-v7:23.1.0
| \--- com.android.support:support-v4:23.1.0
| \--- com.android.support:support-annotations:23.1.0
+--- com.google.android.gms:play-services:8.1.0
| +--- com.google.android.gms:play-services-ads:8.1.0
| | +--- com.google.android.gms:play-services-basement:8.1.0
| | | \--- com.android.support:support-v4:22.2.0 -> 23.1.0 (*)
| | \--- com.google.android.gms:play-services-appindexing:8.1.0
| | \--- com.google.android.gms:play-services-basement:8.1.0 (*)
| +--- com.google.android.gms:play-services-analytics:8.1.0
| | +--- com.google.android.gms:play-services-basement:8.1.0 (*)
| | \--- com.google.android.gms:play-services-ads:8.1.0 (*)
| +--- com.google.android.gms:play-services-appindexing:8.1.0 (*)
| +--- com.google.android.gms:play-services-appinvite:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0
| | \--- com.google.android.gms:play-services-basement:8.1.0 (*)
| +--- com.google.android.gms:play-services-appstate:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-basement:8.1.0 (*)
| +--- com.google.android.gms:play-services-cast:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | \--- com.android.support:mediarouter-v7:22.2.0
| | \--- com.android.support:appcompat-v7:22.2.0 -> 23.1.0 (*)
| +--- com.google.android.gms:play-services-drive:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-fitness:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | \--- com.google.android.gms:play-services-location:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | \--- com.google.android.gms:play-services-maps:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-games:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | \--- com.google.android.gms:play-services-drive:8.1.0 (*)
| +--- com.google.android.gms:play-services-gcm:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-identity:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-location:8.1.0 (*)
| +--- com.google.android.gms:play-services-maps:8.1.0 (*)
| +--- com.google.android.gms:play-services-measurement:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | \--- com.google.android.gms:play-services-analytics:8.1.0 (*)
| +--- com.google.android.gms:play-services-nearby:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-panorama:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-plus:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-safetynet:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-vision:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-wallet:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | +--- com.google.android.gms:play-services-identity:8.1.0 (*)
| | \--- com.google.android.gms:play-services-maps:8.1.0 (*)
| \--- com.google.android.gms:play-services-wearable:8.1.0
| \--- com.google.android.gms:play-services-base:8.1.0 (*)
+--- com.facebook.android:facebook-android-sdk:3.22.0
| +--- com.android.support:support-v4:[21,22) -> 23.1.0 (*)
| \--- com.parse.bolts:bolts-android:1.1.4
+--- project :IndicatorLib
| \--- com.android.support:support-v4:21.0.3 -> 23.1.0 (*)
+--- com.makeramen:roundedimageview:1.5.0
+--- com.github.clans:fab:1.5.0
\--- io.nlopez.smartlocation:library:3.2.0
\--- com.android.support:support-annotations:23.0.1 -> 23.1.0

_releaseCompile - ## Internal use, do not manually configure ##
+--- com.google.code.gson:gson:2.3.1
+--- com.android.support:appcompat-v7:23.1.0
| \--- com.android.support:support-v4:23.1.0
| \--- com.android.support:support-annotations:23.1.0
+--- com.google.android.gms:play-services:8.1.0
| +--- com.google.android.gms:play-services-ads:8.1.0
| | +--- com.google.android.gms:play-services-basement:8.1.0
| | | \--- com.android.support:support-v4:22.2.0 -> 23.1.0 (*)
| | \--- com.google.android.gms:play-services-appindexing:8.1.0
| | \--- com.google.android.gms:play-services-basement:8.1.0 (*)
| +--- com.google.android.gms:play-services-analytics:8.1.0
| | +--- com.google.android.gms:play-services-basement:8.1.0 (*)
| | \--- com.google.android.gms:play-services-ads:8.1.0 (*)
| +--- com.google.android.gms:play-services-appindexing:8.1.0 (*)
| +--- com.google.android.gms:play-services-appinvite:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0
| | \--- com.google.android.gms:play-services-basement:8.1.0 (*)
| +--- com.google.android.gms:play-services-appstate:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-basement:8.1.0 (*)
| +--- com.google.android.gms:play-services-cast:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | \--- com.android.support:mediarouter-v7:22.2.0
| | \--- com.android.support:appcompat-v7:22.2.0 -> 23.1.0 (*)
| +--- com.google.android.gms:play-services-drive:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-fitness:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | \--- com.google.android.gms:play-services-location:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | \--- com.google.android.gms:play-services-maps:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-games:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | \--- com.google.android.gms:play-services-drive:8.1.0 (*)
| +--- com.google.android.gms:play-services-gcm:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-identity:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-location:8.1.0 (*)
| +--- com.google.android.gms:play-services-maps:8.1.0 (*)
| +--- com.google.android.gms:play-services-measurement:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | \--- com.google.android.gms:play-services-analytics:8.1.0 (*)
| +--- com.google.android.gms:play-services-nearby:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-panorama:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-plus:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-safetynet:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-vision:8.1.0
| | \--- com.google.android.gms:play-services-base:8.1.0 (*)
| +--- com.google.android.gms:play-services-wallet:8.1.0
| | +--- com.google.android.gms:play-services-base:8.1.0 (*)
| | +--- com.google.android.gms:play-services-identity:8.1.0 (*)
| | \--- com.google.android.gms:play-services-maps:8.1.0 (*)
| \--- com.google.android.gms:play-services-wearable:8.1.0
| \--- com.google.android.gms:play-services-base:8.1.0 (*)
+--- com.facebook.android:facebook-android-sdk:3.22.0
| +--- com.android.support:support-v4:[21,22) -> 23.1.0 (*)
| \--- com.parse.bolts:bolts-android:1.1.4
+--- project :IndicatorLib
| \--- com.android.support:support-v4:21.0.3 -> 23.1.0 (*)
+--- com.makeramen:roundedimageview:1.5.0
+--- com.github.clans:fab:1.5.0
\--- io.nlopez.smartlocation:library:3.2.0
\--- com.android.support:support-annotations:23.0.1 -> 23.1.0

在我看来,smartlocation 库是导致问题的罪魁祸首,因为如果我删除此库,应用程序将正确构建。根据build.gradle在库中,我认为唯一可能发生冲突的是 GMS 库,我为此添加了 exclude 但这也给出了同样的错误。我还能做些什么来解决这个问题?

更新:-

这是错误日志 -

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
F:\Android SDK\build-tools\21.1.2\dx.bat --dex --no-optimize --output F:\Android Projects\Office Projects\Git Synced\new\app\build\intermediates\dex\debug --input-list=F:\Android Projects\Office Projects\Git Synced\new\app\build\intermediates\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java

:215) 在 com.android.dx.command.Main.main(Main.java:106)

最佳答案

该错误表示您的应用程序及其引用的库达到一定大小,您会遇到构建错误,表明您的应用程序已达到 Android 应用程序构建架构的限制。

所以你必须做到MultiDexApplication

部分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'
}

创建一个扩展 MultiDexApplication 的类并在 list 中定义该类

public class CustomMultiDexApplication extends MultiDexApplication {

@Override
public void onCreate() {
super.onCreate();
}
}

list

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
android:name="your.package.name.CustomMultiDexApplication">
</application>
</manifest>

一个提示,support v7 包含support v4,所以不需要添加v4库的依赖。

关于android - 意外的顶级异常 : in Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33438656/

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