开发了一个未签名的APK,通过USB调试运行了它,效果很好,并执行了将APK文件传输到Android手机( Oreo )的相同操作,但它已安装但没有t打开(但是我多次点击“打开”按钮)
[APK的最低SDK版本是“冰淇淋三明治” ]
我尝试过的事情:
adb shell pm uninstall com.example.seve
从PC上卸载了应用程序,重新安装仍然没有打开。
2019-10-10 19:52:07.241 28262-28262/? E/GlobalPackageInstaller: launchApp error:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.toString()' on a null object reference
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1582)
at android.app.Activity.startActivityForResult(Activity.java:4555)
at android.app.Activity.startActivityForResult(Activity.java:4513)
at android.app.Activity.startActivity(Activity.java:4874)
at android.app.Activity.startActivity(Activity.java:4842)
at com.miui.global.packageinstaller.GlobalPackageInstallerActivity.g(Unknown Source:14)
at com.miui.global.packageinstaller.GlobalPackageInstallerActivity.onClick(Unknown Source:77)
at android.view.View.performClick(View.java:6304)
at android.view.View$PerformClick.run(View.java:24803)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
这是我所有的文件。
MainActivity.java
ScreenItem.java
任何建议将不胜感激。
编辑:我发现错误主要隐藏在我的应用程序中,因此,我尝试了View Breakpoints
并在logcat中得到了类似的信息。Logcat告诉ClassNotFoundException
是由line 19 MainActivity.java
周围的某个地方引起的,但是可以不能从中获得很多收益。
我尝试禁用即时运行一无所获,并检查是否写了<activity android:name=".IntroActivity">
而不是<activity android:name="android.app.IntroActivity
并启用了MultiDex“
2019-10-12 13:06:59.933 15201-15201/com.example.seve W/ResourceType: No package identifier when getting name for resource number 0x00000000
2019-10-12 13:07:00.100 15201-15201/com.example.seve D/AccessibilityManager: AccessibilityManager status: mPackageName = com.example.seve, mOptimizeEnabled = false, mIsEnabled = false, mIsUiAutomationEnabled = false, mIsInterestedPackage =false
2019-10-12 13:07:00.159 15201-15201/com.example.seve I/zygote64: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void com.example.seve.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:19)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7088)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7079)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1215)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2895)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1616)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.os.Looper.loop() (Looper.java:176)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6651)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:547)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:824)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64:Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.seve-GCOyFEE-ADwenEs5Wnn_ZA==/base.apk", zip file "/data/app/com.example.seve-GCOyFEE-ADwenEs5Wnn_ZA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.seve-GCOyFEE-ADwenEs5Wnn_ZA==/split_lib_resources_apk.apk", zip file "/data/app/com.example.seve-GCOyFEE-ADwenEs5Wnn_ZA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.seve-GCOyFEE-ADwenEs5Wnn_ZA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.seve-GCOyFEE-ADwenEs5Wnn_ZA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.seve-GCOyFEE-ADwenEs5Wnn_ZA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.seve-GCOyFEE-ADwenEs5Wnn_ZA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.seve-GCOyFEE-ADwenEs5Wnn_ZA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.seve-GCOyFEE-ADwenEs5Wnn_ZA==/split_lib_slice_6_apk.apk",
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:125)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void com.example.seve.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:19)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7088)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7079)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1215)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2895)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1616)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.os.Looper.loop() (Looper.java:176)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6651)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:547)
2019-10-12 13:07:00.160 15201-15201/com.example.seve I/zygote64: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:824)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void com.example.seve.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:19)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7088)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7079)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1215)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2895)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1616)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void android.os.Looper.loop() (Looper.java:176)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6651)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:547)
2019-10-12 13:07:00.161 15201-15201/com.example.seve I/zygote64: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:824)
答案 0 :(得分:1)
您将需要生成一个 Signed apk:
https://www.jetbrains.com/help/idea/generating-a-signed-apk-through-an-artifact.html
要在物理设备上部署和运行Android应用程序,您需要对应用程序进行数字签名。使用IntelliJ IDEA,您可以在提取包时使用现有的发布密钥对Android应用程序包(.apk文件)进行签名。 IntelliJ IDEA还集成了发行密钥生成工具,可以在打包过程中调用该工具。生成的密钥保存在密钥库二进制文件中。
您可以根据需要拥有任意数量的密钥库文件和密钥,并使用现有密钥,或者在现有密钥库中创建新密钥,甚至创建新密钥库。
除了使用“生成签名的APK向导”之外,您还可以通过创建Android应用程序工件定义来将.apk文件配置为工件。当IntelliJ IDEA根据此定义构建软件包时,该软件包将自动签名。
用户在评论中提到他正在使用IntelliJ IDEA,因此根据您的IDE,此答案将有所不同。例如,无论您是否使用密钥库进行签名,Xamarin都会生成-Signed.apk,但这可能因IDE而异。
答案 1 :(得分:0)
根据错误:
Attempt to invoke virtual method 'java.lang.String android.content.Intent.toString()' on a null object reference
再次检查您的代码并进行调试。您的代码有问题。安装程序似乎没有问题。