标签: android-multidex

API 19上的Android Gradle Multidex Build问题

我有一个项目,我已经启用multidex了避免65k limit,并且productFlavors(开发API 21和prod API 19)进行自定义.建立我的项目API 21即开发风味是成功的,但在API 19prod风味,它不断给我在应用程序任务中的例外shrink{component}MultiDexComponents

完整错误日志:

:app:shrinkProdDebugMultiDexComponents FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:shrinkProdDebugMultiDexComponents'.
> java.io.IOException: Can't read [{Project Path}/app/build/intermediates/multi-dex/prod/debug/allclasses.jar] (Can't process class [com/olivephone/office/a/b/e/p.class] (Unknown verification type [17] in stack map frame))
Run Code Online (Sandbox Code Playgroud)

的build.gradle

apply plugin: 'com.android.application'

android {  
    compileSdkVersion 23  
    buildToolsVersion '23.0.0'  
    defaultConfig {  
        applicationId '{Project Name}'  
        minSdkVersion 15  
        targetSdkVersion 23  
        versionCode 1  
        versionName "1.0"  
        multiDexEnabled true  
    } …
Run Code Online (Sandbox Code Playgroud)

android android-multidex

11
推荐指数
2
解决办法
1万
查看次数

太多的字段引用:70613; 最大值是65536

我的项目使用这些插件:

  • OneSignal
  • GooglePlayServices
  • 调整
  • 谷歌分析
  • Unity IAP
  • Facebook SDK

几乎每个项目都使用这些插件.

但我超过现场参考计数

这是我的.aar文件列表 名单

我该怎么做才能减少参考数量?

android unity-game-engine android-multidex

11
推荐指数
2
解决办法
2万
查看次数

Android Studio 3.0上的com.android.dex.DexIndexOverflowException

我有一个用于Espresso测试的库,当我添加到我的项目时,我无法编译我的测试.

Gradle输出此错误

Caused by: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
    at com.android.dx.merge.DexMerger$8.updateIndex(DexMerger.java:565)
    at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
    at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:574)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:166)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
Run Code Online (Sandbox Code Playgroud)

这真的很奇怪,因为我已经在我的项目中启用了multiDex

我的项目build.gradle

defaultConfig {
            minSdkVersion 16
            targetSdkVersion 21
            versionName versionNameFromGitTagVia()
            versionCode versionCodeFromJenkins()
            multiDexEnabled true

            testInstrumentationRunner "app.test.general.InstrumentationRunner" ...
}
dependencies {
    ...
    androidTestImplementation project(':test-utils')
    ...
    implementation 'com.android.support:multidex:1.0.2'
}
Run Code Online (Sandbox Code Playgroud)

我的应用类

public class RiderApplication extends MultiDexApplication implements Application.ActivityLifecycleCallbacks,
        GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
  ....
}
Run Code Online (Sandbox Code Playgroud)

AndroidManifest

<application
    android:name=".RiderApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/MyAppTheme"
    tools:replace="android:theme,android:icon">
Run Code Online (Sandbox Code Playgroud)

删除库可以解决问题

有什么建议?

编辑 我尝试用几种方法解决它,我发现只有当我将库包含在内时才会发生这种情况

androidTestImplementation
Run Code Online (Sandbox Code Playgroud)

但是当作为常规使用时

implementation
Run Code Online (Sandbox Code Playgroud)

dex错误消失了

真奇怪 …

android android-multidex

11
推荐指数
1
解决办法
889
查看次数

找不到AndroidX MultiDex

我正在创建一个新的android项目,并决定将新的AndroidX替换为支持库,有关支持的文档,请参见:https : //developer.android.com/jetpack/androidx/migrate

我按照字母的步骤进行操作,并在同步gradle之后,可以访问androidx名称空间和其中包含的各种类。但是,在创建我的应用程序类时,我想从中继承androidx.multidex.MultiDexApplication(可以在上面的链接的表中看到)。但是,整个multidex软件包不存在。

有人解决了这个问题吗?有指针吗?

android android-multidex androidx

11
推荐指数
2
解决办法
5901
查看次数

Android应用程序首次启动启动需要花费更多时间甚至30秒甚至更长时间

以下是应用首次安装时的日志:

05-12 13:16:23.632 28250-28250/com.app.projectName W/System:ClassLoader引用未知路径:/data/app/com.app.projectName-1/lib/arm 05-12 13:16:59.041 28250-28250/com.app.projectName W/System:ClassLoader引用未知路径:/data/app/com.app.projectName-1/lib/arm 05-12 13:16:59.073 28250-28250/com.app. projectName I/MultiDex:版本2.1.0的VM具有multidex支持05-12 13:16:59.073 28250-28250/com.app.projectName I/MultiDex:install 05-12 13:16:59.073 28250-28250/com. app.projectName I/MultiDex:VM具有multidex支持,MultiDex支持库被禁用.

MultiDex在我的项目中使用库它将完全在棒棒糖前设备下工作.这种延迟在Lollipop设备中在第一次应用启动时在30秒到90秒之间变化.

看它不是由于MultiDex对吗?因为时间是1.)初始化05-12 13:16:23.632,第二次登录是在36秒之后,即05-12 13:16:59.041

那个东西创建ClassLoader引用的app延迟.... MultiDex正在快速初始化.以下是截图在此输入图像描述 这需要15秒到30秒,有时甚至更长.

我的Gradle文件是:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'

compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.bignerdranch.android:expandablerecyclerview:2.1.1'
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
compile 'org.apache.httpcomponents:httpcore:4.2.4'
compile 'org.apache.httpcomponents:httpmime:4.3'
compile 'com.google.code.gson:gson:2.5'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile 'com.squareup.okhttp3:logging-interceptor:3.1.2'
compile 'co.lujun:androidtagview:1.0.2'

compile …
Run Code Online (Sandbox Code Playgroud)

android delay android-multidex

10
推荐指数
1
解决办法
3904
查看次数

.dex文件中的方法引用数超过64K

目前我的Android应用程序在我的项目中包含播放服务和firebase库后我正在收到此错误并且无法运行我的代码

:app:prePackageMarkerForDebug:app:transformClassesWithDexForDebug要在进程中运行dex,Gradle守护程序需要更大的堆.它目前有大约910 MB.要加快构建速度,请将Gradle守护程序的最大堆大小增加到2048 MB以上.为此,请在项目gradle.properties中设置org.gradle.jvmargs = -Xmx2048M.有关详细信息,请参阅https://docs.gradle.org/current/userguide/build_environment.html 错误:.dex文件中的方法引用数不能超过64K.在https://developer.android.com/tools/building/multidex.html上了解如何解决此问题 :app:transformClassesWithDexForDebug FAILED错误:任务':app:transformClassesWithDexForDebug'的执行失败.com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:org.gradle.process. internal.ExecException:进程'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java''以非零退出值2结束

我的build.gradle文件在这里:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "xyz.in.network"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        shrinkResources true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        multiDexEnabled true
    }
}
}

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   testCompile 'junit:junit:4.12'
   compile project(':libs:ViewPagerIndicator')
   compile 'com.google.android.gms:play-services:9.0.0'
   compile 'com.android.support:appcompat-v7:23.4.0'
   compile 'com.android.support:design:23.4.0'
   compile 'com.google.android.gms:play-services-maps:9.0.0'
   compile 'com.google.android.gms:play-services-location:9.0.0'
   compile 'com.android.support:cardview-v7:23.4.0'
   compile 'com.getbase:floatingactionbutton:1.10.1'
   compile 'com.squareup.picasso:picasso:2.5.2'
   compile …
Run Code Online (Sandbox Code Playgroud)

heap android dex android-multidex

10
推荐指数
2
解决办法
1万
查看次数

Android多个dex文件定义Lcom/google/android/gms/common/api/zza

构建项目并将应用程序部署到具有API级别22或25的模拟器可以,但是当我尝试构建APK或将应用程序部署到具有API级别16的真实设备时,我收到以下错误:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zza;
Run Code Online (Sandbox Code Playgroud)

我的项目build.gradle文件:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'me.tatarka:gradle-retrolambda:3.3.0-beta4'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

我的app build.gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "<aplication id here>"
        minSdkVersion 16 …
Run Code Online (Sandbox Code Playgroud)

android build firebase android-gradle-plugin android-multidex

10
推荐指数
1
解决办法
7978
查看次数

Android MultiDex - 关于内部工作的问题

我最近发现了Android的新MultiDex功能,用于处理超过65,000个引用的应用程序.请参阅:https://developer.android.com/tools/building/multidex.html

有人可以帮我理解以下问题:

1)Gradle构建插件如何确定主要dex文件(classes.dex)与次要dex文件的放置内容?基于该文档,在主要dex中需要某些东西,但它没有给出任何示例.是否所有活动都必须在主要dex文件中?

引用文字:

在Dalvik运行时执行时,主要dex文件中需要哪些类有复杂的要求.Android构建工具更新处理Android需求,但其他包含的库可能还有其他依赖性要求,包括使用内省或从本机代码调用Java方法.在更新multidex构建工具之前,可能无法使用某些库,以允许您指定必须包含在主dex文件中的类.

2)仅针对Android API Level 21(Android L)及更高版本构建时,Gradle Build Plugin中存在不同的行为.它说它更快,因为它"将应用程序的每个模块(包括依赖项)构建为单独的dex文件.这通常被称为预先dexing." Android中模块的定义是什么?这是这里提到的Java库,Android库和Android应用程序模块:http://developer.android.com/sdk/installing/studio-build.html#projectModules?远程或本地二进制依赖项(例如:Jars)是否计为单独的模块,因此可以放入不同的dex文件中,还是根据它们包含在模块中?

android android-build android-activity android-gradle-plugin android-multidex

9
推荐指数
2
解决办法
3080
查看次数

带有multidex的Xamarin Android - 调试模式下的bug

我创建了Xamarin Forms应用程序.我使用Android的multidex(许多库).我使用带有MultiDexMainDexList选项的multidex.keep文件.现在部署工作.但是我在调​​试模式下遇到异常:

 System.ArgumentException: The offset and length have exceeded the bounds of the array or the counter value exceeds the number of elements from the pointer to the end of the original collection.
 ? System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)
 ? Mono.Cecil.Metadata.GuidHeap.Read(UInt32 index)
 ? Mono.Cecil.MetadataReader.InitializeCustomDebugInformations()
 ? Mono.Cecil.MetadataReader.GetCustomDebugInformation(ICustomDebugInformationProvider provider)
? Mono.Cecil.Cil.PortablePdbReader.Read(MethodDefinition method)
? Mono.Cecil.Cil.CodeReader.ReadMethodBody()
? Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
? Mono.Cecil.MethodDefinition.<>c.<get_Body>b__41_0(MethodDefinition method, MetadataReader reader)
? Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func`3 read)
? Mono.Cecil.MethodDefinition.get_Body()
 Mono.Cecil.MethodDefinition.get_DebugInformation()
? Mono.Debugging.Soft.SoftDebuggerSession.LoadPdbType(TypeDefinition type, Dictionary`2 fileToSourceFileInfos) …
Run Code Online (Sandbox Code Playgroud)

android xamarin.android dex xamarin.forms android-multidex

9
推荐指数
1
解决办法
232
查看次数

E/LoadedApk:无法仅在 Android Q (API 29) 上实例化 appComponentFactory

我已经到处搜索了这个问题,但仍然没有解决方案。

gradle 有 minSdkVersion 21 和 targetSdkVersion 29

我只在 API 29 中遇到错误,然后应用程序无法加载并显示空白屏幕。当我看到 logcat 它给出了这样的错误:

E/LoadedApk: Unable to instantiate appComponentFactory
java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.CoreComponentFactory" on path: DexPathList[[],nativeLibraryDirectories=[/data/app/com.packagename.appname-BxS7Zs-h0IWwJAVhbjx7aQ==/lib/x86, /data/app/com.packagename.appname-BxS7Zs-h0IWwJAVhbjx7aQ==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.app.LoadedApk.createAppFactory(LoadedApk.java:256)
    at android.app.LoadedApk.updateApplicationInfo(LoadedApk.java:370)
    at android.app.ActivityThread.handleDispatchPackageBroadcast(ActivityThread.java:5951)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1941)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at com.android.server.SystemServer.run(SystemServer.java:541)
    at com.android.server.SystemServer.main(SystemServer.java:349)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:908)
Run Code Online (Sandbox Code Playgroud)

我认为它似乎来自 multidex,然后我尝试将以下代码添加到 gradle app

multiDexKeepFile 文件('multidex-config.txt')

multiDexKeepProguard 文件('multidex-config.pro')

我的 multidex-config.txt

com/packagename/appname/androidx.class
Run Code Online (Sandbox Code Playgroud)

我的 multidex-config.pro

-keep class androidx.core.app.CoreComponentFactory { *; }
Run Code Online (Sandbox Code Playgroud)

我的 App …

android gradle android-studio android-multidex

9
推荐指数
1
解决办法
1万
查看次数