My apk Signed does not run on my mobile

Asked

Viewed 514 times

0

I finished a small application that saves notes and I’m trying to generate Signed apk, but it doesn’t work on my phone.

  • I have tested generating a Signed apk from a new project with only a Blank Activity and the same worked normally on my phone.
  • I redid the process of generating Signed apk about 10x and none of them worked.
  • My application works normally in the emulator by Android Studio (which leaves me without understanding the problem of not working on my phone).

My little project is on github and has only 2 Activity’s, meaning it’s not complex...

I would appreciate it if someone could take a look at me...(remembering that I have already researched a lot on the internet and tried several options). thanks in advance!

project link on github: https://github.com/LucasBaltazar/Simple-Notes

download and try to generate Signed apk to see, I await answers!

Editing

This project gives this error:

01-07 16:35:55.009 16335-16335/com.lbttecnology.Notes E/Androidruntime FATAL EXCEPTION: main java.lang.Runtimeexception: Unable to start Activity Componentinfo{com.lbttecnology.Notes/com.lbttecnology.Notes.Notesactivity}: java.lang.Illegalstateexception: Cannot add header view to list -- setAdapter has already been called. at android.app.Activitythread.performLaunchActivity(Activitythread.java:2394) at android.app.Activitythread.handleLaunchActivity(Activitythread.java:2446) at android.app.Activitythread.access$600(Activitythread.java:165) at android.app.Activitythread$H.handleMessage(Activitythread.java:1373) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:194) at android.app.Activitythread.main(Activitythread.java:5434) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:834) at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:601) at Dalvik.system.Nativestart.main(Native Method) Caused by: java.lang.Illegalstateexception: Cannot add header view to list -- setAdapter has already been called. at android.widget.Listview.addHeaderView(Listview.java:261) at android.widget.Listview.addHeaderView(Listview.java:290) with.lbttecnology.Notes.NotesActivity.onCreate(Notesactivity.java:53) at android.app.Activity.performCreate(Activity.java:5122) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1146) at android.app.Activitythread.performLaunchActivity(Activitythread.java:2358)             at android.app.Activitythread.handleLaunchActivity(Activitythread.java:2446)             at android.app.Activitythread.access$600(Activitythread.java:165)             at android.app.Activitythread$H.handleMessage(Activitythread.java:1373)             at android.os.Handler.dispatchMessage(Handler.java:107)             at android.os.Looper.loop(Looper.java:194)             at android.app.Activitythread.main(Activitythread.java:5434)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:525)             at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:834)             at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:601)             at Dalvik.system.Nativestart.main(Native Method)

  • Which one android:targetSdkVersion? And what version of your Android on mobile?

  • cellular: 4.1.2(16) // project: minSdkVersion 15 targetSdkVersion 21

  • But does it install on your phone? What exactly happens?

  • It installs normally though, when I click on its icon to run the application it gives me the following message: "Notes stopped"

  • If you can download the project on github and look there on your machine, I believe that maybe you can solve...

  • I changed the question with the error generated by your application. There is any problem. Do not use the logcat you to test?

  • 1

    So, in my emulator does not generate error.. I have checked the problem you posted, fixed, generated the apk and installed on my phone and ran normally.

  • 1

    First of all, thank you very much, I am very grateful for your help!

Show 3 more comments

1 answer

0


In your code you have these two lines

setListAdapter(adapter);
getListView().addHeaderView(menu);

Where you first arrow the Adapter and then add the Header, this only works this way from Android Kitkat, before it was mandatory to set the Header before setting the Adapter

What should be happening to you is that the emulator is using an image of Android Kitkat or Lollipop, where it works, while on your mobile you probably have an earlier version of Android and it does not allow you to do this.

Perhaps simply reversing the order of these two lines will solve your problem.

  • Thanks man, Jorge B. had already solved my problem, but thank you so much for the attention! I will give your answers to the next people who have this same problem can solve it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.