简体   繁体   English

调试APK解析错误(通过单击android studio运行按钮生成)

[英]debug APK parsing error (generate by click android studio run button)

I had developed app on android studio 3.0.1, but I got a error when I installed the apk to my cellphone. 我已经在Android Studio 3.0.1上开发了应用程序,但是将apk安装到手机上时出现错误。
Cellphone connect mac by usb, click run button 手机通过usb连接mac,点击运行按钮

在此处输入图片说明

,the apk will installed and run no error. ,apk将安装并运行没有错误。 But if I copy the apk in finder (like this) 但是如果我在finder中复制apk(像这样)

在此处输入图片说明

to cellphone and install it in phone, there will be an error "APK parsing error". 到手机并将其安装在手机中,将出现错误“ APK解析错误”。
If install apk by "adb install xxx.apk" ,when open the app, it will crash and logcat as follow: 如果通过“ adb install xxx.apk”安装apk,则在打开应用程序时,它将崩溃并显示logcat,如下所示:

12-20 16:35:09.562 14658-14658/? I/art: Late-enabling -Xcheck:jni
12-20 16:35:09.562 14658-14658/? I/art: Reinit property: dalvik.vm.checkjni= false
12-20 16:35:09.614 14658-14658/com.xxx.xxx I/InstantRun: starting instant run server: is main process
12-20 16:35:09.620 14658-14658/com.xxx.xxx E/AndroidRuntime: FATAL EXCEPTION: main
                                                                        Process: com.xxx.xxx, PID: 14658
                                                                        java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.xxx.xxx/com.xxx.xxx.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.MainActivity" on path: DexPathList[[zip file "/data/app/com.xxx.xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-1/lib/arm64, /data/app/com.xxx.xxx-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2695)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2867)
                                                                            at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1570)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                            at android.os.Looper.loop(Looper.java:156)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:6595)
                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
                                                                         Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.MainActivity" on path: DexPathList[[zip file "/data/app/com.xxx.xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-1/lib/arm64, /data/app/com.xxx.xxx-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
                                                                            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.app.Instrumentation.newActivity(Instrumentation.java:1083)
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2685)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2867) 
                                                                            at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1570) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:105) 
                                                                            at android.os.Looper.loop(Looper.java:156) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:6595) 
                                                                            at java.lang.reflect.Method.invoke(Native Method) 
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942) 
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832) 
12-20 16:35:09.624 14658-14658/com.xxx.xxx I/Process: Sending signal. PID: 14658 SIG: 9

But if click Bulid>Build APK(s) , then copy the apk in same folder (this : apk )to cellphone, it will install and run with no error... 但是,如果单击Bulid> Build APK(s),然后将同一文件夹(this: apk )中的apk复制到手机,它将安装并正常运行...

is it a bug in android studio? 这是Android Studio中的错误吗?

manifest.xml manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxx.xxx">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.CAMERA" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

In new version VS, You shold use "Bulid Apk" menu option to generate the product apk :) 在新版本VS中,您使用“内置Apk”菜单选项生成产品apk :) 在此处输入图片说明

try with disable Instant Run . 尝试禁用Instant Run it find at 它发现在

Run Goto File -> Settings -> Build,Execution, Deployment -> Instant Run -> Uncheck the checkbox for instant run 运行转到文件->设置->构建,执行,部署->即时运行->取消选中即时运行复选框

before this uninstall previous app from device. 在此之前,请从设备上uninstall以前的应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM