tangxiaolv / android-easy-multidex Goto Github PK
View Code? Open in Web Editor NEW[Deprecated] Android,multidex,splitdex,分包插件
[Deprecated] Android,multidex,splitdex,分包插件
一开始加入了9个-just activity 可以正确分包
后来又加入了2个activity 这两个activity就不能被加入maindex
按照demo设置后,发现没有任何一点效果。然后fetch 下来demo,发现demo自己也不会分多dex。。。。
在实际运用中,打包后在4.2.2模拟器上运行,出现如下错误,是不是说明相关依赖没有在第一个main dex中呢,这里是极光推送的相关依赖。
thma E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at cn.jpush.android.b.a(Unknown Source)
at cn.jpush.android.b.a(Unknown Source)
at cn.jpush.android.api.JPushInterface.init(Unknown Source)
at com.ibreathcare.asthma.MyApplication.init(MyApplication.java:82)
at com.ibreathcare.asthma.MyApplication.onCreate(MyApplication.java:65)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1000)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4391)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
can you provide english documentation ?
README.EN.md
在酷派9190L android 4.3的系统上,报找不到MainActivity错误!小米5正常使用。
四大组件不会默认打到 MainDex,也不需要,除非你有特殊操作,需要在 MultiDex install 之前操作,需要 keep
Hi,
My Android app crashes when it is installed from Play store while launching but when i launch the same app directly from the device, it is not crashing. So i am Assume that it will be the MultiDex issue. i am developing the games in ActionScript language so how to use MultiDex Enabled in ActionScript .
please suggest me solution as soon as possible.
已经按照教程的配置了,
编译的时候console输出
DexKnife Processing ...
DexKnife Config: -just activity com.ctv.ui.splash.splashactivity
DexKnife Config: -keep com.ctv.sdk.**
DexKnife Config: -split .
DexKnife Config: -donot-use-suggest
DexKnife-From MergedJar: /home/alex/AndroidStudioProjects/ctv/app/build/intermediates/transforms/jarMerging/debug/jars/1/1f/combined.jar
:app:genMainDexList
DexKnife: From Merged Jar: /home/alex/AndroidStudioProjects/ctv/app/build/intermediates/transforms/jarMerging/debug/jars/1/1f/combined.jar
DexKnife Finished: 17ms
为毛还是只有一个dex, 8.3mb....
gradle插件1.5.0以后写起来比较的麻烦。所以想着直接使用multiDexKeepFile
,但是multiDexKeepFile
不会导致分dex,是哪里有问题吗? 使用DexKnifePlugin是OK的。
multiDexEnabled true
multiDexKeepFile file('maindexlist.txt')
#为注释符
#-----------主Dex中必要依赖的脚本配置-----------
#默认保留四大组件中其他三大组件,Activity组件选择性保留(使用-just activity 选项),若为空默认保留所有Activity
#-just activity com.ceabie.demo.MainActivity
#-----------附加类-----------
-keep com.ezviz.**
#-keep android.support.v7.app.AppCompatDialogFragment.class
#android.support.v?.**
#将全部类移出主Dex
-split com.juziwl.xiaoxin.view.**
-split com.juziwl.model.**
#-donot-use-suggest
#-dex-param --set-max-idx-number=4000
#-auto-maindex
#-log-mainlist
我配置了感觉并没有将类移除主包主包还是很大!!!
DexKnife Processing ...
DexKnife Adt Main: null
DexKnife Config: -dex-param --set-max-idx-number=4000
DexKnife Config: -auto-maindex
DexKnife Config: -log-mainlist
DexKnife Warning: NO SET split Or keep path, it will use Suggest!
DexKnife-From MergedJar: null
DexKnife Error: jarMerging is Null! Skip DexKnife. Please report All Gradle Log.
DexKnife Finished: 7ms
在targetSDK=23的时候,dexknife配置项中keep不生效,试了降到19后正常。是分包跟使用的target版本有什么关系吗
使用這個插件,主包的大小降下來了,1.5mb左右,但是第二個包卻有7mb, 如何保證每個包小於4mb?因爲要兼容android 2.x, 所以也就是是否可以生成第三個包?
-just activity com.ceabie.demo.MainActivity
这个是指
还是-just activity(选项不写)?用来保留所有的Activity?
-split .
上面这个选项是不是不包括四大组件?它跟下面一条有冲突吗?
这个日志是在哪里显示?
如果是有多个依赖module是不是在主app中使用?
谢谢!
我现在的项目有三个dex,按照dexknife的配置,只能明确指定一个类在主dex,而其他的类会随机分配在dex2和dex3中,大神这个项目能够增加明确指定某些类只分配在某一个dex(非主dex)中功能吗?
我已经写了-just activity asia.bluepay.best.pay.MainActivity,关闭了instant run,gradle版本是2.1.0,在坚果1上测试MainActivity没有打进主dex包中,如果单保留MainActivity.class,MainActivity中的内部类找不到
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.ceabie.dextools:gradle-dexknife-plugin:2.0.1'
instant run关掉了
如题,具体来说我目前是用了4.2.2来测,似乎没有自动载入secondary dex,需要手动载入吗?求指教!
我改了text中文本但是主dex大小并没有变 这个文件是放在 src目录下和main文件平级吗?
配置后报错
`DexKnife Processing ...
DexKnife Config: -keep com.efangtec.efang.**
DexKnife Config: -donot-use-suggest
DexKnife Config: -auto-maindex
:app:genMainDexList
DexKnife: From Merged Jar: null
DexKnife: The Merged Jar is not exist! Can't be processed!
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
DexKnife Warnning: Main dex is EMPTY ! Check your config and project!`
-just activity不起作用
请问,这个问题如何解决?
build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'dexknifePlus'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.juziwl.ixiao"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dexKnife{
//必选参数
enabled true //if false,禁用分包插件
//可选参数
//1.如果没有可选参数,将根据enabled决定是否分包。
//2.如果有可选参数,需满足必选参数和可选参数的条件才允许分包
productFlavor 'mock'
buildType 'debug'
/*
*eg:当前productFlavors = dev,buildType = debug,
*参数组合1:enabled = true,productFlavor = dev,buildType = debug 分包
*参数组合2:enabled = true,productFlavor = mock,buildType = debug 不分包
*参数组合1:enabled = true,buildType = debug 所有buildType = debug分包
*参数组合1:enabled = true,productFlavor = dev 所有productFlavor = dev分包
* */
}
dexknife.txt
#为注释符
#-----------主Dex中必要依赖的脚本配置-----------
#默认保留四大组件中其他三大组件(并计算其依赖树),Activity组件选择性保留(使用-just activity 选项),若为空不保留任何Activity
-just activity com.juziwl.ixiao.main.MainActivity
#-----------附加类-----------
#-keep com.ceabie.demo.**
#-keep android.support.v7.app.AppCompatDialogFragment.class
#-split android.support.v?.**
#将全部类移出主Dex
-split .
#-donot-use-suggest
-dex-param --set-max-idx-number=3000
#-auto-maindex
打包的时候还报了一些错,但是打包成功了
Information:Gradle tasks [:emojitest:assembleDebug, :ixiao:assembleDebug]
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.squareup.haha.guava.base.Joiner$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is not an inner class.
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.squareup.haha.guava.collect.Iterables$2) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is not an inner class.
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.squareup.haha.guava.collect.Iterables$3) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is not an inner class.
Information:BUILD SUCCESSFUL
Information:Total time: 43.909 secs
Information:24 errors
Information:0 warnings
Information:See complete output in console
我生成class.dex文件有27928个方法,我现在就想分包,请问怎么写?还有上面的问题是什么原因造成的?
大佬们,请问下你们这个maindexlist怎么生成的
Error:Could not find com.ceabie.dextools:gradle-dexknife-plugin:2.0.1. Searched in the following locations: file:/Applications/Android Studio2.2.app/Contents/gradle/m2repository/com/ceabie/dextools/gradle-dexknife-plugin/2.0.1/gradle-dexknife-plugin-2.0.1.pom file:/Applications/Android Studio2.2.app/Contents/gradle/m2repository/com/ceabie/dextools/gradle-dexknife-plugin/2.0.1/gradle-dexknife-plugin-2.0.1.jar https://jcenter.bintray.com/com/ceabie/dextools/gradle-dexknife-plugin/2.0.1/gradle-dexknife-plugin-2.0.1.pom https://jcenter.bintray.com/com/ceabie/dextools/gradle-dexknife-plugin/2.0.1/gradle-dexknife-plugin-2.0.1.jar file:/Users/allen/AndroidStudioProjects/juyoulicai_android_app/repo/com/ceabie/dextools/gradle-dexknife-plugin/2.0.1/gradle-dexknife-plugin-2.0.1.pom file:/Users/allen/AndroidStudioProjects/juyoulicai_android_app/repo/com/ceabie/dextools/gradle-dexknife-plugin/2.0.1/gradle-dexknife-plugin-2.0.1.jar Required by: :juyoulicai_android_app:unspecified
直接用了您的那段引用 : compile 'com.android.support:MultiDex:1.0.1'
一直报错,后来才发现 compile 'com.android.support:multidex:1.0.1' 全是小写字母。
如题。我该怎么设置?
友盟中的类无法找到 我没有做混淆如将分包插件关闭可以正常启动应用这个是怎么回事呢
Could not find class 'com.taobao.accs.utl.h$a', referenced from method com.taobao.accs.internal.ACCSManagerImpl.bindApp Could not find class 'com.ut.mini.internal.UTOriginalCustomHitBuilder', referenced from method com.taobao.accs.utl.UTMini.commitEvent
环信也报错
'com.hyphenate.chat.EMCallManager', referenced from method com.hyphenate.chat.EMClient.callManager
DexKnife Processing ...
:NewTravelGuide_main:transformClassesWithDexForDevDebug FAILED
FAILURE: Build failed with an exception.
Cannot cast object 'com.tencent.tinker.build.gradle.transform.ImmutableDexTransform@5dd422d6' with class 'com.tencent.tinker.build.gradle.transform.ImmutableDexTransform' to class 'com.android.build.gradle.internal.transforms.DexTransform'
private static void filterActivity(Project project) { File file = project.file(DexSplitTools.DEX_KNIFE_CFG_TXT) if (file != null) { def justActivitys = []; file.eachLine { line -> //printf "read line ${line}\n"; if (line.startsWith('-just activity')) { line = line.replaceAll('-just activity', '').trim(); justActivitys.add(line) } } printf "-just activity size = ${justActivitys.size()}\n"; if (justActivitys.size() != 0) { project.tasks.each { task -> if (task.name.startsWith('collect') && task.name.endsWith('MultiDexComponents')) { println "main-dex-filter: found task $task.name" task.filter { name, attrs -> String componentName = attrs.get('android:name') if ('activity'.equals(name)) { def result = justActivitys.find { componentName.endsWith("${it}") } def bool = result != null; if (bool) { printf "main-dex-filter: keep ${componentName}\n" } return bool } return true } } } } } }
在gradle2.2.3中没有collectReleaseMultiDexComponents
有木有考虑将dex进行异步加载来解决ANR的问题
我的点击图标后的界面是一个登录界面,发现无数bug,就是说方法未找到,次级依赖(2,3,4级依赖)都没有放入主dex
08-29 17:21:17.634 31325-31325/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: xx, PID: 31325
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{xx/xxx.SplashActivity}: java.lang.ClassNotFoundException: Didn't find class "xxx.SplashActivity" on path: DexPathList[[zip file "/data/app/xx-1/base.apk"],nativeLibraryDirectories=[/data/app/xx-1/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2252)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2403)
at android.app.ActivityThread.access$800(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5298)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:910)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:705)
Caused by: java.lang.ClassNotFoundException: Didn't find class "cn.v6.sixrooms.ui.phone.SplashActivity" on path: DexPathList[[zip file "/data/app/xx-1/base.apk"],nativeLibraryDirectories=[/data/app/xx-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2242)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2403)
at android.app.ActivityThread.access$800(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5298)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:910)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:705)
Suppressed: java.lang.NoClassDefFoundError: xxx..SplashActivity
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 14 more
Suppressed: java.lang.ClassNotFoundException: xxx..SplashActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
as已发布正式版3.0,请求支持!
怎么解决额? 项目马上要上线了 这个问题怎么解决额? 求帮助额
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.