EchoEcho
EchoEcho
  • 发布:2023-10-20 18:08
  • 更新:2023-10-23 09:31
  • 阅读:310

【报Bug】UniPlugin-Hello-AS项目编写的插件, 打包成功,但是运行失败,急需解决

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10 企业版

HBuilderX类型: 正式

HBuilderX版本号: 3.8.12

手机系统: Android

手机系统版本号: Android 10

手机厂商: 一加

手机机型: 一加5

页面类型: vue

vue版本: vue2

打包方式: 离线

项目创建方式: HBuilderX

SDK版本号: Android-SDK@3.8.12.81924_20230817

示例代码:

···
UniPlugin-Hello-AS项目的build.gradle 配置信息:
//修改包名 com.android.HelloH5 com.ghyl.reportwork
applicationId "com.ghyl.reportwork"
minSdkVersion 24
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 30

    versionCode 1  
    versionName "1.0"  
    multiDexEnabled true  
    ndk {  
        abiFilters 'arm64-v8a','armeabi-v7a' //"arm64-v8a",  
    }  
    compileOptions {  
        sourceCompatibility JavaVersion.VERSION_1_8  
        targetCompatibility JavaVersion.VERSION_1_8  
    }  

子项目的配置信息:

defaultConfig {  
    minSdkVersion 24  
    //noinspection ExpiredTargetSdkVersion  
    targetSdkVersion 30  
    versionCode 1  
    versionName "1.0"  

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"  
    consumerProguardFiles "consumer-rules.pro"  

    externalNativeBuild {  
        cmake {  
            cppFlags ""  
            abiFilters "arm64-v8a", "armeabi-v7a"  
        }  
    }  
}  

externalNativeBuild {  
    cmake {  
        path "src/main/jni_v6/CMakeLists.txt"  
    }  
}  

···

操作步骤:

···
···

预期结果:

···
···

实际结果:

···
D onCreate
2023-10-20 18:00:15.581 12075-12075 System.err W java.lang.ClassNotFoundException: io.dcloud.common.util.net.http.LocalServer2
2023-10-20 18:00:15.582 12075-12075 System.err W at java.lang.Class.classForName(Native Method)
2023-10-20 18:00:15.582 12075-12075 System.err W at java.lang.Class.forName(Class.java:454)
2023-10-20 18:00:15.582 12075-12075 System.err W at java.lang.Class.forName(Class.java:379)
2023-10-20 18:00:15.583 12075-12075 System.err W at io.dcloud.common.ui.PrivacyManager.isDebugMode(Unknown Source:1)
2023-10-20 18:00:15.583 12075-12075 System.err W at io.dcloud.b.onCreate(Unknown Source:8)
2023-10-20 18:00:15.583 12075-12075 System.err W at io.dcloud.WebAppActivity.onCreate(Unknown Source:22)
2023-10-20 18:00:15.584 12075-12075 System.err W at android.app.Activity.performCreate(Activity.java:7815)
2023-10-20 18:00:15.584 12075-12075 System.err W at android.app.Activity.performCreate(Activity.java:7804)
2023-10-20 18:00:15.584 12075-12075 System.err W at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1325)
2023-10-20 18:00:15.585 12075-12075 System.err W at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3350)
2023-10-20 18:00:15.585 12075-12075 System.err W at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3514)
2023-10-20 18:00:15.586 12075-12075 System.err W at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
2023-10-20 18:00:15.586 12075-12075 System.err W at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
2023-10-20 18:00:15.587 12075-12075 System.err W at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
2023-10-20 18:00:15.587 12075-12075 System.err W at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2110)
2023-10-20 18:00:15.587 12075-12075 System.err W at android.os.Handler.dispatchMessage(Handler.java:107)
2023-10-20 18:00:15.588 12075-12075 System.err W at android.os.Looper.loop(Looper.java:214)
2023-10-20 18:00:15.588 12075-12075 System.err W at android.app.ActivityThread.main(ActivityThread.java:7697)
2023-10-20 18:00:15.588 12075-12075 System.err W at java.lang.reflect.Method.invoke(Native Method)
2023-10-20 18:00:15.589 12075-12075 System.err W at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
2023-10-20 18:00:15.589 12075-12075 System.err W at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
2023-10-20 18:00:15.591 12075-12075 System.err W Caused by: java.lang.ClassNotFoundException: Didn't find class "io.dcloud.common.util.net.http.LocalServer2" on path: DexPathList[[zip file "/data/app/-Fx2sR7gA-7eKVhDJl4s1XA==/base.apk"],nativeLibraryDirectories=[/data/app/-Fx2sR7gA-7eKVhDJl4s1XA==/lib/arm64, /data/app/-Fx2sR7gA-7eKVhDJl4s1XA==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
2023-10-20 18:00:15.592 12075-12075 System.err W at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
2023-10-20 18:00:15.592 12075-12075 System.err W at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
2023-10-20 18:00:15.593 12075-12075 System.err W at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
2023-10-20 18:00:15.593 12075-12075 System.err W ... 21 more
2023-10-20 18:00:15.621 4106-6527 RecentTasksList net.oneplus.launcher D dumpTasks# id=357, cmp=ComponentInfo{/io.dcloud.PandoraEntry}, uid=0, locked=false, isAppLocked=false
2023-10-20 18:00:15.844 12075-12075 ghyl.reportwor W Accessing hidden field Ldalvik/system/BaseDexClassLoader;->pathList:Ldalvik/system/DexPathList; (greylist, JNI, allowed)
2023-10-20 18:00:15.844 12075-12075 ghyl.reportwor W Accessing hidden field Ldalvik/system/DexPathList;->dexElements:[Ldalvik/system/DexPathList$Element; (greylist, JNI, allowed)
2023-10-20 18:00:15.844 12075-12075 ghyl.reportwor W Accessing hidden field Ldalvik/system/DexPathList$Element;->dexFile:Ldalvik/system/DexFile; (greylist, JNI, allowed)
2023-10-20 18:00:15.844 12075-12075 ghyl.reportwor W Accessing hidden field Ldalvik/system/DexFile;->mFileName:Ljava/lang/String; (greylist, JNI, allowed)
2023-10-20 18:00:15.987 12075-12075 WebViewFactory I Loading com.google.android.webview version 81.0.4044.138 (code 404413833)
2023-10-20 18:00:16.566 13705-13706 JSE I ScriptBridgeInMultiProcess::ExecJSService
2023-10-20 18:00:16.570 13705-13706 JSE I ScriptBridgeInMultiProcess::ExecJSService
2023-10-20 18:00:16.830 12075-12075 cr_LibraryLoader I Loaded native library version number "81.0.4044.138"
2023-10-20 18:00:16.832 12075-12075 AppRuntime E initUTS error java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.reflect.Field java.lang.Class.getField(java.lang.String)' on a null object reference
2023-10-20 18:00:16.832 12075-12075 download_manager D BaseActivity onCreate
2023-10-20 18:00:16.832 12075-12075 <no-tag> D onRuntimePreCreate appid=Main_App
2023-10-20 18:00:16.864 12075-12075 splash I WebAppActivity.onCreateSplash().appid=null this.appid=Main_App this=io.dcloud.PandoraEntryActivity@dcf9986
2023-10-20 18:00:16.864 12075-12075 splash I WebAppActivity.onCreateSplash().mSplashView is Null =true
2023-10-20 18:00:16.864 12075-12075 WebAppActivity I onCreateSplash;intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=/io.dcloud.PandoraEntryActivity (has extras) }
2023-10-20 18:00:16.865 12075-12075 WebAppActivity I onCreateSplash hasSplash=true
2023-10-20 18:00:16.865 12075-12075 WebAppActivity I onCreateSplash __splash_mode__=auto
2023-10-20 18:00:16.907 12075-12075 platform I ClassNotFoundException io.dcloud.appstream.actionbar.StreamAppActionBarUtil checkNeedTitleView
2023-10-20 18:00:16.915 12075-12075 WebAppActivity D checkAutoHide false
2023-10-20 18:00:16.938 12075-12075 <no-tag> I onResume appid=Main_App
2023-10-20 18:00:16.938 12075-12075 Html5Plus-onResume E 1697796016938
2023-10-20 18:00:16.952 12075-12075 ViewRootImpl V The specified message queue synchronization barrier token has not been posted or has already been removed
2023-10-20 18:00:16.960 12075-12075 OPDFontHInj D ViewRoot performTraversals. in /io.dcloud.PandoraEntryActivity
2023-10-20 18:00:16.985 12075-13718 ViewRootIm...yActivity] D windowFocusChanged hasFocus=true inTouchMode=true
2023-10-20 18:00:17.011 12075-12075 SplashView I dispatchDraw.....
2023-10-20 18:00:17.071 12075-12075 Choreographer W Already have a pending vsync event. There should only be one at a time.
2023-10-20 18:00:17.078 1599-4776 OpenIdManager system_server D Get openid: package=, uid=1000, type=OUID
2023-10-20 18:00:17.079 12075-12075 ImageLoader W memoryCache() and memoryCacheSize() calls overlap each other
2023-10-20 18:00:17.086 31697-2392 OpenID:Ide...(Line:129) com.heytap.openid E :LicenceCode is null,CacheValidity,Query later:App Not Exists
2023-10-20 18:00:17.090 12075-12075 ImageLoader W memoryCache() and memoryCacheSize() calls overlap each other
2023-10-20 18:00:17.090 1599-4776 OpenIdManager system_server D Get openid: package=, uid=1000, type=AUID
2023-10-20 18:00:17.091 12075-12075 ImageLoader W discCache(), discCacheSize() and discCacheFileCount calls overlap each other
2023-10-20 18:00:17.286 1599-3288 OpenIdManager system_server D Get openid: package=, uid=1000, type=OUID
2023-10-20 18:00:17.302 31697-2392 OpenID:Ide...(Line:129) com.heytap.openid E :LicenceCode is null,CacheValidity,Query later:App Not Exists
2023-10-20 18:00:17.304 12075-12075 uni-AD E wm adapter version not match
2023-10-20 18:00:17.307 1599-3288 OpenIdManager system_server D Get openid: package=, uid=1000, type=AUID
2023-10-20 18:00:17.424 12075-12075 jse_precompilejs I 1
2023-10-20 18:00:17.438 12075-12075 Main_Path_Main_App I onCreate appid=Main_App
2023-10-20 18:00:17.459 12075-13696 DpmTcmClient I RegisterTcmMonitor from: $Proxy0
2023-10-20 18:00:17.490 1599-1752 ActivityManager system_server I Start proc 13741:com.google.android.webview:sandboxed_process0:org.chromium.content.app.SandboxedProcessService0:0/u0i335 for {/org.chromium.content.app.SandboxedProcessService0:0}
2023-10-20 18:00:17.509 1599-1752 ActivityManager system_server I Start proc 13755:com.google.android.webview:sandboxed_process0:org.chromium.content.app.SandboxedProcessService0:0/u0i336 for {/org.chromium.content.app.SandboxedProcessService0:0}
2023-10-20 18:00:17.571 1599-1751 BroadcastQueue system_server W Permission Denial: broadcasting Intent { act=android.intent.action.BATTERY_CHANGED flg=0x60000010 (has extras) } from null (pid=-1, uid=-1) requires huawei.permission.CLICK_STATUSBAR_BROADCAST due to registered receiver BroadcastFilter{de279b5 10280/u0 ReceiverList{657d1ec 12075 /10280/u0 remote:65d1c9f}}
2023-10-20 18:00:17.571 12075-12075 Main_Path_Main_App I onRuntimeCreate appid=Main_App
2023-10-20 18:00:17.587 12075-12075 DCloud_LOG E fmgr no dp
2023-10-20 18:00:17.751 12075-12075 Main_Path E FeatureMgr.loadBootOptions io.dcloud.feature.aps.APSFeatureImpl
2023-10-20 18:00:17.751 12075-12075 Main_Path E FeatureMgr.loadBootOptions io.dcloud.feature.statistics.StatisticsBootImpl
2023-10-20 18:00:17.752 12075-12075 Main_Path E FeatureMgr.loadBootOptions io.dcloud.net.DownloaderBootImpl
2023-10-20 18:00:17.817 12075-12075 DeviceInfo I old_app_modify_date=1697789614000
2023-10-20 18:00:17.818 12075-12075 DeviceInfo I App Modify Date=1697789614000;_ret=false
2023-10-20 18:00:17.818 12075-12075 DCloud_LOG E channel:;ver:1.9.9.81924;max:3;trim:0;dg:false
···

bug描述:

使用的UniPlugin-Hello-AS项目编写一个插件,插件项目中用到了jni,以及一些so文件,打包是成功了,但是运行的时候直接报错了,程序崩溃了

2023-10-20 18:08 负责人:无 分享
已邀请:
II优选

II优选 - 定制插件开发-联系QQ:770104707

付费处理

EchoEcho

EchoEcho (作者)

问题解决了,结贴,文件权限没给上

EchoEcho

EchoEcho (作者)

安卓10以下主项目中需要配置一行: android:requestLegacyExternalStorage="true" ,对文件的读写权限

    <application  
        android:name="io.dcloud.application.DCloudApplication"  
        android:allowClearUserData="true"  
        android:icon="@drawable/icon"  
        android:label="@string/app_name"  
        android:largeHeap="true"  
       android:requestLegacyExternalStorage="true"  
        android:supportsRtl="true">

要回复问题请先登录注册