Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

混淆后无法运行 #85

Closed
eaglelzy opened this issue Mar 30, 2016 · 5 comments
Closed

混淆后无法运行 #85

eaglelzy opened this issue Mar 30, 2016 · 5 comments

Comments

@eaglelzy
Copy link

我导入demo可以正常运行,但是在宿主工程打开混淆开关后,就无法运行了,请问混淆要注意什么吗?

buildTypes {
        debug {
            minifyEnabled true
            signingConfig signingConfigs.debug
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled true
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

运行后的异常日志:

03-30 16:43:33.300 20400-20400/net.wequick.example.small E/AndroidRuntime: FATAL EXCEPTION: main
    Process: net.wequick.example.small, PID: 20400
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{net.wequick.example.small/net.wequick.small.A}: java.lang.ClassNotFoundException: Didn't find class "net.wequick.example.small.app.main.MainActivity" on path: DexPathList[[zip file "/data/data/net.wequick.example.small/lib/libnet_wequick_example_small_app_detail.so", zip file "/data/data/net.wequick.example.small/lib/libnet_wequick_example_small_app_mine.so", zip file "/data/data/net.wequick.example.small/lib/libnet_wequick_example_small_app_home.so", zip file "/data/data/net.wequick.example.small/lib/libnet_wequick_example_small_app_main.so", zip file "/data/data/net.wequick.example.small/lib/libcom_example_mysmall_lib_style.so", zip file "/data/data/net.wequick.example.small/lib/libnet_wequick_example_small_lib_utils.so", zip file "/data/app/net.wequick.example.small-2/base.apk"],nativeLibraryDirectories=[/data/app/net.wequick.example.small-2/lib/arm, /vendor/lib, /system/lib]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2225)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
        at android.app.ActivityThread.access$800(ActivityThread.java:148)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5310)
        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:901)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "net.wequick.example.small.app.main.MainActivity" on path: DexPathList[[zip file "/data/data/net.wequick.example.small/lib/libnet_wequick_example_small_app_detail.so", zip file "/data/data/net.wequick.example.small/lib/libnet_wequick_example_small_app_mine.so", zip file "/data/data/net.wequick.example.small/lib/libnet_wequick_example_small_app_home.so", zip file "/data/data/net.wequick.example.small/lib/libnet_wequick_example_small_app_main.so", zip file "/data/data/net.wequick.example.small/lib/libcom_example_mysmall_lib_style.so", zip file "/data/data/net.wequick.example.small/lib/libnet_wequick_example_small_lib_utils.so", zip file "/data/app/net.wequick.example.small-2/base.apk"],nativeLibraryDirectories=[/data/app/net.wequick.example.small-2/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:1088)
        at net.wequick.small.ApkBundleLauncher$InstrumentationWrapper.newActivity(Unknown Source)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386) 
        at android.app.ActivityThread.access$800(ActivityThread.java:148) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:135) 
        at android.app.ActivityThread.main(ActivityThread.java:5310) 
        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:901) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696) 
        Suppressed: java.lang.NoClassDefFoundError: net.wequick.example.small.app.main.MainActivity
        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)
                ... 15 more
        Suppressed: java.lang.ClassNotFoundException: net.wequick.example.small.app.main.MainActivity
        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)
                ... 14 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
@galenlin
Copy link
Member

galenlin commented Apr 3, 2016

确认问题,安排在近期解决。

@galenlin
Copy link
Member

已支持宿主代码混淆,请更新最新代码,配置混淆如Sample/app/proguard-rules.pro

# Support Libraries
-dontwarn android.support.**
-keep class android.support.** { *; }
-keep interface android.support.** { *; }

# Small
-keep class net.wequick.small.Small { public *; }
-keep interface net.wequick.small.** { *; }

@a137235
Copy link

a137235 commented May 18, 2016

为了解构我们一般都很少将代码放到宿主中,所以支持宿主混淆作用不大.插件混淆基本没法使用,lib使用混淆直接报错,而app会将一些公共库重新打包到自己.混淆是减少体积和提高安全性,能不能实现呢?

@galenlin
Copy link
Member

因为我们要从插件中分离出公共代码,如果要支持混淆,会很麻烦:

  1. 混淆时需要所有的类参与,意味着不能前期分离
  2. 混淆后包名、类(文件)名面目全非,甚至会额外抽取出一些额外的类(文件),意味着后期也很难分离

所以这个活很细呀,思路虽然有,但是具体操作起来恐怕没有那么顺利,需要时间。

@galenlin
Copy link
Member

gradle-small:0.9.0 已支持混淆,关闭本问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants