1

Developed an unsigned APK,ran it through USB Debugging worked fine and ran the same transferring the APK file to an Android Phone(Oreo)it gets installed but doesn't open up(However many times i tap on the "Open" Button)
[Minimum SDK Version of APK is "Ice Cream Sandwich"]

Things I Tried:


  • Uninstalled the application,Cleared all App Data;Reinstalled(from File Manager) still didn't opened.
  • Made sure that "Install from unknown sources was enabled".
  • Installed the application on my friend's Android device still didn't opened.
  • Uninstalled application from PC through adb shell pm uninstall com.example.seve, Reinstalled still didn't opened.
  • Made sure Google Play Protect was disabled.



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)


Here are all my files.
MainActivity.java

IntroActivity.java

dash.java

IntroViewPagerAdapter.java

ScreenItem.java


Any suggestion will be appreciated.



EDIT: I found that the error is hidden mainly in my application so, I tried View Breakpoints and got something like this in logcat.Logcat tells that ClassNotFoundException is caused by somewhere around line 19 MainActivity.java but can't make much from it.
I tried disabling instant run got nothing and checked that <activity android:name=".IntroActivity"> is written instead of <activity android:name="android.app.IntroActivity
and enabled 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)
Kushagra Bajpai
  • 71
  • 1
  • 2
  • 9

2 Answers2

1

You will need to generate a Signed apk:

https://www.jetbrains.com/help/idea/generating-a-signed-apk-through-an-artifact.html

To deploy and run an Android application on a physical device, you need to sign the application digitally. With IntelliJ IDEA, you can have your Android Application Package (.apk file) signed with an existing release key on package extraction. IntelliJ IDEA also incorporates a release key generation tool that can be invoked during the packaging procedure. Generated keys are saved in a keystore binary file.

You can have as many keystore files and keys as you need and use either existing keys, or create new ones in existing keystores, or even create new keystores.

Apart from using the Generate Signed APK Wizard, you can configure the .apk file as an artifact by creating an Android application artifact definition. When IntelliJ IDEA builds the package in accordance with this definition, the package is signed automatically.

User has mentioned in comments that he's using IntelliJ IDEA so this answer would be different depending on your IDE. Xamarin, for example, will generate the -Signed.apk whether or not you have it signed with a keystore, but that may vary by IDE.

Community
  • 1
  • 1
hexagod
  • 449
  • 3
  • 15
  • I generated a signed apk, took ```app-release.apk``` and moved it to the phone,same problem gets installed but on tapping open it doesn't open. The main problem is that my app icon isn't even showing up on the phone,i.e the app icon is not visible after it gets installed. Thanx for a great suggestion though. – Kushagra Bajpai Oct 11 '19 at 16:14
  • see the below answer then.. you're trying to invoke virtual method 'java.lang.String android.content.Intent.toString()' on a null object reference ... that means you will need to step through your code in debug, starting probably @ `OnCreate` and find the null object. Then what I recommend doing is either explictly set that object `OnCreate` or alternatively you can use a `try` `catch` try to do what you're trying to do and if it fails then you will set the object. I really can't give much more detail without seeing the code you're trying to run. Either way, I recommend using signed apks – hexagod Oct 11 '19 at 16:21
  • after looking at this again... Just find where you are invoking `.toString()` on an instance of an `Intent` .. .that should be easy to find. Then you will need to backtrack where your `Intent` object is coming from and figure out another way to instantiate it. My bet is that it's statically instantiated directly in your class but never actually set. Take a look at this post https://stackoverflow.com/questions/20984429/cannot-instantiate-the-type-intent – hexagod Oct 11 '19 at 16:25
  • Actually here's a better post about it: https://stackoverflow.com/questions/4186021/how-to-start-new-activity-on-button-click ... basically you need to do some research on `Intent` in android because you're not getting the object. – hexagod Oct 11 '19 at 16:30
  • Well,I updated my question by adding all the java files i had(btw i searched(Ctrl + F) on all the java files and i haven't used ```toString()``` anywhere);Going back to research work on Intent. – Kushagra Bajpai Oct 11 '19 at 16:56
  • yeah that's weird. The only other thing I could say to do is set a breakpoint on every line where you're instantiating an `Intent` and then check your locals to see if it's returning null. You should be able to hover over the line and see what the values are (when you've set a breakpoint). Otherwise it's going to be some obscure issue that I have not seen before. I've never had any problems instantiating `Intent`s in Xamarin, nor invoking methods on them so I'm not an expert on this exception – hexagod Oct 11 '19 at 18:44
  • check this out for more information on how to use breakpoints https://www.jetbrains.com/help/idea/using-breakpoints.html – hexagod Oct 11 '19 at 18:47
  • @KushagraBajpai line 95 in introactivity can you set a breakpoint on all of these button click lines and see if it's breaking here? Apparently you have to get the `Intent` inside `onCreate` ... I know that's technically in that method but you're also overriding another method within it so I don't know if you're getting the right scope here without having the IDE in front of me. – hexagod Oct 11 '19 at 19:01
  • @KushagraBajpai check this out... maybe try setting intellij to break on *any* exception https://stackoverflow.com/questions/934794/is-there-break-on-exception-in-intellij ... this might stop your program on the exact line that is breaking your application. I'd give it a shot – hexagod Oct 11 '19 at 19:13
  • UPDATE: I just looked at my main Xamarin android project and I've got `Intent` s instantiated outside `onCreate` ... I read another post from an intellij user and they said it had to be inside `onCreate`, which is why I recommended that route. Try the breakpoint route above and see if the IDE will catch your exception – hexagod Oct 12 '19 at 00:29
  • after i open the "View Breakpoints" i select the following https://i.imgur.com/m1PBucn.png configurations and click on Done and then i ```run>debug``` the application and after it gets launched on my phone,I see some logcat "Caused by:" statements(They were not highlighted in red.)which i have posted in the question. @hexagod A big thanks for sticking with me though. – Kushagra Bajpai Oct 12 '19 at 07:56
  • @KushagraBajpai from the log you posted it looks like the only errors I see are related to a key listener. Man you might have to just set a breakpoint on every line in `onCreate` inside your `MainActivity` ... I'd set a bunch of breakpoints and then step through the whole app loading. When the app breaks on a line, you'll know which line. I know with android the break on all setting doesn't seem to work a lot of the time. – hexagod Oct 13 '19 at 19:55
0

As per the error:

Attempt to invoke virtual method 'java.lang.String android.content.Intent.toString()' on a null object reference

check your code again and debug. There is something wrong with your code.It does not seem to be an issue by installer.

bhavya joshi
  • 1,096
  • 10
  • 20