Java Android应用程序在棒棒糖上崩溃-服务意图必须明确:

Java Android应用程序在棒棒糖上崩溃-服务意图必须明确:,java,android,Java,Android,我的日志 05-05 12:02:50.620:E/AndroidRuntime(32319):java.lang.RuntimeException:无法启动活动组件信息{com.xxxxxxxx.apps.xxx/com.xxxxxx.apps.xxx.activities.SplashActivity}:java.lang.IllegalArgumentException:服务意图必须明确:意图{act=com.android.vending.licensing.licensingservi

我的日志

05-05 12:02:50.620:E/AndroidRuntime(32319):java.lang.RuntimeException:无法启动活动组件信息{com.xxxxxxxx.apps.xxx/com.xxxxxx.apps.xxx.activities.SplashActivity}:java.lang.IllegalArgumentException:服务意图必须明确:意图{act=com.android.vending.licensing.licensingservice}

在哪里修复代码

package com.xxxxxx.apps.xxx.activities;`

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings.Secure;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

import com.android.vending.licensing.AESObfuscator;
import com.android.vending.licensing.LicenseChecker;
import com.android.vending.licensing.LicenseCheckerCallback;
import com.android.vending.licensing.ServerManagedPolicy;
import com.xxxxxxxx.apps.xxxx.R;
import com.xxxxxx.libs.util.Platform;

public class SplashActivity extends Activity {

    /*[ $if full $ ]*/
    private final class xxxLicenseCheckerCallback implements LicenseCheckerCallback {
        @Override
        public void allow() {
            Log.i(TAG, "License OK");

            licenseResponseHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Intent intent = createSequencerActivityIntent();
                    startActivity(intent);
                    finish();
                }
            }, 2000);           
        }



        @Override
        public void dontAllow() {
            Log.e(TAG, "License check FAILED");

            new AlertDialog.Builder(SplashActivity.this)
                .setTitle(R.string.app_name)
                .setMessage("License check failed.\nPlease try starting the app again" +
                        " when your internet connection is ON.\n" +
                        "This is required to protect the app from piracy.\n" +
                        "If the problem persists, please contact us at xxxxxx@xxxxxx.com.")
                .setCancelable(false)
                .setNegativeButton("Close the app", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        SplashActivity.this.finish();
                    }
                })
                .setPositiveButton("Retry", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                        licenseResponseHandler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                licenseChecker.checkAccess(licenseCheckerCallback);
                            }
                        }, 1000L);
                    }
                })
            .show();
        }

        @Override
        public void applicationError(ApplicationErrorCode errorCode) {
            Log.e(TAG, "License check unavailable: " + errorCode);

            new AlertDialog.Builder(SplashActivity.this)
                .setTitle(R.string.app_name)
                .setMessage("We were unable to check your license.\nPlease try restarting the app again.\nIf the problem persists, please contact us at xxxxxx@xxxxxxx.com.")
                .setCancelable(false)
                .setPositiveButton("Close the app", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        SplashActivity.this.finish();
                    }
                })
            .show();
        }
    }
    /*[ $endif$ ]*/

    private static final String TAG = SplashActivity.class.getSimpleName();

    /*[ $if full $ ]*/
    private static final String BASE64_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnZaL3WpvXaBlnEu" +
                                                    "ToXHlWmraQ8bz7tyQ4TyaFF17BocoLpJgfNXDM43ezpaVeDYCrX7qcExn79" +
                                                    "QcSFoKzlS9ILbWEQ3mt7+kim6f1DIMqKIWZ6F0VyovshW84ps0m4Aq0ZGnp" +
                                                    "MOMBy/v63ACcRiZkymEIJSwiDp3Twdoj2R9I+NkBvjM2NSF0u2ejzmBYx6h" +
                                                    "z0jlvIvOhTbGmqJ0zQKFyKDJ17WROgscXSQ38ehvIJ2ycJvsGTsFWr/yp8P" +
                                                    "bMGVTrpLI1SZlRIY3zw8JFxxI+bx19c7+SZUqHyePjxGpq5R13r+tQRvoC6" +
                                                    "99S6EFZ3McPGXw7aZK+d21z82ILKNANwIDAQAB";
    private static final byte[] SALT = new byte[] {
         -46, 65, 30, -128, -103, -42, 77, -117, -36, -110, -57, 74, 64, 51, 88, -95, -11, 32, -60, 89
    };

    private LicenseCheckerCallback licenseCheckerCallback;
    private LicenseChecker licenseChecker;
    /*[ $endif$ ]*/
    private Handler licenseResponseHandler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        licenseResponseHandler = new Handler();

        /*[ $if full $ ]*/
        // Check the license
        licenseCheckerCallback = new xxxLicenseCheckerCallback();

        String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
        licenseChecker =  new LicenseChecker(this, 
                new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)), 
                BASE64_PUBLIC_KEY);

        licenseChecker.checkAccess(licenseCheckerCallback);
        // End license check
        /*[ $else$ 

        licenseResponseHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = createSequencerActivityIntent();
                startActivity(intent);
                finish();
            }
        }, 2000);           

            $endif$ ]*/

        ImageView imageView = new ImageView(this);
        if (Platform.isIcsOrLater()) {
            imageView.setScaleType(ScaleType.FIT_XY);
            imageView.setImageResource(R.drawable.splash_ics);
        } else {
            imageView.setScaleType(ScaleType.CENTER_CROP);
            imageView.setImageResource(R.drawable.splash);
        }

        setContentView(imageView);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        /*[ $if full $ ]*/
        if (licenseChecker != null) {
            licenseChecker.onDestroy();
        }
        /*[ $endif$ ]*/
    }

    protected Intent createSequencerActivityIntent() {
        return new Intent(SplashActivity.this, SequencerActivity.class);        
    }
}

如果我不得不打赌,给你带来麻烦的是:

    licenseChecker.checkAccess(licenseCheckerCallback);
或其上方创建
licenseChecker
的行。这看起来像是试图与
服务
通话。从棒棒糖开始,所有绑定的服务都必须使用显式的
Intent
绑定。您看到的错误是因为有东西正在调用
bindService()
,并提供了一个
Intent
对象,其中没有设置
ComponentName

这是Google Play授权库的一部分。该问题已分配,并将在将来解决。同时,如果您还想将库与棒棒糖一起使用,则有一个解决方法:

LicenseChecker.java
中,对此进行更改:

boolean bindResult = mContext.bindService(new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))),
                                          this, // ServiceConnection.
                                          Context.BIND_AUTO_CREATE);
为此:

Intent serviceIntent = new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")));
serviceIntent.setPackage("com.android.vending");

boolean bindResult = mContext.bindService(serviceIntent,
                                          this, // ServiceConnection.
                                          Context.BIND_AUTO_CREATE);

您的问题中是否有任何敏感信息,例如加密密钥?您的错误指向哪一行?2017年,错误仍然存在。非常感谢。2018年,它仍然存在。如何检查许可证?2018年过半,现在还在这里!几乎到2018年底,谷歌仍然没有修复这个明显的错误。现在是2019年,而且(令人惊讶!)仍然没有人在意。顺便说一句,我想指出,修复需要API 4。