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

官方Examples:Sample 启动直接崩了,有log信息:java.lang.RuntimeException: Unable to instantiate activity ComponentInfo #412

Open
1 task done
struggle111 opened this issue Feb 6, 2017 · 10 comments

Comments

@struggle111
Copy link

struggle111 commented Feb 6, 2017

  • 我已阅读并理解 贡献指南,严格遵循其约定。

错误报告

你做了什么?

我下载了官方Examples:Sample,编译正常,当运行安装成功后,启动app,直接闪退,且有log信息;

你期望的结果是什么?

Sample能正常运行且正常启动,正常使用;

实际结果是什么?

Sample启动时闪退,报错信息如下:
...(--stacktrace堆栈,需包含net.wequick.gradle包名下的错误)

Small发送运行报错,报错信息如下:
Process: net.wequick.example.small, PID: 2853
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.small.A" on path: DexPathList[[zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_app_detail.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_appok_if_stub.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_app_mine.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_lib_analytics.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libcom_example_mysmall_lib_style.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_lib_utils.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_app_main.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_app_home.so", zip file "/data/app/net.wequick.example.small-1/base.apk"],nativeLibraryDirectories=[/data/app/net.wequick.example.small-1/lib/arm, /vendor/lib, /system/lib, /data/data/net.wequick.example.small/files/storage/net.wequick.example.small.app.mine/lib/armeabi-v7a]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2291)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2459)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5338)
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:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
Caused by: java.lang.ClassNotFoundException: Didn't find class "net.wequick.small.A" on path: DexPathList[[zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_app_detail.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_appok_if_stub.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_app_mine.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_lib_analytics.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libcom_example_mysmall_lib_style.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_lib_utils.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_app_main.so", zip file "/data/app/net.wequick.example.small-1/lib/arm/libnet_wequick_example_small_app_home.so", zip file "/data/app/net.wequick.example.small-1/base.apk"],nativeLibraryDirectories=[/data/app/net.wequick.example.small-1/lib/arm, /vendor/lib, /system/lib, /data/data/net.wequick.example.small/files/storage/net.wequick.example.small.app.mine/lib/armeabi-v7a]]
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:1073)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2281)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2459) 
at android.app.ActivityThread.access$900(ActivityThread.java:155) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:139) 
at android.app.ActivityThread.main(ActivityThread.java:5338) 
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:950) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745) 
Suppressed: java.lang.ClassNotFoundException: net.wequick.small.A
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
...

Small环境

Compile-time

  gradle-small plugin : 1.1.0-beta4 (project)
            small aar : 1.1.0-alpha1(project)
          gradle core : 2.10
       android plugin : 2.1.2
                   OS : Mac OS X 10.12 (x86_64)

Bundles

Sample 默认
(注:编译时错误只需本行以上内容,运行时错误补充本行以下内容)

Runtime

  Device : OnePlus ONE E1001
     SDK : Android 5.1.1
     ABI : armeabi-v7a, armeabi
@galenlin
Copy link
Member

galenlin commented Feb 6, 2017

你好,请按照首页贡献指南中的issue模板修改下issue

@struggle111
Copy link
Author

感觉是机型的问题,我试了下魅族就可以,一加x就不行了

@galenlin
Copy link
Member

galenlin commented Feb 6, 2017

net.wequick.small.A 是虚拟Activity,正常情况下会被重定向到插件的Activity。

我手头没有这个机型,麻烦协助调试下 net.wequick.small.ApkBundleLauncher#onCreate 方法,看下以下hook是否正常执行:

// Replace instrumentation
try {
    f = thread.getClass().getDeclaredField("mInstrumentation");
    f.setAccessible(true);
    base = (Instrumentation) f.get(thread);
    wrapper = new ApkBundleLauncher.InstrumentationWrapper(base);
    f.set(thread, wrapper);
} catch (Exception e) {
    throw new RuntimeException("Failed to replace instrumentation for thread: " + thread);
}

// Inject message handler
try {
    f = thread.getClass().getDeclaredField("mH");
    f.setAccessible(true);
    Handler ah = (Handler) f.get(thread);
    f = Handler.class.getDeclaredField("mCallback");
    f.setAccessible(true);
    f.set(ah, new ApkBundleLauncher.ActivityThreadHandlerCallback());
} catch (Exception e) {
    throw new RuntimeException("Failed to replace message handler for thread: " + thread);
}

如果已正常替换,再看下以下两个重定向方法是不是都没有走到或者执行异常:

/** @Override V21+
 * Wrap activity from REAL to STUB */
public ActivityResult execStartActivity(
        Context who, IBinder contextThread, IBinder token, Activity target,
        Intent intent, int requestCode, android.os.Bundle options) {
    wrapIntent(intent);
    return ReflectAccelerator.execStartActivity(mBase,
            who, contextThread, token, target, intent, requestCode, options);
}

/** @Override V20-
 * Wrap activity from REAL to STUB */
public ActivityResult execStartActivity(
        Context who, IBinder contextThread, IBinder token, Activity target,
        Intent intent, int requestCode) {
    wrapIntent(intent);
    return ReflectAccelerator.execStartActivity(mBase,
            who, contextThread, token, target, intent, requestCode);
}

@struggle111
Copy link
Author

经过调试,最后有个方法:return null了;如下:
ApkBundleLauncher.execStartActivity(Context who, IBinder contextThread, IBinder token, Activity target,Intent intent, int requestCode, android.os.Bundle options))——> ReflectAccelerator.execStartActivity(mBase,who, contextThread, token, target, intent, requestCode, options) -->
V21_.execStartActivity(instrumentation, who, contextThread, token, target, intent, requestCode, options); -->
ReflectAccelerator.invoke(sInstrumentation_execStartActivityV21_method, instrumentation, who, contextThread, token, target, intent, requestCode, options);

就是在invoke方法中执行了return null ,但是这个似乎不是原因。
你说的哪几方面都是正常运行的

@galenlin
Copy link
Member

galenlin commented Feb 6, 2017

V21_.execStartActivity(instrumentation, who, contextThread, token, target, intent, requestCode, options); 这个地方接收的 intent 是插件Activity了吗?

@galenlin
Copy link
Member

galenlin commented Feb 6, 2017

不是的话,要看下 wrapIntent 方法是否有问题。

@struggle111
Copy link
Author

是的,这个intent就是插件activity了

@struggle111
Copy link
Author

这个问题现在有思路吗??可能是什么原因造成的???

@galenlin
Copy link
Member

galenlin commented Feb 8, 2017

是的,这个intent就是插件activity了

从你调试的结果看,没毛病呀,,要看下什么地方没拦截成功,直接把 net.wequick.small.A 抛给底层了。

@xifan-xf
Copy link

xifan-xf commented Mar 22, 2017

我们应用在testIn上也测出了这个问题是一加的手机,应该是产商的氢Os系统有些奇怪的地方,可以肯定的是不是所有一加自己的OS出现的问题 ,同事一台一加刷的海外版OxygenOs没有问题。还有两款手机美图 V4和IUNI N1,Android版本都是5.1。准备自己刷机跟进下

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