I have following class
public class Settings extends RealmObject {
private String something;
}
I want to add the following field
public class AndroidBuild extends RealmObject {
int one;
int two;
}
so it looks like
public class Settings extends RealmObject {
private String something;
private AndroidBuild androidBuild;
}
So, my migration looks like
if (oldVersion == 1) {
RealmObjectSchema settingsSchema = schema.get("Settings");
RealmObjectSchema androidBuildSchema = schema.get("AndroidBuild");
if (settingsSchema != null) {
settingsSchema.addRealmObjectField("androidBuild", androidBuildSchema);
oldVersion++;
}
}
and it crashes
07-11 15:05:06.384 9046-9046/com.cassby.terminal.cassby E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cassby.terminal.cassby, PID: 9046
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cassby.terminal.cassby/com.cassby.terminal.cassby.UserStories.Launch.LaunchActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String io.realm.RealmObjectSchema.getClassName()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String io.realm.RealmObjectSchema.getClassName()' on a null object reference
at io.realm.MutableRealmObjectSchema.addRealmObjectField(MutableRealmObjectSchema.java:126)
at com.cassby.terminal.cassby.Services.Database.RealmMigrations.migrate(RealmMigrations.java:36)
at io.realm.BaseRealm$6.onMigrationNeeded(BaseRealm.java:714)
at io.realm.internal.OsSharedRealm.runMigrationCallback(OsSharedRealm.java:520)
at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(Native Method)
at io.realm.internal.OsSharedRealm.<init>(OsSharedRealm.java:184)
at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:254)
at io.realm.BaseRealm.<init>(BaseRealm.java:124)
at io.realm.BaseRealm.<init>(BaseRealm.java:93)
at io.realm.Realm.<init>(Realm.java:153)
at io.realm.Realm.createInstance(Realm.java:424)
at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:342)
at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:282)
at io.realm.Realm.getDefaultInstance(Realm.java:332)
at com.cassby.terminal.cassby.UserStories.Launch.LaunchActivity.resolveStartingActivity(LaunchActivity.java:35)
at com.cassby.terminal.cassby.UserStories.Launch.LaunchActivity.onCreate(LaunchActivity.java:29)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
What am I doing wrong ?
You need to add Table first, so
Realm.setDefaultConfiguration(new RealmConfiguration.Builder()
.name(DB_NAME)
.schemaVersion(SCHEMA_VERSION)
.migration((realm, oldVersion, newVersion) -> {
RealmSchema schema = realm.getSchema();
if (oldVersion == OLD_VERSION) {
schema.create("AndroidBuild")
.addField("one", int.class)
.addField("two", int.class);
schema.get("Settings")
.addRealmObjectField("androidBuild", schema.get("AndroidBuild"))
oldVersion++;
}
})
);
Related
I have received numerous Crashlytics reports of an exception my app is throwing, but I have never seen this myself, and I am struggling to understand where it is coming from.
My running theory is that it is related to the Firebase Auth dependency I have - but that dependency isn't actively being used yet. There is a whole sign-up and sign-in flow that my production app has disabled. The only two instances of the library being used in production code is:
// Inside Activity.onCreate()
Firebase.auth.addAuthStateListener {
val user = it.currentUser
if (user != null) {
Firebase.analytics.setUserId(user.uid)
CoroutineScope(Dispatchers.IO).launch {
registerDeviceToken(applicationContext)
}
} else {
Firebase.analytics.setUserId(null)
Firebase.messaging.deleteToken()
}
}
and:
// Called from Activity.onStart()
fun hasPendingMagicLink(intent: Intent): Boolean {
val emailAddress = getMagicLinkEmailAddress()
return emailAddress != null
&& Firebase.auth.currentUser == null
&& Firebase.auth.isSignInWithEmailLink(intent.data.toString())
}
I have included the Crashlytics reports below.
Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{com.poliziano.notanotherpomodoroapp/com.google.android.gms.auth.api.signin.internal.SignInHubActivity}: java.lang.NullPointerException
android.app.ActivityThread.performLaunchActivity
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.poliziano.notanotherpomodoroapp/com.google.android.gms.auth.api.signin.internal.SignInHubActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by java.lang.NullPointerException
android.app.ActivityThread.performLaunchActivity
Caused by java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at com.google.android.gms.internal.auth-api.zzaz.checkNotNull(zzaz.java:2)
at com.google.android.gms.auth.api.signin.internal.SignInHubActivity.onCreate(SignInHubActivity.java:5)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 4 years ago.
Im trying to write an app that puts a string in a textview if there is a file in a given url, this is the code and the crash info, what could be the error?.
public class MainActivity extends AppCompatActivity {
String url = "https://images.pexels.com/photos/617278/pexels-photo-617278.jpeg?cs=srgb&dl=adorable-animal-blur-617278.jpg&fm=jpg";
TextView textView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView.findViewById(R.id.textView);
try {
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("HEAD");
connection.connect();
if(connection.getResponseCode() == HttpURLConnection.HTTP_OK){
textView.setText("File Exists!!");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.archivoexiste, PID: 6160
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.archivoexiste/com.example.android.archivoexiste.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.widget.TextView.findViewById(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.widget.TextView.findViewById(int)' on a null object reference
at com.example.android.archivoexiste.MainActivity.onCreate(MainActivity.java:23)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Application terminated.
Change this line in your oncreate method
textView.findViewById(R.id.textView);
to this
textView = (TextView) findViewById(R.id.textView);
My app works with different listviews. Acts normally, but when memory fills (during simulation or naturally) and system dumps it, app crashes with nullpointerexception on one of the declared ListViews.
Views are declared onCreate()
a_images = (ListView) findViewById(R.id.ascii_images);
a_emotes = (ListView) findViewById(R.id.ascii_emotes);
and then called onSectionAttached()
public void onSectionAttached(int number) {
switch (number) {
case 1:
status = 1;
mTitle = getString(R.string.title_section1);
a_images.invalidateViews();
a_images.refreshDrawableState();
Here's the logcat.
05-21 20:16:54.162 11230-11230/com.joudoviny.jonda.copypasta E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.joudoviny.jonda.copypasta, PID: 11230
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.joudoviny.jonda.copypasta/com.example.jonda.copypasta.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.invalidateViews()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2906)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1605)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:172)
at android.app.ActivityThread.main(ActivityThread.java:6637)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.invalidateViews()' on a null object reference
at com.example.jonda.copypasta.MainActivity.onSectionAttached(MainActivity.java:303)
at com.example.jonda.copypasta.MainActivity$PlaceholderFragment.onAttach(MainActivity.java:530)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1363)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3217)
at android.support.v4.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:3166)
at android.support.v4.app.FragmentController.dispatchCreate(FragmentController.java:181)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:319)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:84)
at com.example.jonda.copypasta.MainActivity.onCreate(MainActivity.java:99)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2784)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2906)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1605)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:172)
at android.app.ActivityThread.main(ActivityThread.java:6637)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
This happens whenever I use the ListView, in this case in invalidateViews() method.
I am writing code to fetch data from a firebase database:
private void displayMessages(){
//Suppose you want to retrieve "chats" in your Firebase DB:
DatabaseReference ref=FirebaseDatabase.getInstance().getReference(Constants.USERS_CHAT).child(chatId);
Log.d(TAG,"Inside query"+ref);
ref.addListenerForSingleValueEvent(new ValueEventListener(){
#Override
public void onDataChange(DataSnapshot dataSnapshot){
Log.d(TAG,"Inside query Inside onDataChange");
if(dataSnapshot.exists()) {
queryforDisplayMessages=mDbRefusers_chat.child(chatId);
}else{
queryforDisplayMessages=mDbRefusers_chat.child(revchatId);
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
But when running it, I get the following exception:
Process: com.iworld.daxi, PID: 20438
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.iworld.daxi/com.iworld.daxi.UserChatActivity}:
java.lang.RuntimeException: Failed to call observer method
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.RuntimeException: Failed to call observer method
at android.arch.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:225)
at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:193)
at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:184)
at android.arch.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:36)
at android.arch.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
at android.arch.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:292)
at android.arch.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:332)
at android.arch.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:137)
at android.arch.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:123)
at android.arch.lifecycle.ReportFragment.dispatch(ReportFragment.java:121)
at android.arch.lifecycle.ReportFragment.onStart(ReportFragment.java:81)
at android.app.Fragment.performStart(Fragment.java:2637)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1312)
at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1549)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1611)
at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3039)
at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:2996)
at android.app.FragmentController.dispatchStart(FragmentController.java:189)
at android.app.Activity.performStart(Activity.java:7021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2909)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.database.ChildEventListener com.google.firebase.database.Query.addChildEventListener(com.google.firebase.database.ChildEventListener)' on a null object reference
at com.firebase.ui.database.FirebaseArray.onCreate(FirebaseArray.java:53)
at com.firebase.ui.common.BaseObservableSnapshotArray.addChangeEventListener(BaseObservableSnapshotArray.java:97)
at com.firebase.ui.database.FirebaseListAdapter.startListening(FirebaseListAdapter.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at android.arch.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:215)
at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:193)
at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:184)
at android.arch.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:36)
at android.arch.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
at android.arch.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:292)
at android.arch.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:332)
at android.arch.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:137)
at android.arch.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:123)
at android.arch.lifecycle.ReportFragment.dispatch(ReportFragment.java:121)
at android.arch.lifecycle.ReportFragment.onStart(ReportFragment.java:81)
at android.app.Fragment.performStart(Fragment.java:2637)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1312)
at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1549)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1611)
at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3039)
at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:2996)
at android.app.FragmentController.dispatchStart(FragmentController.java:189)
at android.app.Activity.performStart(Activity.java:7021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2909)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
03-08 10:22:40.020 20438-20438/com.iworld.daxi D/AppTracker: App Event: crash
I have also observed that the onDataChange() method is not getting triggered.
I have used the BluetoothLeGatt example from Android and now I want to load a xml file depending on the UUID of the device I'm connecting with.
I've tried to compare the UUID's with the following code.
mBluetoothLeService.getSupportedGattServices().equals("0003CBBB-0000-1000-8000-00805F9B0131")
With the function:
public List<BluetoothGattService> getSupportedGattServices() {
if (mBluetoothGatt == null) return null;
return mBluetoothGatt.getServices();
}
What am I doing wrong?
Here is the error code:
FATAL EXCEPTION: main
Process: com.example.android.bluetoothlegatt, PID: 1314
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.bluetoothlegatt/com.example.android.bluetoothlegatt.DeviceControlActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.example.android.bluetoothlegatt.BluetoothLeService.getSupportedGattServices()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2924)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.example.android.bluetoothlegatt.BluetoothLeService.getSupportedGattServices()' on a null object reference
at com.example.android.bluetoothlegatt.DeviceControlActivity.onCreate(DeviceControlActivity.java:483)
at android.app.Activity.performCreate(Activity.java:6912)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2877)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358
As per I understand your question :
List<BluetoothGattService> services = mBluetoothLeService.getSupportedGattServices();
for (int i = 0; i < services.size(); i++) {
BluetoothGattService gattService = services.get(i);
if(gattService.getUuid().toString().equalsIgnoreCase("0003CBBB-0000-1000-8000-00805F9B0131"))
Log.e("SERVICES : ", "" + gattService.getUuid());
}
}