First I want to reference my "research". I'm new to the Android environment, not to Java, but I could say I've sometimes failed to understand the concepts that lead to logical errors. It's been my experience that I usually don't have to think too much about setup, diving right into code. It's also been one one of the things that have held me back.
This to say that the error I'm experiencing now may be because of a fundamental misunderstanding of the compiling-linking mechanism on Java or on Android specifically. I want to change that.
Primarily this question is for an explanation on this subject, concentrating on learning enough to update this text so that I can give an apt explanation of what's really going on and why I was stuck with this problem for so long.
Specifically, I'm using the demo app to test on my device, having the app go "Unfortunately, has stopped". I've followed each step outlined here with repetition and variance in each case following previous answer, especially this answer, which seems to describe a very similar scenario to mine.
I could use a quick fix, but this answer I think deserves a better explanation. Solutions associated with this question seem to depend on what exactly the user has in his environment/the order with which libraries are compiled/the folders within which these libraries are placed. So if anyone has a deeper understanding of what exactly is going on here I would certainly appreciate the visualization.
I can share my own code files (which are copies of the my_location_demo) but I have no logcat as I'm exporting to dropbox to test on my own device.
UPDATE
Does anyone know if I need to declare my library resources in my manifest file? Here it says to declare all external library activity. My current manifest file includes the following:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCvGBr5in13NK2yYBR7lhXTtnxj3mrXQy4"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
I am looking into the logcat suggestions, although I do not have a rooted device, nor one running <=4.1 But I had this running a while back, this cannot be so difficult.
UPDATE 2
Right now I got the demo app functioning, this is what I did:
1.Created new workspace.
2.Imported Google Play Services lib (Copy into workspace because i have 2 Drives, this only works when both files are in the same drive)
3.I noticed that androi v4 support library was already added.
4.Changed API key accordingly on manifest (which already had all necesary permissions).
Since this was the demo app it already has some setting i cannot decipher. I obviously want to apply this to my own app.
I tried reproducing the same procedure and i noticed the file icon (to the left of the name in the file explorer on eclipse) was missing a symbol for Library, in contrast to my previously succesful demo project.
I referenced that through "Add JAR" in the Java build path libraries tab.
With these options my app gets to a loading map, but crashes before it shows anything.
I referenced the google play through "Add External JAR" in the java build path libraries tab as well, and I didn't get to the map, which takes me "further" away, so I removed it and got the map to 'almost' load again, at least.
UPDATE 3
In the next Image I'd like to point out the only difference I can still find while comparing the demo app (working) with two versions of my app. The bottom red rectangle highlights what I mean about the working project having an android-support-v4.jar with a library icon on its left. The next red highlight box shows one of the project instances I have, where the file is shown to not have the same library icon on its left. The last two red boxes from bottom up highlight how I tried to convert that file into a library, the top red box being a new 'file' that appeared when I made the reference to the library.
The one that 'seems' to work (gets to map controls, but shows no map and crashes) is the top instance.
UPDATE 4
I added this line GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); to my onCreate as suggested here. Which resulted in getting to actually load a MAP (omg im so close) with controls. GPS icon on the top system tray is flashing (acquiring location) and a colorful map appears on the grid, but it still crashes after 5-7 seconds.
UPDATE 5
It's possible that I may have acomplished something, but I think i just lost my time. I added a TextView that was present in the initial tutorial (i didn't need it) to the code and now everything is working (almost fine). I'm guessing I haven't read enough of Layouts to understand how much that needs to be set up.I still have some bugs but at least i can see the map and it's pinging my location.
Again,
Many thanks.
Related
I downloaded an example of an Android project from this website:
https://draeger-it.blog/android-app-programmierung-bluetooth-low-energy-connection-ble/?cn-reloaded=1
...and adjusted the code as mentioned in the comments. I was very happy to see it working on my Samsung Tab S7.
Afterward, I created my own Android Project and just copied the code from the following three documents:
AndroidManifest.xml
MainActivity.java
activity_main.xml
Unfortunately, it is not working when using a new Project structure. One obvious difference is that every time I open the "original" / working project, the user is asked to grant permission for the device location. Using my own project, it seems like the user is only asked when running the App for the first time.
Any ideas what else needs to be changed in the project, to get that working?
Thank you!
You have one more file that you should check, and that is the build.gradle file. You might not be using the same android API.
My users are complaining that my app now requires "run at startup" permission according the listing on Google Play. I have no need for this permission so would like to remove it from my app. I assume it must be from a library that I use but which one? In the "Merged Manifest" there is nothing about "boot" or "startup". I just have these:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
How can I track this down? My users are acting like I'm the anti-Christ for having this extra permission and I look stupid(maybe accurately) for not knowing why. Also, is there a list somewhere that shows what permissions correspond to what text on the Play store description page?
I want to address the comment about removing the permission. I understand how that is done and that's not what I'm asking. I need to know how to find the permission. Else, how can you remove something if you don't know what is is? Also, I may want to keep the permission but need to explain what it is for to my end-users.
#Mike is probably correct about WorkManager API. Still the question is how did he find that out? Why doesn't Android Studio show the permission in the Merged Manifest?
Also, even stranger is that I have removed the WorkManager API so the permission should be gone. I did check out the code for the released version and there are no left over references to WorkManager.
The easy way is from Android Studio. First build your app. Then from the build menu select Analyze APK. From there you can see the full AndroidManifest.
https://developer.android.com/studio/build/apk-analyzer
In my case the permissions did not show up in the Merged Manifest tab. Could be a bug. I think what happened is that I used a library during beta testing. Removed the code that uses library but still had a reference in build.gradle. That added the permission to the released apk's Manifest.
If I wanted to research how and where permissions [requested in the Mainfest.xml] were used in an Android app for the purposes of removing them is there an easy way of doing this? Does lint or findbugs offer some sort of support for tracking permissions used/abused in a project?
I came from the future to save your lives.
Here (in the future), LINT does check for missing permissions as you can see on LINT checks.
So, go to your AndroidManifest.xml and remove all tags <uses-permission> using Android permissions (meaning, don't delete permissions that belong to your app, such as UA_DATA and C2D_MESSAGE).
Then run LINT analysis. Click on Analyze then Inspect Code...
Look under Android -> Constant and Resource Type Mismatches
You should see all missing permissions.
Then you can just right-click them and select Apply fix "Add Permission". If you select this option, Android Studio will include one permission for every error. So you'll end up with multiple copies of the same permission on your Manifest file, just delete the duplicates. You can do it manually too.
Here is the description of the LINT rule:
ID ResourceType
Description
This inspection looks at Android API calls that have been annotated with various support annotations (such as RequiresPermission or UiThread) and flags any calls that are not using the API correctly as specified by the annotations. Examples of errors flagged by this inspection:
Passing the wrong type of resource integer (such as R.string) to an API that expects a different type (such as R.dimen).
Forgetting to invoke the overridden method (via super) in methods that require it
Calling a method that requires a permission without having declared that permission in the manifest
Passing a resource color reference to a method which expects an RGB integer value.
...and many more. For more information, see the documentation at http://developer.android.com/tools/debugging/annotations.html
I'm using Android Studio 2.1.2.
In your app manifest file you should have a tab "Merged Manifest" there you can see your final manifest and the permissions you request you can click on a permission to see where it came from. (who added it - ex': sdk or what code it came from)
There is also a simple way to remove a permission by adding to manifest:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
tools:node="remove" />
Also remember to add the tools at the top:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="...">
The way I would do it for an app for which I didn't write the code would be to remove the permissions one by one and test the app end-to-end each time. When it fails, narrow it down. If not, that permission may not be used.
You will have to try removing them one by one and checking i fthe app still works OK. This is not checked by lint in any way (it should be).
When they come back (they are currently down), you can upload your apk to this website (if that's ok with you) and let them statically analyse the permissions you are using: http://www.android-permissions.org/
Best way is to understand what the may actually do. If it is ever going to use the camera then you know you need the camera permission.
Or you could just learn what your app does and then go through the permissions and see which ones are extra. What does your app do, what phone features does it use. There should be some documentation somewhere on what it should do and what methods are in there
I need to crop an image using selectors and dragging etc.
I cannot use com.android.camera.action.CROP cause in many phones i tested doesn't work.
I searched here all examples, the only working is that where is used android.provider.MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI
but the problem is that everytime it asks user to choice the image.
Can someone post me kindly an example.
I need to open it on the image i need, without that the user has to open an image, searching in file system.
I am enough disappointed cause android doestn offer something compatible for all devices from 2.1 android till 4 at least...
Thanks
Download Sample:- https://github.com/lorensiuswlt/AndroidImageCrop
Only three changes required for android 2.1:-
In main.xml, write wrap_content instead of matchparent.
In AndroidManifest.xml, <uses-sdk android:minSdkVersion="7" />
In default.properties, target=android-7
A project is a best tutor.
I have just recently started out programming for Android, and have decided that I want to learn how to use OpenGL ES 2.0. I googled around for an example and it turns out that in the resources section of the Android Developers Website there is one.
Link: http://developer.android.com/resources/tutorials/opengl/opengl-es20.html#touch
However, I am trying to run the first example and I get a force-close on my HTC EVO. I have tried literally copy and pasting the code from broswer to Eclipse, and adding the appropriate line in the manifest, but still no dice.
Any help here?
After reading carefully through that, turns out all i had to do was modify the activity in the manifest file. Problem Solved.