I have android native project (java) with YoutubeAndroidPlayerAPI.jar official library version 1.2.2 that have a function to be embedded Youtube Player in my App. Anything work fine before migrating to AndroidX.
I realized that the code inside the YoutubeAndroidPlayerAPI didn't support to AndroidX. The class of YoutubePlayerSupportFragment that extends to Fragment still use import android.support.v4.app.Fragment not androidx.fragment.app.Fragment.
i Can not edit the code of YoutubeAndroidPlayerAPI (read-only mode) for migrating to AndroidX.
This is my sample code of my project that getting error and red color warning at 'setArguments', 'getArguments' and 'getActivity'.
public class FragmentVideoPlayer extends YouTubePlayerSupportFragment implements YouTubePlayer.OnInitializedListener {
private YouTubePlayer player;
public FragmentVideoPlayer() {
}
public static FragmentVideoPlayer newInstance(final String videoId) {
final FragmentVideoPlayer youTubeFragment = new FragmentVideoPlayer();
final Bundle bundle = new Bundle();
bundle.putString(KEY_VIDEO_ID, videoId);
youTubeFragment.setArguments(bundle);
return youTubeFragment;
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
final Bundle arguments = getArguments();
if (bundle != null && bundle.containsKey(KEY_VIDEO_ID)) {
mVideoId = bundle.getString(KEY_VIDEO_ID);
} else if (arguments != null && arguments.containsKey(KEY_VIDEO_ID)) {
mVideoId = arguments.getString(KEY_VIDEO_ID);
}
String API_KEY = new SharedPref(getActivity()).getYoutubeApiKey();
initialize(API_KEY, this);
}
}
And this is some code from YoutubeAndroidPlayerAPI
package com.google.android.youtube.player;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.youtube.player.YouTubePlayer.OnInitializedListener;
import com.google.android.youtube.player.YouTubePlayer.Provider;
import com.google.android.youtube.player.YouTubePlayerView.b;
import com.google.android.youtube.player.internal.ab;
public class YouTubePlayerSupportFragment extends Fragment implements Provider {
private final YouTubePlayerSupportFragment.a a = new YouTubePlayerSupportFragment.a((byte)0);
private Bundle b;
private YouTubePlayerView c;
private String d;
private OnInitializedListener e;
private boolean f;
}
Please, help me to solve this problem. How to fix YoutubeAndroidPlayerAPI jar file to supporting AndroidX?