wequick / Small

A small framework to split app into small parts
http://code.wequick.net/Small
Apache License 2.0
5.04k stars 1.11k forks source link

自定义控件使用 inflate 单独运行可以,整体运行运行时错误 #403

Closed MaYunFei closed 7 years ago

MaYunFei commented 7 years ago

错误报告

你做了什么?

我在lib*模块中自定义了个view,使用 inflate 添加子控件,app*模块引用,单独编译运行是可以的,但是打包成插件整体运行时不可以的,(ps 我后来又写了个demo 是可以运行的,但是这个demo就是运行不了) 工程 https://github.com/MaYunFei/smalltest

你期望的结果是什么?

Small能够正确编译并正确运行。

实际结果是什么?

后来发现 Small 启动时报了个错误

open failed: errno 13 01-20 15:59:51.735 7050-7072/com.dongao.smalldemo W/art: The dalvik.system.DexPathList$Element constructor is not accessible by default. This is a temporary workaround for backwards compatibility with class-loader hacks. Please update your application. 01-20 15:59:51.735 7050-7072/com.dongao.smalldemo W/art: The dalvik.system.DexPathList$Element constructor is not accessible by default. This is a temporary workaround for backwards compatibility with class-loader hacks. Please update your application. 01-20 15:59:51.735 7050-7072/com.dongao.smalldemo W/art: The dalvik.system.DexPathList$Element constructor is not accessible by default. This is a temporary workaround for backwards compatibility with class-loader hacks. Please update your application. 01-20 15:59:51.778 7050-7050/com.dongao.smalldemo W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 01-20 15:59:51.899 7050-7050/com.dongao.smalldemo W/ResourceType: No known package when getting value for resource number 0x77030000 01-20 15:59:51.901 7050-7050/com.dongao.smalldemo W/PackageManager: Failure retrieving text 0x77030000 in package com.dongao.smalldemo android.content.res.Resources$NotFoundException: String resource ID #0x77030000 at android.content.res.Resources.getText(Resources.java:331) at android.app.ApplicationPackageManager.getText(ApplicationPackageManager.java:1508) at android.content.pm.ComponentInfo.loadLabel(ComponentInfo.java:99) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

运行报错,报错信息如下:

01-20 13:27:49.289 11907-11907/com.dongao.smalldemo E/AndroidRuntime: FATAL EXCEPTION: main Process: com.dongao.smalldemo, PID: 11907 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dongao.smalldemo/com.dongao.smalldemo.app.main.SecondActivity}: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class com.dongao.smalldemo.lib.widget.base.CustomerLayout at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class com.dongao.smalldemo.lib.widget.base.CustomerLayout Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class com.dongao.smalldemo.lib.widget.base.CustomerLayout Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:430) at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.inflate(LayoutInflater.java:518) at android.view.LayoutInflater.inflate(LayoutInflater.java:426) at android.view.LayoutInflater.inflate(LayoutInflater.java:377) at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:414) at android.app.Activity.setContentView(Activity.java:2414) at com.dongao.smalldemo.app.main.SecondActivity.onCreate(SecondActivity.java:10) at android.app.Activity.performCreate(Activity.java:6664) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at net.wequick.small.ApkBundleLauncher$InstrumentationWrapper.callActivityOnCreate(ApkBundleLauncher.java:220) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class vector Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class vector 01-20 13:27:49.290 11907-11907/com.dongao.smalldemo E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.vector" on path: DexPathList[[zip file "/data/app/com.dongao.smalldemo-1/lib/arm/libcom_dongao_smalldemo_app_main.so", dir "/data/app/com.dongao.smalldemo-1/lib/arm/libcom_dongao_smalldemo_app_main.so", zip file "/data/app/com.dongao.smalldemo-1/lib/arm/libcom_dongao_smalldemo_lib_data.so", dir "/data/app/com.dongao.smalldemo-1/lib/arm/libcom_dongao_smalldemo_lib_data.so", zip file "/data/app/com.dongao.smalldemo-1/lib/arm/libcom_dongao_smalldemo_lib_widget.so", dir "/data/app/com.dongao.smalldemo-1/lib/arm/libcom_dongao_smalldemo_lib_widget.so", zip file "/data/app/com.dongao.smalldemo-1/base.apk"],nativeLibraryDirectories=[/data/app/com.dongao.smalldemo-1/lib/arm, /data/app/com.dongao.smalldemo-1/base.apk!/lib/armeabi, /system/lib, /vendor/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at android.view.LayoutInflater.createView(LayoutInflater.java:609) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:700) at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.inflate(LayoutInflater.java:495) at android.view.LayoutInflater.inflate(LayoutInflater.java:426) at com.dongao.smalldemo.lib.widget.base.CustomerLayout.(CustomerLayout.java:26) at com.dongao.smalldemo.lib.widget.base.CustomerLayout.(CustomerLayout.java:21) at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:430) at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.inflate(LayoutInflater.java:518) at android.view.LayoutInflater.inflate(LayoutInflater.java:426) at android.view.LayoutInflater.inflate(LayoutInflater.java:377) at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:414) at android.app.Activity.setContentView(Activity.java:2414) at com.dongao.smalldemo.app.main.SecondActivity.onCreate(SecondActivity.java:10) at android.app.Activity.performCreate(Activity.java:6664) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at net.wequick.small.ApkBundleLauncher$InstrumentationWrapper.callActivityOnCreate(ApkBundleLauncher.java:220) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Small环境

Compile-time

  gradle-small plugin : 1.1.0-beta4 (maven)
            small aar : 1.1.0-alpha1 (maven)
          gradle core : 2.14.1
       android plugin : 2.2.3
                   OS : Mac OS X 10.12.2 (x86_64)

Bundles

type name PP sdk aapt support file(armeabi) size
host app 25 25.0.1 25.1.0
stub app+base_resources 25 25.0.1 25.1.0
app app.main 0x77 25 25.0.1 *_main.so 18.3 KB
lib lib.widget 0x3f 25 25.0.1 *_widget.so 606.6 KB
lib lib.data 0x32 25 25.0.1 *_data.so 612.5 KB

Runtime

  Device : moto g 2014 LTE
     SDK : Android 7.0
     ABI : armeabi-v7a
MaYunFei commented 7 years ago

感觉是个适配的问题,换了个手机好了,我之前是 moto g 刷的CM14 android7.0

galenlin commented 7 years ago

你好,从Log来看是找不到类 android.view.vector

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.vector"

这个是啥呢?是不是没有打包宿主或插件里。

MaYunFei commented 7 years ago

可以看下我附上的demo工程就用的

compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
  compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"
  compile "com.android.support:design:$rootProject.supportLibraryVersion"

  compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
  compile "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"
  compile "com.squareup.retrofit2:adapter-rxjava:$rootProject.retrofitVersion"
  compile "com.squareup.okhttp3:logging-interceptor:$rootProject.okhttpVersion"
  compile "com.squareup.okhttp3:okhttp:$rootProject.okhttpVersion"
  compile "io.reactivex:rxandroid:$rootProject.rxandroidVersion"
  compile "io.reactivex:rxjava:$rootProject.rxjavaVersion"

换了个手机居然可以了,android.view.vector这个类我也搜过了,没有用到,Google也搜过了没有什么信息,我这几天再试试

MaYunFei commented 7 years ago

后来没有出现这个问题,先关闭了