Firebase App crash when I open it initialize - java

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!

Related

How to fix Android app crashing that uses Firebase?

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

NullPointerException when declaring RecyclerView [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 3 years ago.
I am trying to declare a RecyclerView in an activity in my project. When I switch to this activity, the project crashes.
I am getting a NullPointerException when I try to instantiate my RecyclerView, see error below:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.marykate.marykatefordefyp, PID: 13490
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.marykate.marykatefordefyp/com.example.marykate.marykatefordefyp.ViewFavourites}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2264)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2313)
at android.app.ActivityThread.access$1100(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5336)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.marykate.marykatefordefyp.ViewFavourites.onCreate(ViewFavourites.java:54)
at android.app.Activity.performCreate(Activity.java:5302)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2228
I have looked at similar questions on this site but none have the answer I am looking for. I am not referencing the wrong xml file and I am calling the correct RecyclerView.
See my code below:
RecyclerView eventsListview;
List<Favourite> favourites = new ArrayList<>();
FaveAdapter adapter = new FaveAdapter(this, R.layout.eventlist_layout, favourites);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_favourites);
eventsListview.findViewById(R.id.eventsListview1); //the line causing an error
Does anyone know what might be causing this?
eventsListview = (RecyclerView)findViewById(R.id.eventsListview1);

Android Location Exception

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.

Why is getApplicationContext throwing nullPointerException, in singleton getInstance?

I have created a class (GameHelper) which extends SQLiteOpenHelper. I want it to be a singleton, so I can create it and have it store the contents of the database during runtime, with all other classes referencing it.
I followed the advice here, (Approach 1).
So I when I need to reference the database, I don't create a new instance of GameHelper, I call getInstance. Here is the relevant code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game_info);
populate(getIntent().getStringExtra("game"), getIntent().getStringExtra("game"));
}
public void populate(String gameToGo, String game) {
DataTable game = gameHelper.getgame(game, gameToGo); //GameInfo.java:12
TextView tv = (TextView) findViewById(R.id.tableId);
String text = game.TABLE_ID;
tv.setText(text);
}
Which refers to the following method in GameHelper:
private static GameHelper sInstance;
public static synchronized GameHelper getInstance(Context context) {
// Use the application context, which will ensure that you
// don't accidentally leak an Activity's context.
// See this article for more information: http://bit.ly/6LRzfx
if (sInstance == null) {
sInstance = new GameHelper(context.getApplicationContext()); //GameHelper.java:60
}
return sInstance;
}
The problem occurs on the line sInstance = new GameHelper(context.getApplicationContext());, which throws a NullPointerException, as shown here:
11-08 10:14:54.974 16214-16214/com.example.android.whichgame E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.android.whichgame, PID: 16214
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.whichgame/com.example.android.whichgame.GameInfo}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2177)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2301)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5212)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:109)
at com.example.android.whichgame.GameHelper.getInstance(GameHelper.java:60)
at com.example.android.whichgame.GameInfo.<init>(GameInfo.java:12)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1062)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2155)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2301)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5212)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
            at dalvik.system.NativeStart.main(Native Method)
I have spent all day scouring the internet for answers, and while I have found numerous responses to similar problems, I haven't found anything that has helped. The best and most popular answer seems to be that I need to set android:name for <application> in AndroidManifest, but herein lies another problem. I'm working in Android Studio, and when I try to add my application name, the name turns red. I suppose it's possible that I'm doing it wrong! My package (as defined in the manifest) is "com.example.android.whichgame", though the app itself (and the folder it is in) is called Whichgame.
So my question is this: What am I missing that is causing getApplicationContext() to kick out the NPE when called through getInstance? And if it is because I haven't set android:name, what is causing Studio and the compiler to reject the name?
You're using your GameInfo activity as a Context too early at initialization phase. Postpone the initialization that requires a valid Context to onCreate() or later in the activity lifecycle.

Android 5.0 IllegalArgumentException: Service Intent must be explicit: on com.google.android.location.internal.GoogleLocationManagerService.START

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.

Categories

Resources