Android: GoogleMap v2 in a fragment requires the additional permissions - android

I'm trying to use GoogleMaps V2 within a fragment, but without success. In the emulator, I get the info, that I should update the play services. The same on the Samsung Galaxy Nexus. Once I updated the play services, I get the following error. All those permission - listed in the error - are part of my manifest file. Any idea?
Remark: I uploaded the demo project to Github. Feel free to use it. I'm using IntelliJ but the GoogleMap API is from a former Eclipse project.
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.demo.mymap/com.demo.mymap.MainActivity}:
android.view.InflateException: Binary XML file line #8: Error
inflating class fragment ... Caused by: android.view.InflateException:
Binary XML file line #8: Error inflating class fragment ... Caused by:
java.lang.SecurityException: The Maps API requires the additional
following permissions to be set in the AndroidManifest.xml to ensure a
correct behavior:
My manifest looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo.mymap" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyA6mS6BJy89Sgkj1GCgRrusQ84p_T5hLEA" />
</application>
</manifest>

Move your <uses-permission> elements to be children of <manifest>, not children of <application>.

Take a look on what the Logcat says:
Caused by: java.lang.SecurityException: The Maps API requires the
additional following permissions to be set in the AndroidManifest.xml
to ensure a correct behavior:
Your permissions at your Manifest are declared wrong.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo.mymap" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyA6mS6BJy89Sgkj1GCgRrusQ84p_T5hLEA" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

Your perrmissions must be defined outside the application definition, and must be children of <manifest>:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo.mymap" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyA6mS6BJy89Sgkj1GCgRrusQ84p_T5hLEA" />
</application>
</manifest>
check the sample and the info of the official documentation:
AndroidManifest.xml

Related

Getting error on google play console even setting Exported to true In AndroidManifest File

I am getting the following error while uploading to the google play console.
You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without 'android: exported' property set. This file can't be installed on Android 12 or higher. See: developer.android.com/about/versions/12/behavior-changes-12#exported
I have set android:exported=true in the AndroidMenifest file.
This same file is working on other projects. Those projects are published successfully on the google play console. But not understanding the problem with this one.
here is my full AndroidManifest code
<?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="com.*****">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:exported="true"
android:name="com.**"
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"
android:usesCleartextTraffic="true">
<activity
android:name="****.CalenderView"
android:exported="true" />
<meta-data
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true" />
<activity
android:name="****.LoginActivity"
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:exported="true"
android:name="****.UserWelcome"
android:label="#string/title_activity_user_welcome"
android:screenOrientation="portrait" />
<activity
android:exported="true"
android:name="*****.unitTest.UniteTest"
android:label="#string/title_activity_user_welcome"
android:screenOrientation="portrait" />
<meta-data android:name="applovin.sdk.key"
android:value="****"/>
</application>
</manifest>
You need to add exported only with activity, service or receiver which have intent filters.
For the libraries that you are using for those also you need to define exported value.
Check this article for more details
https://cafonsomota.medium.com/android-12-dont-forget-to-set-android-exported-on-your-activities-services-and-receivers-3bee33f37beb

Contradictory error when using MobileAds in an Android app

I am somewhat confused by an error showing up in an Android app, where I want to use MobileAds.
Here is the Kotlin code:
val adRequest = AdRequest.Builder().build()
adView.loadAd(adRequest)
The AndroidManifest.xml file contains these three lines:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
And these are the errors I get:
Missing permissions required by BaseAdView.loadAd: android.permission.INTERNET
Missing permissions required by FusedLocationProviderClient.getLastLocation: android.permission.ACCESS_COARSE_LOCATION or android.permission.ACCESS_FINE_LOCATION
Is there anyone out there who has an idea of what is going on?
Any relevant tip or explanation would be more than welcome.
Just in case this is the complete AndroidManifest.xml file:
<?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="me.soft.app">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.App"
tools:targetApi="31">
<activity
android:name=".WorldExposureActivity"
android:exported="false"
android:parentActivityName=".ShopDetailActivity"
android:screenOrientation="portrait" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="XXXXXXX" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-1234567890012345~1234567890"/>
<activity
android:name=".ShopMapActivity"
android:exported="false"
android:label="#string/title_activity_shop_map"
android:parentActivityName=".MainActivity" />
<activity
android:name=".ShopDetailActivity"
android:exported="false"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait" />
<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Getting error when trying to generate signed APK

I am trying to generate a signed APK for my app, however, i am getting two of the below error messages. Please see my Android Manifesto file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.elderlywatch.elderlywatch">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.BODY_SENSORS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:name=".FallDetectorSettings.SettingValues"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat">
<activity
android:name=".HomeActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".HRDetailsActivity"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".HomeActivity" />
</activity>
<activity android:name=".UserActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".FallDetectHomeActivity"
android:icon="#mipmap/ic_launcher"
android:screenOrientation="portrait" />
<activity
android:name=".ContactDetailsActivity"
android:icon="#mipmap/ic_launcher"
android:screenOrientation="portrait" />
<activity
android:name=".FallDetectSettingActivity"
android:icon="#mipmap/ic_launcher"
android:screenOrientation="portrait"/>
<activity
android:name=".MonitoringFallActivity"
android:icon="#mipmap/ic_launcher"
android:screenOrientation="portrait" />
<activity
android:name=".SMSSendActivity"
android:screenOrientation="portrait" />
<service android:name=".FallDetectorAccelerometer.DetectingFalls" >
</service>
<activity
android:name=".SMSDetailsActivity"
android:icon="#mipmap/ic_launcher"
android:screenOrientation="portrait"></activity>
</application>
</manifest>
I am getting the below two error messages and please can someone help me as I am struggling to generate a singed APK. I am able to build my app, however, when trying to create a API I always get the two error messages indicated below.
Error:Execution failed for task
':mobile:transformClassesWithDexForRelease'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.dex.DexIndexOverflowException: method ID not in [0,
0xffff]: 65536
The error:
\AndroidManifest.xml Error:(48) Error: The element must be a direct
child of the root element [WrongManifestParent] Error:Execution failed
for task ':mobile:lintVitalRelease'.
This indicates that you need to look at line 48 of your manifest.xml
That line looks like:
<application
android:name=".ApplicationState"
android:label="#string/app_name" />
That's a second xml <application> tag.
It tells you that tag must be a direct child of the root.
Probably just remove it and it will work.
Remove this
<application
android:name=".ApplicationState"
android:label="#string/app_name" />
and add this
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
**android:name=".ApplicationState"**
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:name=".FallDetectorSettings.SettingValues"
android:label="#string/app_name"
android:screenOrientation="portrait"
in your gradle (app) inside android{} place this
lintOptions {
checkReleaseBuilds false
}
for dex error follow the solution given by android in the below link:
https://developer.android.com/studio/build/multidex.html

Manifest error The markup in the document following the root element must be well-formed

I am a newbie in Android development.
After build I get error in my manifest file: The markup in the document following the root element must be well-formed.
Here's the AndroidManifest.xml code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="smart.tuke.sk.makac" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<permission
android:name="smart.tuke.sk.makac.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".TrackerActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SummaryActivity"
android:label="#string/title_activity_summary" >
</activity>
</application>
</manifest>
I cannot see there any error. Thanks in advance for your help.
You have to close tag </manifest>, since Google Play Services 3.1.59 permission is now completely unnecessary, use this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="smart.tuke.sk.makac" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".TrackerActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SummaryActivity"
android:label="#string/title_activity_summary" >
</activity>
</application>
</manifest>
Clean and Rebuild!

google maps V2 IllegalStateException

I have this very weird bug that my app crashes in the minute I launch it.
the call stack is:
01-25 15:10:52.264: E/AndroidRuntime(13707): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.out.goout/com.out.goout.Splash}: java.lang.IllegalStateException:The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 4132500. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
the thing is that I do have the tag that explained in the stack trace and the version of my google play services is 14
the code in my manifest is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my package"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<uses-permission android:name="com.out.goout.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<permission
android:name="com.out.goout.permission.MAPS_RECEIVE"
android:protectionLevel="signature" >
</permission>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:name="com.out.App"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="false"
android:theme="#style/Theme.Sherlock.Light.DarkActionBar" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<uses-library
android:name="com.google.android.maps"
android:required="true" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my key" />
<activity
...
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
...
</activity>
<activity
...
</activity>
<activity
...
</activity>
<activity
...
</activity>
</application>
</manifest>
your help is much needed
Remove this line from manifest:
<uses-library
android:name="com.google.android.maps"
android:required="true" />
finnaly I got this...
I started a new android project and replace the android-support-v4.jar file clean the project and it helped!
Thanks a lot Zohra Khan for your help

Categories

Resources