I'm trying to retrieve the position of the device. unfortunately my code continues to generate exceptional but I can not figure out what creates the problem.
To take the position, I followed what was written in https://developer.android.com/training/location/retrieve-current.html#play-services
Could anyone give me some advice?
This is my code:
public class MainActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private GoogleApiClient mGoogleApiClient;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
//some other methods...
And this is the error i get during the execution:
FATAL EXCEPTION: main
Process: com.filippocalabrese.whereismycar, PID: 12436
java.lang.NoSuchMethodError: No direct method
(Landroid/content/Context;Landroid/os/Looper;ILcom/google/android/gms/common/internal/zzg;Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;Lcom/google/android/gms/common/api/GoogleApiClient$OnConnectionFailedListener;)V
in class Lcom/google/android/gms/common/internal/zzk; or its super
classes (declaration of 'com.google.android.gms.common.internal.zzk'
appears in
/data/app/com.filippocalabrese.whereismycar-1/split_lib_dependencies_apk.apk:classes15.dex)
at com.google.android.gms.location.internal.zzb.(Unknown Source)
at com.google.android.gms.location.internal.zzl.(Unknown Source)
at com.google.android.gms.location.LocationServices$1.zzn(Unknown
Source)
at com.google.android.gms.location.LocationServices$1.zza(Unknown
Source)
at
com.google.android.gms.common.api.GoogleApiClient$Builder.zza(Unknown
Source)
at
com.google.android.gms.common.api.GoogleApiClient$Builder.zzvq(Unknown
Source)
at
com.google.android.gms.common.api.GoogleApiClient$Builder.build(Unknown
Source)
at
com.filippocalabrese.whereismycar.MainActivity.onCreate(MainActivity.java:34)
at android.app.Activity.performCreate(Activity.java:6662)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
I've tryed to Google it and search for a solution but i've had no luck at all :/
java.lang.NoSuchMethodError
I suspect the android version you are using is different from the tutorial you are following on. sometimes method signatures get updated along the versions. Please verify that you have the right version as the tutorial/article you are trying to use.
Related
My problem is quite a troublesome one, i made an app on Android Studio that has a TextView that displays the Firebase registration token upon launch (I'm still new to Firebase and Android Studio, i'm experimenting), i've been building APK files of my app to test it on my phone since Android Studio doesn't detect my phone when it's hooked to my laptop for some reason and i can't use emulation because my laptop is old (i think it doesn't support virtualization), so whenever i try to launch my app on my phone i get the equivalent of MyApp stopped working in French and i don't know how to view the crash log files.
tl;dr i wanna know what's causing my app to crash
MainActivity.java
package com.gci.gestioncapteursincendie;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.TextView;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
public class MainActivity extends AppCompatActivity {
private TextView textView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView= findViewById(R.id.textViewToken);
FirebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
#Override
public void onComplete(#NonNull Task<InstanceIdResult> task) {
if(task.isSuccessful()){
String token = task.getResult().getToken();
textView.setText("Token : " + token);
}
else
{
textView.setText("Token Not Generated");
}
}
});
}
}
Edit: i managed to run my app on my phone through Android Studio by downloading the right drivers, i checked the logcat when i ran it and i got this:
03-31 18:55:45.069 8855-8855/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gci.gestioncapteursincendie, PID: 8855
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gci.gestioncapteursincendie/com.gci.gestioncapteursincendie.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.gci.gestioncapteursincendie. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.gci.gestioncapteursincendie. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common##16.0.1:219)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at com.gci.gestioncapteursincendie.MainActivity.onCreate(MainActivity.java:38)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Edit 2:
I added the following line of code referred by user Riley Manda:
FirebaseApp.initializeApp(this);
in onCreate() method and i get this error now:
log trace:
03-31 19:10:19.203 11562-11562/com.gci.gestioncapteursincendie E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gci.gestioncapteursincendie, PID: 11562
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gci.gestioncapteursincendie/com.gci.gestioncapteursincendie.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.gci.gestioncapteursincendie. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.gci.gestioncapteursincendie. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common##16.0.1:219)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at com.gci.gestioncapteursincendie.MainActivity.onCreate(MainActivity.java:41)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Edit 3: I'm making another thread about this problem since it seems like the thread has drifted away from its original purpose, thanks everyone for answering.
Connect your app to Crashlytics,this way you will receive crash emails that will lead you to the exact issue thats causing your app to crash.
Follow the instructions on firebase to setup crashlytics for your app in Android Studio.And each time your app crashes, you will receive an email from Crashlytics:
This way, each time your app crashes from your physical devices notification email from Crashlytics is automatically sent to your email indicating the exact line of code/issue that's causing your app to crash.
Based on your crashLog:
You have to initialise firebase in your activity:
Add this to your activity:
FirebaseApp.initializeApp(this);
In your onCreate:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.yourlayout);
FirebaseApp.initializeApp(this);
Add this FirebaseApp.initializeApp(this);just after setContentView(R.layout.yourlayout); or before you make any connections to firebase
Also for your device not showing in android studio
first enable developers Options On your Phone https://www.digitaltrends.com/mobile/how-to-get-developer-options-on-android/
Enable Usb Debugging in the developers Options of your Phone settings
Secondly install an adb driver on your System and try reconnecting your device
Accept the prompt on your phone that asks if you want to trust your system and it should work
When I add this
demoRef = FirebaseDatabase.getInstance().getReference().child("txt");
My App crash and when I delete it the app work can someone help me .
I tried many ways like change the version of database but nothing work and it take me more than 3 weeks without any solve
This is my Mainactivity
public class MainActivity extends Activity
{
private HashMap <String,Object>map=new HashMap();
private Button send;
private EditText edit;
private DatabaseReference demoRef;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
FirebaseApp.initializeApp(this);
demoRef = FirebaseDatabase.getInstance().getReference().child("txt");
send=findViewById(R.id.mainButton1);
edit=findViewById(R.id.mainEditText1);
}
}
This is my build
dependencies {
//compile 'com.google.firebase:firebase-database:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-database:16.0.1'
compile 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
This is my Logcat
FATAL EXCEPTION: main
Process: com.firebase, PID: 5291
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.firebase/com.firebase.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.firebase. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.firebase. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(SourceFile:218)
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.firebase.MainActivity.onCreate(MainActivity.java:27)
at android.app.Activity.performCreate(Activity.java:6677)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)
... 9 more
Shutting down VM
FATAL EXCEPTION: main
Process: com.firebase, PID: 8039
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.firebase/com.firebase.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.firebase. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.firebase. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(SourceFile:218)
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.firebase.MainActivity.onCreate(MainActivity.java:27)
at android.app.Activity.performCreate(Activity.java:6677)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)
... 9 more
Remove
FirebaseApp.initializeApp(this);
and just let the reference like this
private HashMap <String,Object>map=new HashMap();
private Button send;
private EditText edit;
private DatabaseReference demoRef;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
demoRef = FirebaseDatabase.getInstance().getReference().child("txt");
send=findViewById(R.id.mainButton1);
edit=findViewById(R.id.mainEditText1);
}
And make sure you have the INTERNET permission in your manifest
remove FirebaseApp.initializeApp(this); from MainActivity and put it in onCreate of your app's Application class. Look here.
By the way, What is the API LEVEL you're testing? From Marshmallow onwards
you'll need to add runtime permissions to your app. and you probably need WRITE_STORAGE permission to use the local database.
Hope this helps!
This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 6 years ago.
i'm working on a project for indoor navigation and need to add a groundOverlay with the floorplan of the building. I've followed the guidelines on the Documentation from Google dev site. But its giving me NullPointerException when i try to add the overlay to the map.
Heres my code:
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.setIndoorEnabled(true);
mMap.setOnIndoorStateChangeListener(this);
mMap.setPadding(0,0,50,0);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-28.666957, -55.994823), 19));
//add mapOverlay
LatLngBounds iffBounds = new LatLngBounds(
new LatLng(-28.667177,-55.995104),
new LatLng(-28.667061,-55.994443)
);
GroundOverlayOptions iffMap = new GroundOverlayOptions()
.image(BitmapDescriptorFactory.fromResource(R.raw.piso_1))
.positionFromBounds(iffBounds);
mapOverlay = mMap.addGroundOverlay(iffMap);
}
I have tried debbuging the code and i can't see anything wrong, everything is being correctly instantiated, but when it executes the last line
mapOverlay = mMap.addGroundOverlay(iffmap);
My app crashes.
Here's the StackTrace from logCat:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: br.com.imerljak.vegvisir, PID: 2390
java.lang.NullPointerException: null reference
at maps.w.c.a(Unknown Source)
at maps.ad.g$a.<init>(Unknown Source)
at maps.ad.g.a(Unknown Source)
at maps.ad.w.<init>(Unknown Source)
at maps.ad.u.a(Unknown Source)
at vo.onTransact(:com.google.android.gms.DynamiteModulesB:182)
at android.os.Binder.transact(Binder.java:380)
at com.google.android.gms.maps.internal.IGoogleMapDelegate$zza$zza.addGroundOverlay(Unknown Source)
at com.google.android.gms.maps.GoogleMap.addGroundOverlay(Unknown Source)
at br.com.imerljak.vegvisir.MapsActivity.onMapReady(MapsActivity.java:62)
at com.google.android.gms.maps.SupportMapFragment$zza$1.zza(Unknown Source)
at com.google.android.gms.maps.internal.zzt$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:380)
at xz.a(:com.google.android.gms.DynamiteModulesB:82)
at maps.ad.u$5.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
PS: if anyone has any tips that will help me developing this app (like a good API for indoor navigation) i will be grateful :)
Your mapOverlay instance refence seems not to be initialized correctly...
I develop a Google Map related App on Samsung Mobile and release in play store which shows approx 7000 supported devices. When i downloaded the App on Samsung mobile it's working fine but not working on Moto and Sony Mobiles.
When i try to debug with Moto mobile it's shows "Shutting Down VM"
06-20 00:17:25.276 457-457/com.mycompany.mypackage D/AndroidRuntime﹕ Shutting down VM
06-20 00:17:25.281 457-457/com.mycompany.mypackage E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.mycompany.mypackage, PID: 457
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mycompany.mypackage/com.mycompany.mypackage.MapsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2225)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
at android.content.ContextWrapper.getPackageName(ContextWrapper.java:131)
at android.location.GeocoderParams.<init>(GeocoderParams.java:50)
at android.location.Geocoder.<init>(Geocoder.java:83)
at com.mycompany.mypackage.MapsActivity.<init>(MapsActivity.java:96)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1572)
at android.app.Instrumentation.newActivity(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215)
Answer: To the above weird problem,
I encounter very weird problem as discuss above which i finally figure out due to the Geocoder. Solution of above problem is very simple as shown below
Geocoder gc = new Geocoder(this, Locale.getDefault());
public class MapsActivity extends FragmentActivity implements .... {
...............
Geocoder gc = new Geocoder(this, Locale.getDefault());
#Override
protected void onCreate(Bundle savedInstanceState) {
............
}
............
}
In the above code snippet Geocoder defined globally.
This doesn't work on different devices. Works only on Samsung devices. The solution which i figure out finally works on all devices (Tested on Samsung, Moto, Sony).
public class MapsActivity extends FragmentActivity implements .... {
...............
#Override
protected void onCreate(Bundle savedInstanceState) {
............
}
public void send(View view) {
try {
Geocoder gc = new Geocoder(this, Locale.getDefault());
List<Address> list = gc.getFromLocationName(message, 1);
.........}
}
............
}
In above code snippet Geocoder defined locally inside the function.
This solution works for me. I hope in future someone encounter the same problem may this solution helps.
Thanks
I'm trying to retrieve the location of the device calling the method connect of the class LocationClient in my activity, however when the call is made the system crashes with the following exception:
**FATAL EXCEPTION: main
Process: com.unipagossales, PID: 3833
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.unipagossales/com.unipagossales.app.merchants.MerchantFragmentActivity}: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.location.internal.GoogleLocationManagerService.START }
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.location.internal.GoogleLocationManagerService.START }
at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1674)
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1773)
at android.app.ContextImpl.bindService(ContextImpl.java:1751)
at android.content.ContextWrapper.bindService(ContextWrapper.java:538)
at com.google.android.gms.internal.v.a(Unknown Source)
at com.google.android.gms.internal.u.connect(Unknown Source)
at com.google.android.gms.location.LocationClient.connect(Unknown Source)
at com.unipagossales.app.merchants.MerchantFragmentActivity.onStart(MerchantFragmentActivity.java:122)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
at android.app.Activity.performStart(Activity.java:5949)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
... 10 more
**
This is the way I create my LocationClient:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.merchant_activity);
...
// Create a new global location parameters object
locationRequest = LocationRequest.create();
locationRequest.setInterval(Constants.UPDATE_INTERVAL_MILLISECONDS);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setFastestInterval(Constants.FAST_INTERVAL_CEILING_MILLISECONDS);
// Initialize the location client
locationClient = new LocationClient(this, new LocationClientConnectionCallbacks(), new LocationClientOnConnectionFailedListener());
}
#Override
protected void onStart() {
super.onStart();
...
locationClient.connect();
...
}
Changing the target SDK version to "19" helped me.
This problem is related to the fact that Android VM is not being able in runtime to find the definition of the action act=com.google.android.location.internal.GoogleLocationManagerService.START in Google Play Services.
You will need to set your Google Play Services following the next blog:
http://mflerackers.wordpress.com/2014/09/09/noclassdeffounderror-for-googleplayservicesutil/
Then you will need to increment the VM values in eclipse.ini, follow this one:
Unable to execute dex: GC overhead limit exceeded in Eclipse
This should fix your exception collaterally.