Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: cannot find symbol: variable Build.VERSION_CODES.O_MR1

I am trying to implement a native module which provides connection service in react native. But I am facing an error. As I am not an android/java developer, I am not being able to find the cause of the following error.

E:\projects\deets-mobile-cp\node_modules\react-native-connection-service\android\src\main\java\com\genm\CallConnection.java:10: error: cannot find symbol
    @TargetApi(Build.VERSION_CODES.O_MR1)
                                  ^
      symbol:   variable O_MR1
      location: class VERSION_CODES
    E:\projects\deets-mobile-cp\node_modules\react-native-connection-service\android\src\main\java\com\genm\CallConnection.java:14: error: cannot find symbol
            setConnectionProperties(PROPERTY_SELF_MANAGED);
                                    ^
      symbol:   variable PROPERTY_SELF_MANAGED
      location: class CallConnection

CallConnection.java

package com.genm;

import android.annotation.TargetApi;
import android.os.Build;
import android.telecom.Connection;
import android.util.Log;

import static android.content.ContentValues.TAG;

@TargetApi(Build.VERSION_CODES.O_MR1)
public class CallConnection extends Connection{

    public CallConnection(){
        setConnectionProperties(PROPERTY_SELF_MANAGED);
        setAudioModeIsVoip(true);
    }

    @Override
    public  void onAnswer(){
        Log.d(TAG, "On answer to the call");
    }

}
like image 234
Shivam Avatar asked Mar 19 '26 18:03

Shivam


1 Answers

Be sure that you have compileSdkVersion = 27 in your build.gradle file

compileSdkVersion is the SDK level which will be used to compile your app. If you need to access properties or methods added on API 27 you need to update this value accordingly. This means that if you needed to access (for example) Build.VERSION_CODES.P you should have set compileSdkVersion = 28 and so on...

like image 122
MatPag Avatar answered Mar 21 '26 09:03

MatPag



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!