在Google Mobile Ads SDK v17.0.0中无法获取提供者com.google.android.gms.ads.MobileAdsInitProvider错误

时间:2018-10-28 15:16:47

标签: android admob google-admob

升级到Google Mobile Ads SDK v17.0.0时,出现错误(实现'com.google.android.gms:play-services-ads:17.0.0')

import java.awt.Dimension;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.*;

public class EditablePanel extends JPanel {
    private JLabel label;
    private JTextField field;

    public EditablePanel(String title) {
        super();
        setLayout(new OverlayLayout(this));
        setOpaque(false);

        add(label = new JLabel(title));
        label.setFocusable(false);

        field = new JTextField(title);
        field.setBorder(BorderFactory.createEmptyBorder());
        field.setVisible(false);
        field.addActionListener((e) -> finish(true));
        add(field);

        label.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    label.setVisible(false);
                    field.setVisible(true);
                    field.requestFocusInWindow();
                    field.selectAll();
                }
            }
        });
    }

    private void finish(boolean commit) {
        label.setText(field.getText());
        label.setVisible(true);
        field.setVisible(false);
        field.transferFocusUpCycle();
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame("Editable Tab Headers");
        frame.setPreferredSize(new Dimension(400, 300));
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        JTabbedPane pane = new JTabbedPane();
        pane.addTab("First Tab", new JLabel("First tab contents"));
        pane.addTab("Second Tab", new JLabel("Second tab contents"));
        pane.setTabComponentAt(0, new EditablePanel("First Tab"));
        pane.setTabComponentAt(1, new EditablePanel("Second Tab"));
        frame.add(pane);

        frame.pack();
        frame.setVisible(true);
    }
}

该如何解决?

1 个答案:

答案 0 :(得分:2)

从17.0.0版本开始,如果您是AdMob发布商,则现在需要在AndroidManifest.xml文件中添加AdMob应用ID。

Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider

https://developers.google.com/admob/android/quick-start#update_your_androidmanifestxml