I'm developing an application using Google Maps. It references the Google Map Util library project, which references google play services library and appcompat-v7. Here is my workspace:
https://www.dropbox.com/s/cwy2o9di7bk74li/Zrzut%20ekranu%202014-12-14%2016.21.07.png?dl=0
And yet, if I try to compile and run the application, it instantly crashes, with the following trace:
12-14 16:14:24.063: E/AndroidRuntime(7592): FATAL EXCEPTION: main
12-14 16:14:24.063: E/AndroidRuntime(7592): java.lang.NoClassDefFoundError: com.google.android.gms.maps.model.LatLng
12-14 16:14:24.063: E/AndroidRuntime(7592): at michal.myapp.activities.StartupScreenActivity.onCreate(StartupScreenActivity.java:36)
So apparently the compiler has trouble finding google play services jars. Any ideas?
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="michal.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<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="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCELEROMETER"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="michal.myapp.activities.MapActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="michal.myapp.activities.StartupScreenActivity"
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="michal.myapp.activities.CameraActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<!-- configure this activity to use landscape orientation -->
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/api_key"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Plus, checked the class folders, and they do exist at the locations pointed in the Manifest.
Okay, I added back Android Private Libraries to the build path (removed them because I had JAR mismatches because of it), but now it seems to work. I'll mark the answer as correct.
You must follow the oficial steps by Google to nice configuration of library : https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api
Related
I have just created my first Android Automotive project:
when I run AndroidAutoDemo.mobile module it works fine:
Unfortunately when I switch to AndroidAutoDemo.automotive module I get:
Could not identify launch activity: Default Activity not found
Error while Launching activity
Failed to launch an application on all devices
This is the Android Manifest file in AndroidAutoDemo.automotive module (left as default):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidautodemo">
<uses-feature
android:name="android.hardware.type.automotive"
android:required="true" />
<application
android:allowBackup="true"
android:appCategory="audio"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AndroidAutoDemo" />
</manifest>
This is my mobile emulator:
How can I fix?
To run automotive app you need Automotive emulator and Automotive flavor with Manifest like below. Also there is no Automotive emulator provided by Google yet but you can get other open source emulator from like Polestar https://developer.polestar.com/sdk/polestar2-sys-img.xml
and Volvo https://developer.volvocars.com/sdk/volvo-sys-img.xml
You don't have to add new activity
if want to understand you can go through example source code
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:car/app/app-samples/helloworld/
`
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="androidx.car.app.sample.helloworld"
android:versionCode="1"
android:versionName="1.0">
<!-- Various required feature settings for an automotive app. -->
<uses-feature
android:name="android.hardware.type.automotive"
android:required="true" />
<uses-feature
android:name="android.software.car.templates_host"
android:required="true" />
<uses-feature
android:name="android.hardware.wifi"
android:required="false" />
<uses-feature
android:name="android.hardware.screen.portrait"
android:required="false" />
<uses-feature
android:name="android.hardware.screen.landscape"
android:required="false" />
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:extractNativeLibs="false">
<meta-data
android:name="com.android.automotive"
android:resource="#xml/automotive_app_desc"
tools:ignore="MetadataTagInsideApplicationTag" />
<meta-data android:name="androidx.car.app.minCarApiLevel"
android:value="1"
tools:ignore="MetadataTagInsideApplicationTag" />
<service
android:name="androidx.car.app.sample.helloworld.common.HelloWorldService"
android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService" />
</intent-filter>
</service>
<activity
android:name="androidx.car.app.activity.CarAppActivity"
android:theme="#android:style/Theme.DeviceDefault.NoActionBar"
android:exported="true"
android:launchMode="singleTask"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="distractionOptimized" android:value="true"/>
</activity>
</application>
</manifest>
`
Each Manifest file should include information about available activities and launcher activity. Launcher activity needs to be defined with some additional Intent filters, for example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.car">
<uses-permission android:name="android.car.permission.CAR_POWERTRAIN" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.DeviceDefault.NoActionBar">
<activity android:name="com.example.car.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I want to use HereMap SDK in my android app. I followed official tutorial https://developer.here.com/documentation/android-premium/dev_guide/topics/app-create-simple.html.
When I run app, I get an error message:
MapService is missing from the AndroidManifest.xml file. Please refer to the user guide for details about proper project setup.
The message address missing MapService, but I have already added MapService to AndroidManifest.xml. This is my AndroidManifest.xml:
<?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="my.Package.Name">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<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.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:hardwareAccelerated="true"
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:largeHeap="true"
android:roundIcon="#drawable/app_icon"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<!--other activity declerations-->
<meta-data android:name="com.here.android.maps.appid" android:value="#string/here_map_app_id"/>
<meta-data android:name="com.here.android.maps.apptoken" android:value="#string/here_map_app_code"/>
<meta-data android:name="com.here.android.maps.license.key" android:value="#string/here_map_license"/>
<service
android:name="com.here.android.mpa.service.MapService"
android:label="HereMapService"
android:process="global.Here.Map.Service.v3"
android:exported="true" >
<intent-filter>
<action android:name="#string/here_map_intent_name" >
</action>
</intent-filter>
</service>
</application>
</manifest>
Can you help me in this situation? Thank you all!
I am using HereMap SDK version 3.13.3, I have modified HereMap service declaration as folowings so now it works brilliant. Note that I use string directly com.heremapproject.myapp instead of #string/here_map_intent_name inside <intent-filter>
<service
android:name="com.here.android.mpa.service.MapService"
android:label="HereMapService"
android:exported="false" >
<intent-filter>
<action android:name="com.heremapproject.myapp" ></action>
</intent-filter>
</service>
I have this error: Google Maps Android APIļ¹ Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors)
I must say that I have requested API key with the debug keystore and I do have the needed permissions. Here is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tripin.corinaracasan.tripin"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="com.example.googlemaps.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<permission
android:name="com.tripin.corinaracasan.tripin.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<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" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MyActivity"
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:label="#string/app_name" android:name=".MarkItemClass"/>
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="................................." />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
I am busy with an Android project with the android-support-v7-appcompat library for ActionBar, I have followed the description on Android Developer
but I have got every time NoClassDefFoundError: eu.definecontent.fazilet.HomeFragment.
I can not find where is wrong in the code or configuration, maybe you can find it, I would be glad if you could help me:
MainActivity:
public class MainActivity extends ActionBarActivity {
...
Fragment fragment = new HomeFragment();
...
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.definecontent.fazilet"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
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_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" >
</uses-permission>
<application
android:name=".FaziletApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat" >
<activity
android:name="eu.definecontent.fazilet.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>
<service android:name=".service.FillDailyTimetableService" />
<activity
android:name=".helper.DownloadManager"
android:theme="#android:style/Theme.Dialog" />
<activity android:name=".CitySettingActivity" />
<activity android:name=".LocationSettingActivity" />
</application>
and configuration are:
Thanks to G V have Finally fixed that!
just added a try catch statement to initialize a static class and everythings works now!
for more info plz see this article:
javareferencegv.blogspot.com
When I'm trying running my app:
No Launcher activity found!
The launch will only sync the application package on the device!
I've readed all questions about similar problems, I changed my manifest.xml but every time I get same error. I stucked for an hour trying to solve this and nothing works.
Here's my manifest fragment:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mosbin"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" >
<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" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_OWN_KEY" />
/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mosbin.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>
<activity
android:name="com.example.mosbin.Run"
android:label="#string/title_activity_run"
android:parentActivityName="com.example.mosbin" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mosbin" />
</activity>
<activity
android:name=".Stats"
android:label="#string/title_activity_stats"
android:parentActivityName="com.example.mosbin" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mosbin" />
</activity>
</application>
</uses-sdk>
What's wrong with this code?
Before it appears I just wanted to add new activity ...
< /uses-sdk > clear this tag at the end of your manifest and change this
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" > missing / here
to :
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
Also take these into your application tag :
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_OWN_KEY" />
https://developers.google.com/maps/documentation/android/start.
Check the link and the topic under Adding the API Key to your application
This is what you Manifest should look like:
Do note how the various tags have been opened and closed. And nested where required.
Also, read up on the Android Manifest Docs. That will ensure there is no confusion in the future. ;-)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mosbin"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" >
</uses-sdk>
<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" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_OWN_KEY" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mosbin.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>
<activity
android:name="com.example.mosbin.Run"
android:label="#string/title_activity_run"
android:parentActivityName="com.example.mosbin" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mosbin" />
</activity>
<activity
android:name=".Stats"
android:label="#string/title_activity_stats"
android:parentActivityName="com.example.mosbin" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mosbin" />
</activity>
</application>
</manifest>