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

VirtualApp无法运行开启InstantRun编译的应用 #2

Open
prife opened this issue Aug 17, 2016 · 4 comments
Open

VirtualApp无法运行开启InstantRun编译的应用 #2

prife opened this issue Aug 17, 2016 · 4 comments

Comments

@prife
Copy link
Owner

prife commented Aug 17, 2016

使用VS,打开InstantRun特性,生成一个helloworld应用,在VA中打开,即抛出异常,如下所示。

01-10 04:44:20.254 12168-12168/io.virtualapp:p9 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.droi.helloinstantrun, PID: 12168
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.droi.helloinstantrun/com.droi.helloinstantrun.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.droi.helloinstantrun.MainActivity" on path: DexPathList[[zip file "/data/app/com.droi.helloinstantrun-1/base.apk", zip file "/data/app/com.droi.helloinstantrun-1/base.apk"],nativeLibraryDirectories=[/data/user/0/io.virtualapp/app_VApps/com.droi.helloinstantrun/lib, /vendor/lib, /system/lib]]
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.droi.helloinstantrun.MainActivity" on path: DexPathList[[zip file "/data/app/com.droi.helloinstantrun-1/base.apk", zip file "/data/app/com.droi.helloinstantrun-1/base.apk"],nativeLibraryDirectories=[/data/user/0/io.virtualapp/app_VApps/com.droi.helloinstantrun/lib, /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:1067)
    at com.lody.virtual.client.hook.delegate.InstrumentationDelegate.newActivity(InstrumentationDelegate.java:253)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5417) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
      Suppressed: java.lang.ClassNotFoundException: com.droi.helloinstantrun.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)
          ... 13 more
  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
@prife
Copy link
Owner Author

prife commented Aug 17, 2016

平行空间与VA应用目录结构差异

平行空间可以运行,且平行空间双开HelloInstantRun应用后,其目录结果是:

root@shamu:/data/data/com.lbe.parallel # tree
.
|-- app_baidu_ad_sdk
|-- app_webview
|   |-- Web\ Data
|   |-- Web\ Data-journal
|   `-- paks
|-- cache
|   |-- com.phantom
|   |   `-- 0
|   `-- volley
|-- code_cache
|   `-- com.android.opengl.shaders_cache
|-- databases
|   |-- com.amplitude.api
|   |-- com.amplitude.api-journal
|   |-- install.db
|   `-- install.db-journal
|-- files
|-- lib -> /data/app/com.lbe.parallel-1/lib/arm
|-- parallel
|   |-- 0
|   |   |-- com.droi.helloinstantrun
|   |   |   |-- cache
|   |   |   |   |-- slice-com.android.support-animated-vector-drawable-23.4.0_1b822770df4fbd565ee2103fd491db3c3b73d5ae-classes.dex
|   |   |   |   |-- slice-com.android.support-appcompat-v7-23.4.0_d7f41ce67bcfcd7c7473636a50b1a4b02dd08501-classes.dex
|   |   |   |   |-- slice-com.android.support-support-v4-23.4.0_938f50e1ef14f64bcf3c8cc3853c6bbc5287234c-classes.dex
|   |   |   |   |-- slice-com.android.support-support-vector-drawable-23.4.0_509db98626828743d9a7cf60b92324e671408996-classes.dex
|   |   |   |   |-- slice-internal_impl-23.4.0_cefddd432e80017b5433e599717ad65f8770479c-classes.dex
|   |   |   |   |-- slice-slice_0-classes.dex
|   |   |   |   |-- slice-slice_1-classes.dex
|   |   |   |   |-- slice-slice_2-classes.dex
|   |   |   |   |-- slice-slice_3-classes.dex
|   |   |   |   |-- slice-slice_4-classes.dex
|   |   |   |   |-- slice-slice_5-classes.dex
|   |   |   |   |-- slice-slice_6-classes.dex
|   |   |   |   |-- slice-slice_7-classes.dex
|   |   |   |   |-- slice-slice_8-classes.dex
|   |   |   |   |-- slice-slice_9-classes.dex
|   |   |   |   `-- slice-support-annotations-23.4.0_a9367782697a0f464a42e12e99590e060b17736a-classes.dex
|   |   |   |-- code_cache
|   |   |   |   `-- com.android.opengl.shaders_cache
|   |   |   |-- databases
|   |   |   |-- files
|   |   |   |   `-- instant-run
|   |   |   |       `-- dex
|   |   |   |           |-- slice-com.android.support-animated-vector-drawable-23.4.0_1b822770df4fbd565ee2103fd491db3c3b73d5ae-classes.dex
|   |   |   |           |-- slice-com.android.support-appcompat-v7-23.4.0_d7f41ce67bcfcd7c7473636a50b1a4b02dd08501-classes.dex
|   |   |   |           |-- slice-com.android.support-support-v4-23.4.0_938f50e1ef14f64bcf3c8cc3853c6bbc5287234c-classes.dex
|   |   |   |           |-- slice-com.android.support-support-vector-drawable-23.4.0_509db98626828743d9a7cf60b92324e671408996-classes.dex
|   |   |   |           |-- slice-internal_impl-23.4.0_cefddd432e80017b5433e599717ad65f8770479c-classes.dex
|   |   |   |           |-- slice-slice_0-classes.dex
|   |   |   |           |-- slice-slice_1-classes.dex
|   |   |   |           |-- slice-slice_2-classes.dex
|   |   |   |           |-- slice-slice_3-classes.dex
|   |   |   |           |-- slice-slice_4-classes.dex
|   |   |   |           |-- slice-slice_5-classes.dex
|   |   |   |           |-- slice-slice_6-classes.dex
|   |   |   |           |-- slice-slice_7-classes.dex
|   |   |   |           |-- slice-slice_8-classes.dex
|   |   |   |           |-- slice-slice_9-classes.dex
|   |   |   |           `-- slice-support-annotations-23.4.0_a9367782697a0f464a42e12e99590e060b17736a-classes.dex
|   |   |   |-- lib -> /data/data/com.droi.helloinstantrun/lib
|   |   |   `-- shared_prefs
|   |   |-- com.example.prife.hello2
|   |   |   `-- lib -> /data/data/com.example.prife.hello2/lib
|   |   `-- com.phantom
|   |       |-- app_webview
|   |       |   |-- Cookies
|   |       |   `-- Cookies-journal
|   |       |-- cache
|   |       |   `-- volley
|   |       |-- code_cache
|   |       |-- databases
|   |       |   |-- com.amplitude.api
|   |       |   `-- com.amplitude.api-journal
|   |       |-- files
|   |       |-- lib -> /data/data/com.lbe.parallel/parallel/lib-armeabi-v7a/com.phantom
|   |       `-- shared_prefs
|   |           |-- WebViewChromiumPrefs.xml
|   |           |-- ad_config.xml
|   |           `-- com.amplitude.api.com.lbe.parallel.xml
|   |-- app
|   |   `-- com.phantom
|   |       |-- base-1.apk
|   |       `-- base-1.dex
|   |-- badgemanager_user.ini
|   |-- lib
|   |   |-- com.droi.helloinstantrun -> /data/data/com.droi.helloinstantrun/lib
|   |   |-- com.example.prife.hello2 -> /data/data/com.example.prife.hello2/lib
|   |   `-- com.phantom -> /data/data/com.lbe.parallel/parallel/lib-armeabi-v7a/com.phantom
|   |-- lib-armeabi-v7a
|   |   `-- com.phantom
|   |       |-- libdaclient.so
|   |       |-- libdaclient_64.so
|   |       |-- libdaclient_x86.so
|   |       |-- libdadebugger.so
|   |       |-- libdadebugger_64.so
|   |       |-- libdadebugger_ics.so
|   |       |-- libdaunwind.so
|   |       |-- libdaunwind_64.so
|   |       `-- libuninstmon.so
|   |-- packages.ini
|   |-- packages_cache.ini
|   `-- phantom.ini
`-- shared_prefs
    |-- WebViewChromiumPrefs.xml
    |-- com.amplitude.api.com.lbe.parallel.xml
    |-- com.baidu.mobads.loader.xml
    |-- com.lbe.parallel_preferences.xml
    |-- configuration.xml
    |-- dependence_app.xml
    `-- score_guide_record.xml

37 directories, 74 files

而VA的目录结构

root@shamu:/data/data/io.virtualapp # tree
.
|-- app_VApps
|   |-- com.droi.helloinstantrun
|   |   |-- cache
|   |   |-- dalvik-cache
|   |   `-- lib
|   `-- com.example.prife.hello2
|       |-- cache
|       |-- dalvik-cache
|       `-- lib
|-- app_accounts
|   |-- accounts.db
|   `-- accounts.db-journal
|-- app_data
|   `-- system
|       `-- registered_services
|-- cache
|-- code_cache
|   `-- com.android.opengl.shaders_cache
|-- databases
|   `-- cc
|       |-- cc.db
|       `-- cc.db-journal
|-- files
|   `-- mobclick_agent_cached_io.virtualapp1
|-- lib -> /data/app/io.virtualapp-2/lib/arm
`-- shared_prefs
    |-- PersistedMapTagLastSeenMap.xml
    |-- PersistedSetToDoSet.xml
    `-- umeng_general_config.xml

20 directories, 9 files

InstantRun相关资料

@Howie-hxu
Copy link
Contributor

Instant Run的app如果要运行的话,需要做一下IO Redirect的操作。可以在本地修改一下代码就可以了。

2016-08-17 21:09 GMT+08:00 prife [email protected]:

平行空间与VA应用目录结构差异

平行空间可以运行,且平行空间双开HelloInstantRun应用后,其目录结果是:

root@shamu:/data/data/com.lbe.parallel # tree
.
|-- app_baidu_ad_sdk
|-- app_webview
| |-- Web\ Data
| |-- Web\ Data-journal
| -- paks |-- cache | |-- com.phantom | |-- 0
| -- volley |-- code_cache |-- com.android.opengl.shaders_cache
|-- databases
| |-- com.amplitude.api
| |-- com.amplitude.api-journal
| |-- install.db
| -- install.db-journal |-- files |-- lib -> /data/app/com.lbe.parallel-1/lib/arm |-- parallel | |-- 0 | | |-- com.droi.helloinstantrun | | | |-- cache | | | | |-- slice-com.android.support-animated-vector-drawable-23.4.0_1b822770df4fbd565ee2103fd491db3c3b73d5ae-classes.dex | | | | |-- slice-com.android.support-appcompat-v7-23.4.0_d7f41ce67bcfcd7c7473636a50b1a4b02dd08501-classes.dex | | | | |-- slice-com.android.support-support-v4-23.4.0_938f50e1ef14f64bcf3c8cc3853c6bbc5287234c-classes.dex | | | | |-- slice-com.android.support-support-vector-drawable-23.4.0_509db98626828743d9a7cf60b92324e671408996-classes.dex | | | | |-- slice-internal_impl-23.4.0_cefddd432e80017b5433e599717ad65f8770479c-classes.dex | | | | |-- slice-slice_0-classes.dex | | | | |-- slice-slice_1-classes.dex | | | | |-- slice-slice_2-classes.dex | | | | |-- slice-slice_3-classes.dex | | | | |-- slice-slice_4-classes.dex | | | | |-- slice-slice_5-classes.dex | | | | |-- slice-slice_6-classes.dex | | | | |-- slice-slice_7-classes.dex | | | | |-- slice-slice_8-classes.dex | | | | |-- slice-slice_9-classes.dex | | | |-- slice-support-annotations-23.4.0_a9367782697a0f464a42e12e99590e060b17736a-classes.dex
| | | |-- code_cache
| | | | -- com.android.opengl.shaders_cache | | | |-- databases | | | |-- files | | | |-- instant-run
| | | | -- dex | | | | |-- slice-com.android.support-animated-vector-drawable-23.4.0_1b822770df4fbd565ee2103fd491db3c3b73d5ae-classes.dex | | | | |-- slice-com.android.support-appcompat-v7-23.4.0_d7f41ce67bcfcd7c7473636a50b1a4b02dd08501-classes.dex | | | | |-- slice-com.android.support-support-v4-23.4.0_938f50e1ef14f64bcf3c8cc3853c6bbc5287234c-classes.dex | | | | |-- slice-com.android.support-support-vector-drawable-23.4.0_509db98626828743d9a7cf60b92324e671408996-classes.dex | | | | |-- slice-internal_impl-23.4.0_cefddd432e80017b5433e599717ad65f8770479c-classes.dex | | | | |-- slice-slice_0-classes.dex | | | | |-- slice-slice_1-classes.dex | | | | |-- slice-slice_2-classes.dex | | | | |-- slice-slice_3-classes.dex | | | | |-- slice-slice_4-classes.dex | | | | |-- slice-slice_5-classes.dex | | | | |-- slice-slice_6-classes.dex | | | | |-- slice-slice_7-classes.dex | | | | |-- slice-slice_8-classes.dex | | | | |-- slice-slice_9-classes.dex | | | |-- slice-support-annotations-23.4.0_a9367782697a0f464a42e12e99590e060b17736a-classes.dex
| | | |-- lib -> /data/data/com.droi.helloinstantrun/lib
| | | -- shared_prefs | | |-- com.example.prife.hello2 | | |-- lib -> /data/data/com.example.prife.hello2/lib
| | -- com.phantom | | |-- app_webview | | | |-- Cookies | | |-- Cookies-journal
| | |-- cache
| | | -- volley | | |-- code_cache | | |-- databases | | | |-- com.amplitude.api | | |-- com.amplitude.api-journal
| | |-- files
| | |-- lib -> /data/data/com.lbe.parallel/parallel/lib-armeabi-v7a/com.phantom
| | -- shared_prefs | | |-- WebViewChromiumPrefs.xml | | |-- ad_config.xml | |-- com.amplitude.api.com.lbe.parallel.xml
| |-- app
| | -- com.phantom | | |-- base-1.apk | |-- base-1.dex
| |-- badgemanager_user.ini
| |-- lib
| | |-- com.droi.helloinstantrun -> /data/data/com.droi.helloinstantrun/lib
| | |-- com.example.prife.hello2 -> /data/data/com.example.prife.hello2/lib
| | -- com.phantom -> /data/data/com.lbe.parallel/parallel/lib-armeabi-v7a/com.phantom | |-- lib-armeabi-v7a | |-- com.phantom
| | |-- libdaclient.so
| | |-- libdaclient_64.so
| | |-- libdaclient_x86.so
| | |-- libdadebugger.so
| | |-- libdadebugger_64.so
| | |-- libdadebugger_ics.so
| | |-- libdaunwind.so
| | |-- libdaunwind_64.so
| | -- libuninstmon.so | |-- packages.ini | |-- packages_cache.ini |-- phantom.ini
-- shared_prefs |-- WebViewChromiumPrefs.xml |-- com.amplitude.api.com.lbe.parallel.xml |-- com.baidu.mobads.loader.xml |-- com.lbe.parallel_preferences.xml |-- configuration.xml |-- dependence_app.xml -- score_guide_record.xml

37 directories, 74 files

而VA的目录结构

root@shamu:/data/data/io.virtualapp # tree
.
|-- app_VApps
| |-- com.droi.helloinstantrun
| | |-- cache
| | |-- dalvik-cache
| | -- lib |-- com.example.prife.hello2
| |-- cache
| |-- dalvik-cache
| -- lib |-- app_accounts | |-- accounts.db |-- accounts.db-journal
|-- app_data
| -- system |-- registered_services
|-- cache
|-- code_cache
| -- com.android.opengl.shaders_cache |-- databases |-- cc
| |-- cc.db
| -- cc.db-journal |-- files |-- mobclick_agent_cached_io.virtualapp1
|-- lib -> /data/app/io.virtualapp-2/lib/arm
-- shared_prefs |-- PersistedMapTagLastSeenMap.xml |-- PersistedSetToDoSet.xml -- umeng_general_config.xml

20 directories, 9 files

InstantRun相关资料


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMWPdfVzVrl84Z0s9Y4rNSbz4wEMRabOks5qgwgmgaJpZM4Jmazn
.

@prife
Copy link
Owner Author

prife commented Aug 18, 2016

还有一种解决方法:
busybox chmod 777 -R /data/data/com.droi.helloinstantrun/
即可在VA中运行helloinstantrun应用了

具体的原理稍后解释。

@Howie-hxu
Copy link
Contributor

Howie-hxu commented Aug 18, 2016

可以在
VClientImpl.java

    private void handleBindApplication(AppBindData data) {
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public synchronized void start() {
                new Exception().printStackTrace();
                super.start();
            }
        });
+       IOHook.redirect("/data/data/"+data.appInfo.packageName+"/", data.appInfo.dataDir);
+       IOHook.hook();

        IOHook.startDexOverride();
        IOHook.hookNative();
        ContextFixer.fixCamera();
                ......
}

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

2 participants