I'm new to Android development. I'm trying to get a simple HelloWorld app going on my (rooted) phone - and the app is trying to enable Bluetooth.
I've set the Bluetooth permissions in my manifest is as follows, but I'm getting a Permission Denial exception when I try to run the application on my phone via Eclipse:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloandroid"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name" android:debuggable="true" android:permission="android.permission.BLUETOOTH_ADMIN">
<activity android:name=".HelloAndroid"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-sdk android:targetSdkVersion="7" android:minSdkVersion="5"></uses-sdk>
</manifest>
Is there something obvious I'm missing?
The answer about what to include in your manifest.xml for bluetooth activity includes
<uses-feature android:name="android.hardware.bluetooth" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
The first three are of greater priority and as I'm sure you're aware there are different cases when each dependency may be required. Hope it helps with your setup!
I'm not quite sure what the problem was here.
All I can say is that I reinstalled Eclipse and its plugins and now everything is working fine. Thanks for your help Mayra - I'll up-mark your answer because of your helpful and friendly approach.
The element types in the manifest are ordered. I think the uses-permission needs to be first under the tag.
Related
I am currently using this AndroidManifest in my project: Current Manifest, however I am trying to use this other AndroidManifest from a website in order to implement an image upload service : Manifest to add
I have been searching for answers but I haven't been able to merge these 2 files successfully. The Current Manifest picture of course is not the entirety of it, but I simply showed you the most important parts. Am I able to merge both packages, with both applications and activities?
current manifest
<manifest
package="org.briarproject.briar"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature android:name="android.hardware.bluetooth"/>
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<application
android:name="org.briarproject.briar.android.BriarApplicationImpl"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher_round"
android:label="#string/app_name"
android:logo="#mipmap/ic_launcher_round"
android:theme="#style/BriarTheme">
<activity
android:name="org.briarproject.briar.android.reporting.DevReportActivity"
android:excludeFromRecents="true"
android:exported="false"
manifest to add
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.simplifiedlearning.volleymysqlexample">
<!-- the internet permission -->
<uses-permission android:name="android.permission.INTERNET" />
<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>
Do you still want to merge them (or still are wondering how to do it, after reading other peoples comments) ?.
If so (you could have used a separate module or make a library), one way is like this:
I kept your old package name as the external main one
I made sure I had all permissions of both manifest's
I kept the new Activity's intent-filter (so it's the first Activity on launch)
You need to physically copy the new source code (directory/s) into your current source code
("net.simplifiedlearning.volleymysqlexample.MainActivity" meaning physically "...\net\simplifiedlearning\volleymysqlexample\MainActivity" {windows path convention})
Merging manifest's is quite a simple operation, merging resources can be a lot of work. Questions you have to ask yourself:
Do I need resources from the new project and copy/merge them into the current ?
(They may be many and incompatible, strings,layouts, styles and themes in particular but many more ...).
Is the build system of the new project merged into your project ?
Example resource directories (not to mention all the files):
res +
+---drawable-hdpi
+---drawable-land-hdpi
+---drawable-land-ldpi
+---drawable-land-mdpi
+---drawable-land-xhdpi
+---drawable-land-xxhdpi
+---drawable-land-xxxhdpi
+---drawable-mdpi
+---drawable-port-hdpi
+---drawable-port-ldpi
+---drawable-port-mdpi
+---drawable-port-xhdpi
+---drawable-port-xxhdpi
+---drawable-port-xxxhdpi
+---drawable-xhdpi
+---drawable-xxhdpi
+---layout
+---menu
+---mipmap-hdpi
+---mipmap-ldpi
+---mipmap-mdpi
+---mipmap-xhdpi
+---mipmap-xxhdpi
+---mipmap-xxxhdpi
+---values
+---xml
The merged manifest:
<manifest
package="org.briarproject.briar"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature android:name="android.hardware.bluetooth"/>
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<application
android:name="org.briarproject.briar.android.BriarApplicationImpl"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher_round"
android:label="#string/app_name"
android:logo="#mipmap/ic_launcher_round"
android:theme="#style/BriarTheme">
<activity android:name="org.briarproject.briar.android.reporting.DevReportActivity">
android:label="#string/crash_report_title"
</activity>
<activity android:name="net.simplifiedlearning.volleymysqlexample.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
your code shows two differentes packages, anyway, merge several manifest is a gradle or IDE task:
"Your APK file can contain just one AndroidManifest.xml file, but your Android Studio project may contain several—provided by the main source set, build variants, and imported libraries. So when building your app, the Gradle build merges all manifest files into a single manifest file that's packaged into your APK."
source: https://developer.android.com/studio/build/manifest-merge.html
We wrote all permission codes between suitable tags. But when i install the program there is no ask about permissions.
Where is my fault?
this my manifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.berker.notkayit">
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="24" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
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>
Writing permissions in Manifest file won't ask permissions on runtime. In order to show permissions, you need to write code in your application instances. Refer this link https://developer.android.com/training/permissions/requesting.html
are u testing the app in marshmallow or above device means it won't ask for permission during installation but it will permission during run time have u added the runtime permission codes
It dependences on your devices, if you device Android version is below 6.0, then you way is ok, however, if you device version is 6.0 and above then you need add runtime permission, check this link https://github.com/googlesamples/easypermissions
I'm not entirely sure how or why this is happening, but when I install my app, There are 2 apks that are installed. They have the same name and they have the same icon. One (top right, circled in red) force closes and the other (bottom left, circled in yellow) works just fine. But I dont want 2, only 1. Below is my manifest as Im sure that is where the issue is happening.
EDIT: I believe it has something to do with the servicestarter activity but I'm not sure what.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="bladebeat.pro.swipeup" >
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application tools:replace="android:icon , android:theme"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" >
<activity
android:name=".ServiceStarter">
<intent-filter>
<action android:name="android.intent.action.ASSIST"></action>
<action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
</activity>
<activity android:name=".HomeActivity"></activity>
<service android:name=".Servers.SearchManager"></service>
</application>
</manifest>
Do this in your manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="bladebeat.pro.swipeup"
android:versionCode="1"
android:versionName="1.0" >
Android Studio builds two applications for the same project simultaenously
This was the problem. It actually had nothing to do with my Manifest and everything to do with my dependencies manifest. Problem solved though it should not have happened in the first place.
I had my existing android project going unmanageable due to unnecessary research codes, so I decided to create a new project with only necessary code that's required for the app. I uploaded the same on play store's beta environment. As the app got updated on my phone, the already existing app icon on home screen got removed. Did I make any mistake in the code development?
Please help
EDIT: Added Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.abc"
android:installLocation="preferExternal"
android:versionCode="52"
android:versionName="5.0.004" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name="com.example.abc.Appname"
android:allowBackup="true"
android:icon="#drawable/launcher"
android:label="#string/app_name"
android:theme="#style/Theme.CustomTheme" >
<activity
android:name="com.example.abc.SplashScreen"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/title_activity_app_name"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</manifest>
Reverted back the application name to old file name (java class) and the same in manifest file. The launcher icon was created while installing via Google play store's beta environment.
Still unsure why the application name and java class names had an impact on the launcher icons. Any idea?
I am developing some app for android which worked well untill this evening.
However the app is working well in emulator but on Archos 80 G9 tablet with android 3.2.80 I got this error
The application Package installer (process com.android.packageinstaller) has stopped unexpectedly. Please try again.
Also here is my manifest XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="oni.dani"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="13"
/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:debuggable="true"
>
<activity
android:label="#string/app_name"
android:screenOrientation="portrait"
android:name="com.android.onidani.Dashboard" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.android.onidani.KlasaPrikazBaze"></activity>
<activity android:name="com.android.onidani.Dashboard"></activity>
<activity android:name="com.android.onidani.OniDaniActivity"></activity>
</application>
</manifest>
This error is occuring because you have declared your Dashboard activity twice.
<activity android:name="com.android.onidani.Dashboard"></activity>
You should add permission declaration in your manifest file. E.g
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
error: 'unfortunately package installer has stopped'. This happens when application needs permissions like location, phone call, Read external storage, write external storage etc. If permission is not defined in the manifest file then i get this kind of error message.
Add permission in manifest file according to your need
i need read/write file so i added below permission (outside of application)
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
in my situation i was passing empty array to requestPermissions. so check if your array is'not empty (String[] permissions)